SDDS ToolKit Programs and Libraries for C and Python
Loading...
Searching...
No Matches
SDDSLayout.cc File Reference

Detailed Description

Core type, error-context, and immutable layout lookup operations.

Defines type identification, protocol type names, contextual exceptions, and name-to-index lookup for immutable layouts.

License
This file is distributed under the terms of the Software License Agreement found in the file LICENSE included with this distribution.

Definition in file SDDSLayout.cc.

#include "SDDS.hpp"
#include <array>

Go to the source code of this file.

Functions

Type sdds::typeOf (const Scalar &value) noexcept
 
Type sdds::typeOf (const Values &values) noexcept
 
std::string_view sdds::typeName (Type type) noexcept
 

Function Documentation

◆ typeName()

std::string_view sdds::typeName ( Type type)
noexcept

Definition at line 39 of file SDDSLayout.cc.

39 {
40 constexpr std::array<std::string_view, 11> names = {
41 "longdouble", "double", "float", "long64", "ulong64", "long", "ulong",
42 "short", "ushort", "string", "character"};
43 const auto index = static_cast<std::int32_t>(type) - 1;
44 return index >= 0 && index < static_cast<std::int32_t>(names.size()) ? names[index] : "unknown";
45}

◆ typeOf() [1/2]

Type sdds::typeOf ( const Scalar & value)
noexcept

Definition at line 31 of file SDDSLayout.cc.

31 {
32 return static_cast<Type>(value.index() + 1);
33}

◆ typeOf() [2/2]

Type sdds::typeOf ( const Values & values)
noexcept

Definition at line 35 of file SDDSLayout.cc.

35 {
36 return static_cast<Type>(values.index() + 1);
37}