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.

77 lines
1.8 KiB

  1. // MODULE: INIREAD.CPP
  2. //
  3. // PURPOSE: INI file reading classes
  4. //
  5. // COMPANY: Saltmine Creative, Inc. (206)-284-7511 [email protected]
  6. //
  7. // AUTHOR: Oleg Kalosha
  8. //
  9. // ORIGINAL DATE: 7-29-98
  10. //
  11. // NOTES:
  12. // 1. As of 1/99, needn't account for CHM file:
  13. //
  14. // Version Date By Comments
  15. //--------------------------------------------------------------------
  16. // V3.0 08-04-98 OK
  17. //
  18. #include "stdafx.h"
  19. #include "iniread.h"
  20. #include "event.h"
  21. #include "CharConv.h"
  22. ////////////////////////////////////////////////////////////////////////////////////
  23. // CINIReader
  24. ////////////////////////////////////////////////////////////////////////////////////
  25. CINIReader::CINIReader(CPhysicalFileReader * pPhysicalFileReader, LPCTSTR section)
  26. : CTextFileReader(pPhysicalFileReader),
  27. m_strSection(section)
  28. {
  29. }
  30. CINIReader::~CINIReader()
  31. {
  32. }
  33. void CINIReader::Parse()
  34. {
  35. CString str;
  36. long save_pos = 0;
  37. CString section_with_brackets = CString(_T("[")) + m_strSection + _T("]");
  38. save_pos = GetPos();
  39. if (Find(section_with_brackets))
  40. { // we have found section
  41. m_arrLines.clear();
  42. NextLine();
  43. try
  44. {
  45. while (GetLine(str))
  46. {
  47. str.TrimLeft();
  48. str.TrimRight();
  49. if (str.GetLength() == 0) // empty string
  50. continue;
  51. if (str[0] == _T('[')) // another section
  52. break;
  53. if (str[0] == _T(';')) // entry is commented
  54. continue;
  55. m_arrLines.push_back(str);
  56. }
  57. }
  58. catch (exception& x)
  59. {
  60. CString str;
  61. // Note STL exception in event log.
  62. CBuildSrcFileLinenoStr SrcLoc( __FILE__, __LINE__ );
  63. CEvent::ReportWFEvent( SrcLoc.GetSrcFileLineStr(),
  64. SrcLoc.GetSrcFileLineStr(),
  65. CCharConversion::ConvertACharToString(x.what(), str),
  66. _T(""),
  67. EV_GTS_STL_EXCEPTION );
  68. }
  69. }
  70. SetPos(save_pos);
  71. }