Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
DimSupportXML.h
1// trax track library
2// AD 2019
3//
4// "the resolution of all the fruitless searches"
5//
6// Peter Gabriel
7//
8//
9// Copyright (c) 2025 Trend Redaktions- und Verlagsgesellschaft mbH
10// Copyright (c) 2019 Marc-Michael Horstmann
11//
12// Permission is hereby granted to any person obtaining a copy of this software
13// and associated source code (the "Software"), to use, view, and study the
14// Software for personal or internal business purposes, subject to the following
15// conditions:
16//
17// 1. Redistribution, modification, sublicensing, or commercial use of the
18// Software is NOT permitted without prior written consent from the copyright
19// holder.
20//
21// 2. The Software is provided "AS IS", without warranty of any kind, express
22// or implied.
23//
24// 3. All copies of the Software must retain this license notice.
25//
26// For further information, please contact: horstmann.marc@trendverlag.de
27
28#pragma once
29
35
36#include <boost/property_tree/ptree.hpp>
37
38#include "dim/support/DimSupportStream.h"
39
40namespace dim{
41namespace ptreesupport{
42
52 template<int L,int M,int T>
53 Value<Dimension<L,M,T>> get(
54 const boost::property_tree::ptree& pt,
55 boost::property_tree::ptree::path_type path,
56 Value<Dimension<L,M,T>> defaultValue = Value<Dimension<L,M,T>>{0},
57 Value<Dimension<L,M,T>> (*defaultUnits)( Real ) = DefaultUnit<L,M,T>::GetDefaultStreamInDimension() )
58 {
59 common::Resetter<typename DefaultUnit<L,M,T>::StreamInDimension> resetter{ DefaultUnit<L,M,T>::GetDefaultStreamInDimension(), defaultUnits };
60 if( auto result = pt.get_optional<Value<Dimension<L,M,T>>>( path ) )
61 return *result;
62 return defaultValue;
63 }
64
65 template<int L,int M,int T>
66 boost::optional<Value<Dimension<L,M,T>>> get_optional(
67 const boost::property_tree::ptree& pt,
68 boost::property_tree::ptree::path_type path,
69 Value<Dimension<L,M,T>> (*defaultUnits)( Real ) )
70 {
71 common::Resetter<typename DefaultUnit<L,M,T>::StreamInDimension> resetter{ DefaultUnit<L,M,T>::GetDefaultStreamInDimension(), defaultUnits };
72 return pt.get_optional<Value<Dimension<L,M,T>>>( path );
73 }
74
75} // namespace ptreesupport
76} // namespace dim
The namespace provides classes and methods for the dim library.
Definition DimensionedValues.h:178
float Real
Underlying floating point type to be used with the dim library.
Definition DimensionedValues.h:190