Cbeam
Loading...
Searching...
No Matches
xpod.hpp
Go to the documentation of this file.
1/*
2Copyright (c) 2025 acrion innovations GmbH
3Authors: Stefan Zipproth, s.zipproth@acrion.ch
4
5This file is part of Cbeam, see https://github.com/acrion/cbeam and https://cbeam.org
6
7Cbeam is offered under a commercial and under the AGPL license.
8For commercial licensing, contact us at https://acrion.ch/sales. For AGPL licensing, see below.
9
10AGPL licensing:
11
12Cbeam is free software: you can redistribute it and/or modify
13it under the terms of the GNU Affero General Public License as published by
14the Free Software Foundation, either version 3 of the License, or
15(at your option) any later version.
16
17Cbeam is distributed in the hope that it will be useful,
18but WITHOUT ANY WARRANTY; without even the implied warranty of
19MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20GNU Affero General Public License for more details.
21
22You should have received a copy of the GNU Affero General Public License
23along with Cbeam. If not, see <https://www.gnu.org/licenses/>.
24*/
25
26#pragma once
27
29#include <cbeam/convert/string.hpp> // for cbeam::convert::to_string
30#include <cbeam/memory/pointer.hpp> // for cbeam::memory::pointer
31
32namespace cbeam::convert
33{
45 inline std::string to_string(const container::xpod::type& val)
46 {
47 switch (val.index())
48 {
50 return convert::to_string(std::get<container::xpod::type_index::integer>(val));
52 return convert::to_string(std::get<container::xpod::type_index::number>(val));
54 return convert::to_string(std::get<container::xpod::type_index::boolean>(val));
56 return static_cast<std::string>(std::get<container::xpod::type_index::pointer>(val));
58 return std::get<container::xpod::type_index::string>(val);
59 default:
60 return {};
61 }
62 }
63}
constexpr std::size_t number
Definition xpod.hpp:51
constexpr std::size_t boolean
Definition xpod.hpp:52
constexpr std::size_t pointer
Definition xpod.hpp:53
constexpr std::size_t string
Definition xpod.hpp:54
constexpr std::size_t integer
Definition xpod.hpp:50
std::variant< long long, double, bool, memory::pointer, std::string > type
A variant designed for basic data types. memory::pointer is used in place of void* to provide additio...
Definition xpod.hpp:46
Contains conversion utilities to transform data between different formats and types....
Definition buffer.hpp:35
std::string to_string(const container::buffer &b)
Creates a std::string from the contents of a container::buffer.
Definition buffer.hpp:42