ProfileSection.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : LevelEdit *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/LevelEdit/ProfileSection.cpp $Author:: Patrick_s *
  25. * *
  26. * $Modtime:: 2/23/99 10:26a $Revision:: 1 *
  27. * *
  28. *---------------------------------------------------------------------------------------------*
  29. * Functions: *
  30. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  31. #include "StdAfx.H"
  32. #include "ProfileSection.H"
  33. /////////////////////////////////////////////////////////////////////////////
  34. //
  35. // Get_Next_Key
  36. //
  37. bool
  38. ProfileSectionClass::Get_Next_Key
  39. (
  40. CString *key_name,
  41. CString *key_value
  42. )
  43. {
  44. // Assume failure
  45. bool ret_val = false;
  46. // State OK?
  47. ASSERT (m_pszCurrentKey);
  48. if (m_pszCurrentKey &&
  49. (m_pszCurrentKey[0] != 0)) {
  50. // Make a temporary local copy of the key data
  51. TCHAR local_copy[256];
  52. ::lstrcpyn (local_copy, m_pszCurrentKey, sizeof (local_copy));
  53. // Get a pointer to the divider
  54. LPTSTR temp_string = ::strchr (local_copy, '=');
  55. temp_string[0] = 0;
  56. temp_string += 1;
  57. //
  58. // Strip off the comments (if any)
  59. //
  60. LPTSTR comment = ::strchr (local_copy, ';');
  61. if (comment != NULL) {
  62. comment[0] = 0;
  63. }
  64. comment = ::strchr (temp_string, ';');
  65. if (comment != NULL) {
  66. comment[0] = 0;
  67. }
  68. // Did the caller want the key name back?
  69. if (key_name != NULL) {
  70. // Everything on the left side of the divider is the key name
  71. *key_name = local_copy;
  72. key_name->TrimLeft ();
  73. key_name->TrimRight ();
  74. }
  75. // Did the caller want the key value back?
  76. if (key_value != NULL) {
  77. // Everything on the right side of the divider is the key value
  78. *key_value = temp_string;
  79. key_value->TrimLeft ();
  80. key_value->TrimRight ();
  81. }
  82. // Advance the pointer to point to the next key in the section
  83. m_pszCurrentKey += ::lstrlen (m_pszCurrentKey) + 1;
  84. // Success!
  85. ret_val = true;
  86. }
  87. // Return the TRUE/FALSE result code
  88. return ret_val;
  89. }