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. The bundled StormByte Base tree
22 * under thirdparty/ remains under its own license.
23 *
24 * Neither license grants any patent rights. Any patent licenses required
25 * to use this software or third-party components must be obtained separately
26 * from the patent holders.
27 *
28 * StormByte-Config is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU Lesser General Public License for more details.
32 *
33 * You should have received a copy of the GNU Lesser General Public License
34 * version 3 along with StormByte-Config. If not, see
35 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
36 *
37 * SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-StormByte-Commercial
38 */
39
40#pragma once
41
46
47#include <string_view>
48
59 public:
64 explicit Value(int value);
65
70 explicit Value(double value);
71
76 explicit Value(bool value);
77
82 explicit Value(const StormByte::Safe::String& value);
83
88 explicit Value(StormByte::Safe::String&& value);
89
94 explicit Value(const char* value);
95
100 explicit Value(std::string_view value);
101
106 explicit Value(const StormByte::BinaryData& value);
107
112 explicit Value(StormByte::BinaryData&& value);
113
119 Value(const StormByte::Safe::String& name, int value);
120
126 Value(const StormByte::Safe::String& name, double value);
127
133 Value(const StormByte::Safe::String& name, bool value);
134
141
147 Value(const StormByte::Safe::String& name, const char* value);
148
155
161 Value(std::string_view name, int value);
162
168 Value(std::string_view name, double value);
169
175 Value(std::string_view name, bool value);
176
182 Value(std::string_view name, std::string_view value);
183
189 Value(std::string_view name, const char* value);
190
196 Value(std::string_view name, const StormByte::BinaryData& value);
197
202 Value(const Value& value);
203
208 Value(Value&& value) noexcept;
209
215 Value& operator=(const Value& value);
216
222 Value& operator=(Value&& value) noexcept;
223
227 ~Value() noexcept override;
228
233 Item::Type Kind() const noexcept;
234
239 Item::Type Type() const noexcept override;
240
246 Value& operator=(int value);
247
253 Value& operator=(double value);
254
260 Value& operator=(bool value);
261
267 Value& operator=(const StormByte::Safe::String& value);
268
274 Value& operator=(const char* value);
275
281 Value& operator=(const StormByte::BinaryData& value);
282
286 operator int&();
287
291 operator const int&() const;
292
296 operator double() const;
297
301 operator double&();
302
306 operator bool&();
307
311 operator const bool&() const;
312
316 operator StormByte::Safe::String&();
317
321 operator const StormByte::Safe::String&() const;
322
326 operator StormByte::BinaryData&();
327
331 operator const StormByte::BinaryData&() const;
332
337 PointerType Clone() const override;
338
343 PointerType Move() override;
344
350 StormByte::Safe::String Serialize(const int& indent_level) const override;
351
352 protected:
358 bool Equals(const Base& base) const override;
359
360 private:
361 Item::Type m_kind;
362 union Storage {
363 int integer;
364 double floating;
365 bool boolean;
368 Storage() noexcept {}
369 ~Storage() noexcept {}
370 } m_store;
371
372 void Destroy() noexcept;
373 void CopyFrom(const Value& value);
374 void MoveFrom(Value&& value) noexcept;
375
380 [[noreturn]] void Fail(const char* wanted) const;
381 };
382}
383
384#include <StormByte/config/item/base.txx>
Base class for all configuration items.
Definition base.hxx:65
Scalar configuration item.
Definition value.hxx:58
Value(const StormByte::Safe::String &name, double value)
Constructor.
Value(int value)
Constructor.
Value(std::string_view name, int value)
Constructor.
Value(std::string_view name, double value)
Constructor.
Value(Value &&value) noexcept
Move constructor.
Value(const StormByte::Safe::String &name, const StormByte::BinaryData &value)
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::Safe::String &name, const char *value)
Constructor.
Value(const StormByte::Safe::String &name, int value)
Constructor.
Value(std::string_view name, bool value)
Constructor.
Value(StormByte::BinaryData &&value)
Constructor.
Value(const StormByte::Safe::String &name, const StormByte::Safe::String &value)
Constructor.
Value(const StormByte::BinaryData &value)
Constructor.
~Value() noexcept override
Destructor.
Value(std::string_view name, std::string_view value)
Constructor.
Value(const char *value)
Constructor.
Value & operator=(Value &&value) noexcept
Move assignment operator.
Value(const StormByte::Safe::String &name, bool value)
Constructor.
Value & operator=(const Value &value)
Assignment operator.
Value(const StormByte::Safe::String &value)
Constructor.
Value(StormByte::Safe::String &&value)
Constructor.
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:49
#define STORMBYTE_CONFIG_PUBLIC
Definition visibility.h:52