Core Library 1.7.0.0 Library containing core utilities and tools for threading, networking, logging, INI and CSV file management etc.

IniFileSectionDetails.h
Go to the documentation of this file.
1 // This file is part of CoreLibrary containing useful reusable utility
2 // classes.
3 //
4 // Copyright (C) 2014 to present, Duncan Crutchley
5 // Contact <dac1976github@outlook.com>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Lesser General Public License as published
9 // by the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License and GNU Lesser General Public License
16 // for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // and GNU Lesser General Public License along with this program. If
20 // not, see <http://www.gnu.org/licenses/>.
21
27 #include "IniFileLines.h"
28
29 #ifndef INIFILESECTIONDETAILS
30 #define INIFILESECTIONDETAILS
31
33 namespace core_lib
34 {
36 namespace ini_file
37 {
39 namespace if_private
40 {
41
43 class CORE_LIBRARY_DLL_SHARED_API SectionDetails final
44 {
45 public:
47 SectionDetails() = default;
49 SectionDetails(const SectionDetails&) = default;
51 explicit SectionDetails(const line_iter& sectIter);
53 ~SectionDetails() = default;
55 SectionDetails& operator=(const SectionDetails&) = default;
56 #ifdef USE_EXPLICIT_MOVE_
57
58 SectionDetails(SectionDetails&& section);
60 SectionDetails& operator=(SectionDetails&& section);
61 #else
62
63 SectionDetails(SectionDetails&&) = default;
65 SectionDetails& operator=(SectionDetails&&) = default;
66 #endif
67
71 const std::string& Section() const;
77 bool KeyExists(const std::string& key) const;
82 void AddKey(const line_iter& keyIter);
88 void UpdateKey(const std::string& key, const std::string& value);
95 bool EraseKey(const std::string& key, line_iter& lineIter);
102 std::string GetValue(const std::string& key, const std::string& defaultValue = "") const;
107 void GetKeys(keys_list& keys) const;
112 line_iter LineIterator() const;
117 size_t NumKeys() const;
118
119 private:
121 line_iter m_sectIter{};
123 using line_iter_list = std::list<line_iter>;
125 line_iter_list m_keyIters{};
127 using keys_iter = line_iter_list::iterator;
128 };
129
130 } // namespace if_private
131 } // namespace ini_file
132 } // namespace core_lib
133
134 #endif // INIFILESECTIONDETAILS
core_lib::ini_file::keys_list
std::list< std::pair< std::string, std::string > > keys_list
Typedef defining the key-value pair list for section entries.
Definition: IniFileLines.h:44
core_lib::ini_file::if_private::SectionDetails::line_iter_list
std::list< line_iter > line_iter_list
Line iterator lists typedef.
Definition: IniFileSectionDetails.h:123
core_lib
The core_lib namespace.
Definition: AsioDefines.h:59
core_lib::ini_file::if_private::SectionDetails
Class to represent an INI file&#39;s section details.
Definition: IniFileSectionDetails.h:43
core_lib::ini_file::if_private::SectionDetails::keys_iter
line_iter_list::iterator keys_iter
Line iterator list iterator.
Definition: IniFileSectionDetails.h:127
IniFileLines.h
File containing declarations relating the IniFile support classes.
core_lib::ini_file::if_private::line_iter
line_list::iterator line_iter
Line list iterator typedef.
Definition: IniFileLines.h:246