StormByte-Config 2.0.0
C++26 configuration-document module of the StormByte suite
 
Loading...
Searching...
No Matches
value.hxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024-2026 David C. Manuelda (StormBytePP)
3 *
4 * This file is part of StormByte-Config.
5 *
6 * StormByte-Config original source is dual-licensed:
7 *
8 * 1. GNU Lesser General Public License v3.0 (or later)
9 * You may redistribute and/or modify this file under the terms of the
10 * GNU Lesser General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option)
12 * any later version.
13 *
14 * 2. Commercial license
15 * Alternatively, this file may be used under the terms of a commercial
16 * license agreement with the copyright holder
17 * (David C. Manuelda <StormByte@gmail.com>).
18 *
19 * Both licenses apply only to original StormByte-Config source in this
20 * repository. They do not cover other StormByte modules or any third-party
21 * material shipped with this repository (including everything under
22 * thirdparty/, and in particular the bundled StormByte-String tree and
23 * the StormByte Base tree it vendors), which remains under its own license.
24 *
25 * Neither license grants any patent rights. Any patent licenses required
26 * to use this software or third-party components must be obtained separately
27 * from the patent holders.
28 *
29 * StormByte-Config is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU Lesser General Public License for more details.
33 *
34 * You should have received a copy of the GNU Lesser General Public License
35 * version 3 along with StormByte-Config. If not, see
36 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
37 *
38 * SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-StormByte-Commercial
39 */
40
41#pragma once
42
47
48#include <string_view>
49
60 public:
65 explicit Value(int value);
66
71 explicit Value(double value);
72
77 explicit Value(bool value);
78
83 explicit Value(const StormByte::String::String& value);
84
90
95 explicit Value(const char* value);
96
101 explicit Value(std::string_view value);
102
107 explicit Value(const StormByte::BinaryData& value);
108
113 explicit Value(StormByte::BinaryData&& value);
114
120 Value(const StormByte::String::String& name, int value);
121
127 Value(const StormByte::String::String& name, double value);
128
134 Value(const StormByte::String::String& name, bool value);
135
142
148 Value(const StormByte::String::String& name, const char* value);
149
156
162 Value(std::string_view name, int value);
163
169 Value(std::string_view name, double value);
170
176 Value(std::string_view name, bool value);
177
183 Value(std::string_view name, std::string_view value);
184
190 Value(std::string_view name, const char* value);
191
197 Value(std::string_view name, const StormByte::BinaryData& value);
198
203 Value(const Value& value);
204
209 Value(Value&& value) noexcept;
210
216 Value& operator=(const Value& value);
217
223 Value& operator=(Value&& value) noexcept;
224
228 ~Value() noexcept override;
229
234 Item::Type Kind() const noexcept;
235
240 Item::Type Type() const noexcept override;
241
247 Value& operator=(int value);
248
254 Value& operator=(double value);
255
261 Value& operator=(bool value);
262
268 Value& operator=(const StormByte::String::String& value);
269
275 Value& operator=(const char* value);
276
282 Value& operator=(const StormByte::BinaryData& value);
283
287 operator int&();
288
292 operator const int&() const;
293
297 operator double() const;
298
302 operator double&();
303
307 operator bool&();
308
312 operator const bool&() const;
313
317 operator StormByte::String::String&();
318
322 operator const StormByte::String::String&() const;
323
327 operator StormByte::BinaryData&();
328
332 operator const StormByte::BinaryData&() const;
333
338 PointerType Clone() const override;
339
344 PointerType Move() override;
345
351 StormByte::String::String Serialize(const int& indent_level) const override;
352
353 protected:
359 bool Equals(const Base& base) const override;
360
361 private:
362 Item::Type m_kind;
363 union Storage {
364 int integer;
365 double floating;
366 bool boolean;
369 Storage() noexcept {}
370 ~Storage() noexcept {}
371 } m_store;
372
373 void Destroy() noexcept;
374 void CopyFrom(const Value& value);
375 void MoveFrom(Value&& value) noexcept;
376
381 [[noreturn]] void Fail(const char* wanted) const;
382 };
383}
384
385#include <StormByte/config/item/base.txx>
Base class for all configuration items.
Definition base.hxx:66
Scalar configuration item.
Definition value.hxx:59
Value(const StormByte::String::String &value)
Constructor.
Value(int value)
Constructor.
Value(std::string_view name, int value)
Constructor.
Value(std::string_view name, double value)
Constructor.
Value(const StormByte::String::String &name, const StormByte::String::String &value)
Constructor.
Value(Value &&value) noexcept
Move constructor.
Value(std::string_view value)
Constructor.
Value(std::string_view name, const StormByte::BinaryData &value)
Constructor.
Value(const Value &value)
Copy constructor.
Value(const StormByte::String::String &name, bool value)
Constructor.
Value(const StormByte::String::String &name, const StormByte::BinaryData &value)
Constructor.
Value(const StormByte::String::String &name, double value)
Constructor.
Value(std::string_view name, bool value)
Constructor.
Value(StormByte::BinaryData &&value)
Constructor.
Value(StormByte::String::String &&value)
Constructor.
Value(const StormByte::BinaryData &value)
Constructor.
~Value() noexcept override
Destructor.
Value(const StormByte::String::String &name, const char *value)
Constructor.
Value(const StormByte::String::String &name, int value)
Constructor.
Value(std::string_view name, std::string_view value)
Constructor.
Value(const char *value)
Constructor.
Value & operator=(Value &&value) noexcept
Move assignment operator.
Value & operator=(const Value &value)
Assignment operator.
Value(bool value)
Constructor.
Value(double value)
Constructor.
Value(std::string_view name, const char *value)
Constructor.
All the classes for item configuration.
Configuration items (values, comments, groups, lists).
Definition hook.hxx:50
#define STORMBYTE_CONFIG_PUBLIC
Definition visibility.h:53