The Gaudi Framework master (9cc87df9)
Loading...
Searching...
No Matches
PropertyValue.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2026 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11#pragma once
12
13#include "Position.h"
14#include <map>
15#include <stdexcept>
16#include <string>
17#include <variant>
18#include <vector>
19
20namespace Gaudi {
21 namespace Parsers {
22 class PropertyValue final {
23 public:
26 using Value = std::variant<std::string, VectorOfStrings, MapOfStrings>;
27
28 // ----------------------------------------------------------------------------
29 explicit PropertyValue( Value value, bool is_reference = false )
30 : value_( std::move( value ) ), is_reference_( is_reference ) {}
31 PropertyValue( Value value, const Position& position, bool is_reference = false )
32 : value_( std::move( value ) ), position_( position ), is_reference_( is_reference ) {}
33 // ----------------------------------------------------------------------------
34 const Position& position() const { return position_; }
35 // ----------------------------------------------------------------------------
36 std::string& String() { return std::get<std::string>( value_ ); }
37 const std::string& String() const { return std::get<std::string>( value_ ); }
38
41
43 const MapOfStrings& Map() const { return std::get<MapOfStrings>( value_ ); }
44
45 std::string ToString() const;
46 bool HasPosition() const { return position_.Exists(); }
47 bool IsSimple() const;
48 bool IsVector() const;
49 bool IsMap() const;
50 bool IsReference() const { return is_reference_; }
51
56
57 private:
61 };
62
64 public:
65 PropertyValueException( const std::string& message ) : std::runtime_error( message ) {}
67 return PropertyValueException( "Cannot apply +=/-= operation to left value." );
68 }
69
71 return PropertyValueException( "Cannot apply +=/-= operation to right value." );
72 }
73 };
74
76 public:
77 PositionalPropertyValueException( const Position& position, const std::string& message )
78 : std::runtime_error( message ), position_( position ) {}
79 const Position& position() const { return position_; }
80
81 static PositionalPropertyValueException CouldNotFind( const Position& position, const std::string& name ) {
82 return PositionalPropertyValueException( position, "Could not find property " + name + "." );
83 }
84
86 const std::string& name ) {
87 return PositionalPropertyValueException( position, "Could not find property '" + name + "'." );
88 }
89
90 static PositionalPropertyValueException CouldNotFindUnit( const Position& position, const std::string& name ) {
91 return PositionalPropertyValueException( position, "Could not find unit '" + name + "'." );
92 }
93
95
96 private:
98 };
99 } // namespace Parsers
100} // namespace Gaudi
constexpr common_type< duration< _Rep1, _Period1 >, duration< _Rep2, _Period2 > >::type operator-(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr complex< _Tp > & operator-=(const complex< _Up > &)
constexpr complex< _Tp > & operator+=(const complex< _Up > &)
constexpr const __tuple_element_t< __i, tuple< _Elements... > > && get(const tuple< _Elements... > &&__t) noexcept
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
ios_base & right(ios_base &__base)
runtime_error(const string &__arg) _GLIBCXX_TXN_SAFE
bool Exists() const
Definition Position.h:27
static PositionalPropertyValueException CouldNotFindUnit(const Position &position, const std::string &name)
PositionalPropertyValueException(const Position &position, const std::string &message)
static PositionalPropertyValueException CouldNotFind(const Position &position, const std::string &name)
static PositionalPropertyValueException CouldNotFindProperty(const Position &position, const std::string &name)
static PropertyValueException WrongRValue()
static PropertyValueException WrongLValue()
PropertyValueException(const std::string &message)
const std::string & String() const
const VectorOfStrings & Vector() const
const MapOfStrings & Map() const
PropertyValue(Value value, const Position &position, bool is_reference=false)
std::vector< std::string > VectorOfStrings
VectorOfStrings & Vector()
std::map< std::string, std::string, std::less<> > MapOfStrings
std::variant< std::string, VectorOfStrings, MapOfStrings > Value
PropertyValue(Value value, bool is_reference=false)
const Position & position() const
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1
decltype(auto) operator+(const T &v, const Property< TP, V, H > &p)
implemantation of (value + property)
Definition Property.h:484
STL namespace.