1
0

loaderIni.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef NULLSOFT_WINAMP_LOADER_INI_HEADER
  2. #define NULLSOFT_WINAMP_LOADER_INI_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include <bfc/dispatch.h>
  7. class ifc_omservice;
  8. class ifc_omservicehost;
  9. class ifc_omstoragehandlerenum;
  10. class LoaderIni
  11. {
  12. public:
  13. typedef enum
  14. {
  15. flagWriteNormal = 0x00000000,
  16. flagWriteZero = 0x00000001,
  17. flagHexMode = 0x00000002,
  18. } WriteFlags;
  19. public:
  20. LoaderIni();
  21. ~LoaderIni();
  22. public:
  23. HRESULT Load(LPCWSTR pszAddress, ifc_omservicehost *host, ifc_omservice **serviceOut);
  24. HRESULT Reload(ifc_omservice *service);
  25. HRESULT Save(ifc_omservice *service, UINT flags);
  26. HRESULT RegisterHandlers(ifc_omstoragehandlerenum *enumerator);
  27. private:
  28. HRESULT RequestAnsiBuffer(LPSTR *ppBuffer, UINT *pBufferMax, UINT requestSize);
  29. HRESULT RequestBuffer(LPWSTR *ppBuffer, UINT *pBufferMax, UINT requestSize);
  30. HRESULT MakeAnsiPath(LPCWSTR pszAddress);
  31. HRESULT GetServicePath(ifc_omservice *service, LPWSTR pszBuffer, UINT cchBufferMax, BOOL *fGenerated);
  32. HRESULT WideCharToAnsiBuffer(UINT codePage, DWORD flags, LPCWSTR pszWideChar, INT cchWideChar, LPCSTR pDefaultChar, BOOL *pUsedDefaultChar);
  33. HRESULT MultiByteToBuffer( UINT codePage, DWORD flags, LPCSTR pszMultiByte, INT cbMultiByte);
  34. HRESULT Write(LPCSTR pszKey, LPCWSTR pszValue);
  35. HRESULT WriteAnsi(LPCSTR pszKey, LPCSTR pszValue);
  36. HRESULT WriteUint(LPCSTR pszKey, UINT uValue, UINT flags);
  37. HRESULT ReadAnsi(LPCSTR pszKey, LPCSTR pszDefault, LPCSTR *ppszValue);
  38. UINT ReadInt(LPCSTR pszKey, UINT nDefault);
  39. private:
  40. template <class Object, class Getter>
  41. HRESULT WriteObjectStr(LPCSTR pszKey, Object *object, Getter getter);
  42. template <class Object, class Getter>
  43. HRESULT WriteObjectUInt(LPCSTR pszKey, Object *object, Getter getter, UINT flags);
  44. protected:
  45. CHAR pathAnsi[MAX_PATH];
  46. LPSTR bufferAnsi;
  47. UINT bufferAnsiMax;
  48. LPWSTR buffer;
  49. UINT bufferMax;
  50. ifc_omstoragehandlerenum *handlerEnum;
  51. };
  52. #endif //NULLSOFT_WINAMP_LOADER_INI_HEADER