//
//	Copyright © 2007 Nemetschek North America 
//	All Rights Reserved.
//
// Created by Vladislav Stanev

#pragma once


namespace VWFC
{
	namespace Tools
	{
		// ---------------------------------------------------------------------------------------------------
		// STR# resource loader
		// Overcommes the problem of slow work of TXString::Load (or GS_GetResourceString)
		// This is singleton class that works on the current resource
		// ---------------------------------------------------------------------------------------------------
		class CSTRResLoader
		{
		protected:
									CSTRResLoader();

		public:
			virtual					~CSTRResLoader();

			static CSTRResLoader&	Instance();

		public:
			bool					Load(short id, short index, TXString& outString, bool useOnlyLocalResources = true);
			const TXString&			Load(short id, short index, bool useOnlyLocalResources = true);

		private:

			TXString				fInternalStringForLoad;
			TXString				fErrorReturnString;

			struct TStrResData {
				std::vector<unsigned char> fData;
				std::vector<const unsigned char *> fIndex;
			};

			typedef std::map<short, TStrResData>	TStringsMap;
			typedef std::pair<short, short>			TShortPair;
			typedef std::map<TShortPair, TXString>	TLoadedTXStringMap;

			TStringsMap								fmapStrings;
			TLoadedTXStringMap						fLoadedStrings;
		};
	}
}
