Source code of Windows XP (NT5)
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.

117 lines
2.2 KiB

  1. #ifndef CSVDSREADER_HPP
  2. #define CSVDSREADER_HPP
  3. #include <comdef.h>
  4. #include <set>
  5. #include <map>
  6. #include <list>
  7. using namespace std;
  8. typedef set <
  9. pair<String,long>,
  10. less< pair<String,long> > ,
  11. Burnslib::Heap::Allocator< pair<String,long> >
  12. > setOfObjects;
  13. typedef map <
  14. long,
  15. LARGE_INTEGER,
  16. less<long>,
  17. Burnslib::Heap::Allocator<LARGE_INTEGER>
  18. > mapOfOffsets;
  19. typedef
  20. map< String,
  21. long,
  22. less<String>,
  23. Burnslib::Heap::Allocator<long>
  24. > mapOfPositions;
  25. class CSVDSReader
  26. {
  27. private:
  28. mapOfOffsets localeOffsets; // locale x offsets
  29. mapOfPositions propertyPositions; // properties x position
  30. String fileName;
  31. HANDLE file; // csv file
  32. HRESULT parseProperties();
  33. HRESULT parseLocales(const long *locales);
  34. HRESULT
  35. parseLine(
  36. const wchar_t *line,
  37. const long position,
  38. StringList &values) const;
  39. HRESULT
  40. getObjectLine(
  41. const long locale,
  42. const wchar_t *object,
  43. String &csvLine) const;
  44. HRESULT
  45. writeHeader(HANDLE fileOut) const;
  46. public:
  47. CSVDSReader();
  48. // get all values from the csv
  49. HRESULT
  50. getCsvValues(
  51. const long locale,
  52. const wchar_t *object,
  53. const wchar_t *property,
  54. StringList &values) const;
  55. // gets the csv value starting with value to XPValue
  56. // leaves XPValue empty if did not find
  57. HRESULT
  58. getCsvValue(
  59. const long locale,
  60. const wchar_t *object,
  61. const wchar_t *property,
  62. const String &value,
  63. String &XPValue) const;
  64. HRESULT
  65. makeLocalesCsv(
  66. HANDLE fileOut,
  67. const long *locales) const;
  68. HRESULT
  69. makeObjectsCsv(
  70. HANDLE fileOut,
  71. const setOfObjects &objects) const;
  72. virtual ~CSVDSReader()
  73. {
  74. if (file!=INVALID_HANDLE_VALUE) CloseHandle(file);
  75. }
  76. HRESULT
  77. read(
  78. const wchar_t *fileName,
  79. const long *locales);
  80. const String& getFileName() const {return fileName;}
  81. };
  82. #endif