Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
1.9 KiB

  1. #ifndef _PROFILE_SCHEMA_H
  2. #define _PROFILE_SCHEMA_H
  3. #include "BstrHash.h"
  4. #ifndef __no_msxml_dll_import__
  5. #import <msxml.tlb> rename_namespace("MSXML")
  6. #endif
  7. typedef CRawCIBstrHash<int> RAWBSTR2INT;
  8. #define INVALID_POS (UINT)(-1)
  9. #define FULL_SCHEMA (DWORD)(-1)
  10. class CProfileSchema
  11. {
  12. public:
  13. // Read the raw blob according to the schema, and output the positions of
  14. // each element. Output array size MUST be >= Count()
  15. HRESULT parseProfile(LPSTR raw, UINT size, UINT* positions, UINT* bitFlagPositions, DWORD* pdwAttrs);
  16. enum AttrType {
  17. tText=0,
  18. tChar,
  19. tByte,
  20. tWord,
  21. tLong,
  22. tDate,
  23. tInvalid
  24. };
  25. CProfileSchema();
  26. ~CProfileSchema();
  27. BOOL isOk() const { return m_isOk; }
  28. _bstr_t getErrorInfo() const { return m_szReason; }
  29. long GetAgeSeconds() const;
  30. #ifndef __no_msxml_dll_import__
  31. BOOL Read(MSXML::IXMLElementPtr &root);
  32. #endif
  33. BOOL ReadFromArray(UINT numAttributes, LPTSTR names[], AttrType types[], short sizes[], BYTE readOnly[] = NULL);
  34. int m_maskPos;
  35. // Number of attributes
  36. int Count() const { return m_numAtts; }
  37. // Find the index by name
  38. int GetIndexByName(BSTR name) const;
  39. BSTR GetNameByIndex(int index) const;
  40. // Get the type of an attribute
  41. AttrType GetType(UINT index) const;
  42. // Can I write to this attribute?
  43. BOOL IsReadOnly(UINT index) const;
  44. // Get the inherent size of an attribute
  45. // Returns -1 if the type is length prefixed
  46. int GetBitSize(UINT index) const;
  47. int GetByteSize(UINT index) const;
  48. CProfileSchema* AddRef();
  49. void Release();
  50. protected:
  51. long m_refs;
  52. BOOL m_isOk;
  53. _bstr_t m_szReason;
  54. // Valid until this time
  55. SYSTEMTIME m_validUntil;
  56. // Array of attribute types
  57. UINT m_numAtts;
  58. AttrType *m_atts;
  59. short *m_sizes;
  60. BYTE *m_readOnly;
  61. RAWBSTR2INT m_indexes;
  62. };
  63. #endif