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.

105 lines
2.3 KiB

  1. /******************************************************\
  2. This file implement the class that will parse an inf
  3. file.
  4. \******************************************************/
  5. #ifndef _INF_H_
  6. #define _INF_H_
  7. #include <stdafx.h>
  8. #define SEEK_LOC 4
  9. class CInfLine;
  10. class CInfFile
  11. {
  12. public:
  13. // Constructors and Destructors
  14. CInfFile();
  15. CInfFile( LPCTSTR strFileName );
  16. ~CInfFile();
  17. // Strings Functions
  18. BOOL ReadString(CString & str, BOOL bLastFilePos = TRUE);
  19. BOOL ReadSectionString(CString & str, BOOL bRecursive = FALSE);
  20. BOOL ReadSectionString(CInfLine & str);
  21. BOOL ReadSection(CString & str); // Generic Section
  22. BOOL ReadTextSection(CString & str); // Localizable Section
  23. CString GetLanguage()
  24. { return m_strLang; }
  25. // File Functions
  26. LONG Seek( LONG lOff, UINT nFrom );
  27. LONG SeekToBegin()
  28. { return Seek(0, SEEK_SET); }
  29. LONG SeekToEnd()
  30. { return Seek(0, SEEK_END); }
  31. LONG SeekToLocalize()
  32. { return Seek(0, SEEK_LOC); }
  33. LONG GetLastFilePos()
  34. { return (LONG)(m_pfileLastPos-m_pfileStart); }
  35. BOOL Open( LPCTSTR lpszFileName, UINT nOpenFlags, CFileException* pError = NULL );
  36. // Buffer access
  37. const BYTE * GetBuffer(LONG lPos = 0);
  38. private:
  39. BYTE * m_pfileStart;
  40. BYTE * m_pfilePos;
  41. BYTE * m_pfileLocalize;
  42. BYTE * m_pfileLastPos;
  43. LONG m_lBufSize;
  44. CFile m_file;
  45. CString m_strLang;
  46. };
  47. class CInfLine
  48. {
  49. friend class CInfFile;
  50. public:
  51. CInfLine();
  52. CInfLine( LPCSTR lpstr );
  53. // String functions
  54. LPCSTR GetText()
  55. { return m_strText; }
  56. LPCSTR GetTag()
  57. { return m_strTag; }
  58. LPCSTR GetData()
  59. { return m_strData; }
  60. void ChangeText(LPCSTR str);
  61. BOOL IsMultiLine()
  62. { return m_bMultipleLine; }
  63. LONG GetTextLength()
  64. { return m_strText.GetLength(); }
  65. LONG GetTagLength()
  66. { return m_strTag.GetLength(); }
  67. LONG GetDataLength()
  68. { return m_strData.GetLength(); }
  69. // copy operator
  70. CInfLine& operator=(const CInfLine& infstringSrc);
  71. CInfLine& operator=(LPCTSTR lpsz);
  72. private:
  73. CString m_strData;
  74. CString m_strTag;
  75. CString m_strText;
  76. BOOL m_bMultipleLine;
  77. void SetTag();
  78. void SetText();
  79. CString Clean(LPCSTR lpstr);
  80. };
  81. #endif //_INF_H_