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
28#include <cbeam/memory/pointer.hpp> // for cbeam::memory::pointer, cbeam::memory::operator<<
29
30#include <cstddef> // for std::size_t
31
32#include <iosfwd> // for std::ostream
33#include <string> // for std::string
34#include <variant> // for std::visit, std::variant
35
37{
46 using type = std::variant<long long, double, bool, memory::pointer, std::string>;
47
48 namespace type_index
49 {
50 constexpr std::size_t integer{0}; // type index for long long
51 constexpr std::size_t number{1}; // type index for double
52 constexpr std::size_t boolean{2}; // type index for bool
53 constexpr std::size_t pointer{3}; // type index for memory::pointer
54 constexpr std::size_t string{4}; // type index for std::string
55 };
56
66 inline std::ostream& operator<<(std::ostream& os, const xpod::type& v)
67 {
68 std::visit([&os](auto&& arg)
69 { os << arg; },
70 v);
71 return os;
72 }
73} // namespace cbeam::container::xpod
Defines index constants for the xpod::type variant (e.g., integer, number, boolean,...
Definition xpod.hpp:49
constexpr std::size_t number
Definition xpod.hpp:51
constexpr std::size_t pointer
Definition xpod.hpp:53
constexpr std::size_t integer
Definition xpod.hpp:50
Provides a specialized variant type (xpod::type) for simple data exchange, supporting integer,...
Definition xpod.hpp:37
std::ostream & operator<<(std::ostream &os, const xpod::type &v)
Overload of the insertion operator to output the contents of an xpod::type.
Definition xpod.hpp:66
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