MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
cpptoml Namespace Reference

Namespaces

namespace  ARRAY_
 
namespace  detail
 
namespace  TABLE_ARRAY_
 

Classes

class  array
 
class  array_exception
 
struct  array_of_trait
 
struct  array_of_trait< array >
 
class  base
 
struct  base_type_traits
 Type traits class to convert C++ types to enum member. More...
 
struct  base_type_traits< array >
 
struct  base_type_traits< double >
 
struct  base_type_traits< int >
 
struct  base_type_traits< int64_t >
 
struct  base_type_traits< local_date >
 
struct  base_type_traits< local_datetime >
 
struct  base_type_traits< local_time >
 
struct  base_type_traits< MBool >
 
struct  base_type_traits< offset_datetime >
 
struct  base_type_traits< std::string >
 
struct  base_type_traits< table >
 
struct  base_type_traits< table_array >
 
class  consumer
 
class  fill_guard
 
struct  is_one_of
 
struct  is_one_of< T, V >
 
struct  is_one_of< T, V, Ts... >
 
struct  local_date
 
struct  local_datetime
 
struct  local_time
 
class  make_shared_enabler
 
struct  offset_datetime
 
class  option
 
class  parse_exception
 
class  parser
 
class  table
 
class  table_array
 
class  toml_writer
 
struct  valid_value
 
struct  valid_value_or_string_convertible
 
class  value
 
struct  value_accept
 
struct  value_accept< T, Ts... >
 
struct  value_accept<>
 
struct  value_traits
 
struct  value_traits< T, typename std::enable_if< valid_value_or_string_convertible< T >::value >::type >
 
struct  value_traits< T, typename std::enable_if<!valid_value_or_string_convertible< T >::value &&std::is_floating_point< typename std::decay< T >::type >::value >::type >
 
struct  value_traits< T, typename std::enable_if<!valid_value_or_string_convertible< T >::value &&std::is_signed< typename std::decay< T >::type >::value >::type >
 
struct  value_traits< T, typename std::enable_if<!valid_value_or_string_convertible< T >::value &&std::is_unsigned< typename std::decay< T >::type >::value >::type >
 
struct  zone_offset
 

Typedefs

using string_to_base_map = std::map< std::string, std::shared_ptr< base > >
 

Enumerations

enum class  base_type {
  NONE , STRING , LOCAL_TIME , LOCAL_DATE ,
  LOCAL_DATETIME , OFFSET_DATETIME , INT , FLOAT ,
  BOOL , TABLE , ARRAY , TABLE_ARRAY
}
 Base type used to store underlying data type explicitly if RTTI is disabled. More...
 

Functions

void die (const std::string &reason, const std::string &file, const int line)
 
void die (const std::string &reason, const int input_line, const std::string &file, const int line)
 
 CPPTOML_DEPRECATED ("datetime has been renamed to offset_datetime") typedef offset_datetime datetime
 
std::ostream & operator<< (std::ostream &os, const local_date &dt)
 
std::ostream & operator<< (std::ostream &os, const local_time &ltime)
 
std::ostream & operator<< (std::ostream &os, const zone_offset &zo)
 
std::ostream & operator<< (std::ostream &os, const local_datetime &dt)
 
std::ostream & operator<< (std::ostream &os, const offset_datetime &dt)
 
template<class T >
std::shared_ptr< typename value_traits< T >::type > make_value (T &&val)
 
std::shared_ptr< arraymake_array ()
 
template<class T >
std::shared_ptr< T > make_element ()
 
std::shared_ptr< tablemake_table ()
 
std::shared_ptr< table_arraymake_table_array ()
 
template<>
std::shared_ptr< arraymake_element< array > ()
 
template<>
std::shared_ptr< table_arraymake_element< table_array > ()
 
template<class T >
std::enable_if<!std::is_floating_point< T >::value &&std::is_signed< T >::value, option< T > >::type get_impl (const std::shared_ptr< base > &elem)
 
template<class T >
std::enable_if<!std::is_same< T, MBool >::value &&std::is_unsigned< T >::value, option< T > >::type get_impl (const std::shared_ptr< base > &elem)
 
template<class T >
std::enable_if<!std::is_integral< T >::value||std::is_same< T, MBool >::value, option< T > >::type get_impl (const std::shared_ptr< base > &elem)
 
template<>
std::shared_ptr< tablemake_element< table > ()
 
MBool is_number (char c)
 
template<class OnError >
consumer< OnError > make_consumer (std::string::iterator &it, const std::string::iterator &end, OnError &&on_error)
 
std::shared_ptr< tableparse_file (const std::string &filename)
 
std::ostream & operator<< (std::ostream &stream, const base &b)
 
template<class T >
std::ostream & operator<< (std::ostream &stream, const value< T > &v)
 
std::ostream & operator<< (std::ostream &stream, const table &t)
 
std::ostream & operator<< (std::ostream &stream, const table_array &t)
 
std::ostream & operator<< (std::ostream &stream, const array &a)
 

Typedef Documentation

◆ string_to_base_map

typedef std::unordered_map< std::string, std::shared_ptr< base > > cpptoml::string_to_base_map

Definition at line 72 of file cpptoml.h.

Enumeration Type Documentation

◆ base_type

enum class cpptoml::base_type
strong
Enumerator
NONE 
STRING 
LOCAL_TIME 
LOCAL_DATE 
LOCAL_DATETIME 
OFFSET_DATETIME 
INT 
FLOAT 
BOOL 
TABLE 
ARRAY 
TABLE_ARRAY 

Definition at line 368 of file cpptoml.h.

Function Documentation

◆ CPPTOML_DEPRECATED()

cpptoml::CPPTOML_DEPRECATED ( "datetime has been renamed to offset_datetime"  )

◆ die() [1/2]

void cpptoml::die ( const std::string &  reason,
const int  input_line,
const std::string &  file,
const int  line 
)
inline

Definition at line 94 of file cpptoml.h.

94 {
95 std::cerr << file << ":" << std::to_string(line) << ": error: " << reason << " at line " << input_line << std::endl;
96 TERM(-1);
97}

◆ die() [2/2]

void cpptoml::die ( const std::string &  reason,
const std::string &  file,
const int  line 
)
inline

Definition at line 89 of file cpptoml.h.

89 {
90 std::cerr << file << ":" << std::to_string(line) << ": error: " << reason << std::endl;
91 TERM(-1);
92}

◆ get_impl() [1/3]

template<class T >
std::enable_if<!std::is_floating_point< T >::value &&std::is_signed< T >::value, option< T > >::type cpptoml::get_impl ( const std::shared_ptr< base > &  elem)

Definition at line 1021 of file cpptoml.h.

1021 {
1022 if(auto v = elem->as<int64_t>()) {
1023 if(v->get() < std::numeric_limits<T>::min())
1024 THROW_(std::underflow_error, "T cannot represent the value requested in get");
1025
1026 if(v->get() > std::numeric_limits<T>::max())
1027 THROW_(std::overflow_error, "T cannot represent the value requested in get");
1028
1029 return {static_cast<T>(v->get())};
1030 } else {
1031 return {};
1032 }
1033}

◆ get_impl() [2/3]

template<class T >
std::enable_if<!std::is_same< T, MBool >::value &&std::is_unsigned< T >::value, option< T > >::type cpptoml::get_impl ( const std::shared_ptr< base > &  elem)

Definition at line 1037 of file cpptoml.h.

1037 {
1038 if(auto v = elem->as<int64_t>()) {
1039 if(v->get() < 0) THROW_(std::underflow_error, "T cannot store negative value in get");
1040
1041 if(static_cast<uint64_t>(v->get()) > std::numeric_limits<T>::max())
1042 THROW_(std::overflow_error, "T cannot represent the value requested in get");
1043
1044 return {static_cast<T>(v->get())};
1045 } else {
1046 return {};
1047 }
1048}

◆ get_impl() [3/3]

template<class T >
std::enable_if<!std::is_integral< T >::value||std::is_same< T, MBool >::value, option< T > >::type cpptoml::get_impl ( const std::shared_ptr< base > &  elem)

Definition at line 1052 of file cpptoml.h.

1052 {
1053 if(auto v = elem->as<T>()) {
1054 return {v->get()};
1055 } else {
1056 return {};
1057 }
1058}

◆ is_number()

MBool cpptoml::is_number ( char  c)
inline

Definition at line 1471 of file cpptoml.h.

1471{ return c >= '0' && c <= '9'; }

◆ make_array()

std::shared_ptr< array > cpptoml::make_array ( )
inline

Definition at line 873 of file cpptoml.h.

873 {
874#if not defined(MAIA_INTEL_COMPILER)
875 struct make_shared_enabler : public array {
876 make_shared_enabler() = default;
877 };
878
879 return std::make_shared<make_shared_enabler>();
880#else
881 return std::make_shared<ARRAY_::make_shared_enabler>();
882#endif
883}

◆ make_consumer()

template<class OnError >
consumer< OnError > cpptoml::make_consumer ( std::string::iterator &  it,
const std::string::iterator &  end,
OnError &&  on_error 
)

Definition at line 1512 of file cpptoml.h.

1512 {
1513 return consumer<OnError>(it, end, std::forward<OnError>(on_error));
1514}

◆ make_element()

template<class T >
std::shared_ptr< T > cpptoml::make_element ( )
inline

◆ make_element< array >()

template<>
std::shared_ptr< array > cpptoml::make_element< array > ( )
inline

Definition at line 873 of file cpptoml.h.

886 {
887 return make_array();
888}
constexpr std::array< T, n > make_array(const T v)

◆ make_element< table >()

template<>
std::shared_ptr< table > cpptoml::make_element< table > ( )
inline

Definition at line 1417 of file cpptoml.h.

1428 {
1429 return make_table();
1430}
std::shared_ptr< table > make_table()
Definition: cpptoml.h:1417

◆ make_element< table_array >()

template<>
std::shared_ptr< table_array > cpptoml::make_element< table_array > ( )
inline

Definition at line 999 of file cpptoml.h.

1012 {
1013 return make_table_array();
1014}
std::shared_ptr< table_array > make_table_array()
Definition: cpptoml.h:999

◆ make_table()

std::shared_ptr< table > cpptoml::make_table ( )
inline

Definition at line 1417 of file cpptoml.h.

1417 {
1418#if not defined(MAIA_INTEL_COMPILER)
1419 struct make_shared_enabler : public table {
1420 make_shared_enabler() = default;
1421 };
1422#endif
1423
1424 return std::make_shared<make_shared_enabler>();
1425}

◆ make_table_array()

std::shared_ptr< table_array > cpptoml::make_table_array ( )
inline

Definition at line 999 of file cpptoml.h.

999 {
1000#if not defined(MAIA_INTEL_COMPILER)
1001 struct make_shared_enabler : public table_array {
1002 make_shared_enabler() = default;
1003 };
1004
1005 return std::make_shared<make_shared_enabler>();
1006#else
1007 return std::make_shared<TABLE_ARRAY_::make_shared_enabler>();
1008#endif
1009}

◆ make_value()

template<class T >
std::shared_ptr< typename value_traits< T >::type > cpptoml::make_value ( T &&  val)
inline

Definition at line 588 of file cpptoml.h.

588 {
589 using value_type = typename value_traits<T>::type;
590 using enabler = typename value_type::make_shared_enabler;
591 return std::make_shared<value_type>(enabler{}, value_traits<T>::construct(std::forward<T>(val)));
592}

◆ operator<<() [1/10]

std::ostream & cpptoml::operator<< ( std::ostream &  os,
const local_date dt 
)
inline

Definition at line 202 of file cpptoml.h.

202 {
203 fill_guard g{os};
204 os.fill('0');
205
206 using std::setw;
207 os << setw(4) << dt.year << "-" << setw(2) << dt.month << "-" << setw(2) << dt.day;
208
209 return os;
210}

◆ operator<<() [2/10]

std::ostream & cpptoml::operator<< ( std::ostream &  os,
const local_datetime dt 
)
inline

Definition at line 252 of file cpptoml.h.

252 {
253 return os << static_cast<const local_date&>(dt) << "T" << static_cast<const local_time&>(dt);
254}

◆ operator<<() [3/10]

std::ostream & cpptoml::operator<< ( std::ostream &  os,
const local_time ltime 
)
inline

Definition at line 212 of file cpptoml.h.

212 {
213 fill_guard g{os};
214 os.fill('0');
215
216 using std::setw;
217 os << setw(2) << ltime.hour << ":" << setw(2) << ltime.minute << ":" << setw(2) << ltime.second;
218
219 if(ltime.microsecond > 0) {
220 os << ".";
221 int power = 100000;
222 for(int curr_us = ltime.microsecond; curr_us; power /= 10) {
223 auto num = curr_us / power;
224 os << num;
225 curr_us -= num * power;
226 }
227 }
228
229 return os;
230}

◆ operator<<() [4/10]

std::ostream & cpptoml::operator<< ( std::ostream &  os,
const offset_datetime dt 
)
inline

Definition at line 256 of file cpptoml.h.

256 {
257 return os << static_cast<const local_datetime&>(dt) << static_cast<const zone_offset&>(dt);
258}

◆ operator<<() [5/10]

std::ostream & cpptoml::operator<< ( std::ostream &  os,
const zone_offset zo 
)
inline

Definition at line 232 of file cpptoml.h.

232 {
233 fill_guard g{os};
234 os.fill('0');
235
236 using std::setw;
237
238 if(zo.hour_offset != 0 || zo.minute_offset != 0) {
239 if(zo.hour_offset > 0) {
240 os << "+";
241 } else {
242 os << "-";
243 }
244 os << setw(2) << std::abs(zo.hour_offset) << ":" << setw(2) << std::abs(zo.minute_offset);
245 } else {
246 os << "Z";
247 }
248
249 return os;
250}

◆ operator<<() [6/10]

std::ostream & cpptoml::operator<< ( std::ostream &  stream,
const array a 
)
inline

Definition at line 2850 of file cpptoml.h.

2850 {
2851 toml_writer writer{stream};
2852 a.accept(writer);
2853 return stream;
2854}
Definition: contexttypes.h:19

◆ operator<<() [7/10]

std::ostream & cpptoml::operator<< ( std::ostream &  stream,
const base b 
)
inline

Definition at line 2825 of file cpptoml.h.

2825 {
2826 toml_writer writer{stream};
2827 b.accept(writer);
2828 return stream;
2829}

◆ operator<<() [8/10]

std::ostream & cpptoml::operator<< ( std::ostream &  stream,
const table t 
)
inline

Definition at line 2838 of file cpptoml.h.

2838 {
2839 toml_writer writer{stream};
2840 t.accept(writer);
2841 return stream;
2842}
void accept(Visitor &&visitor, Args &&... args) const
Definition: cpptoml.h:2543

◆ operator<<() [9/10]

std::ostream & cpptoml::operator<< ( std::ostream &  stream,
const table_array t 
)
inline

Definition at line 2844 of file cpptoml.h.

2844 {
2845 toml_writer writer{stream};
2846 t.accept(writer);
2847 return stream;
2848}

◆ operator<<() [10/10]

template<class T >
std::ostream & cpptoml::operator<< ( std::ostream &  stream,
const value< T > &  v 
)

Definition at line 2832 of file cpptoml.h.

2832 {
2833 toml_writer writer{stream};
2834 v.accept(writer);
2835 return stream;
2836}

◆ parse_file()

std::shared_ptr< table > cpptoml::parse_file ( const std::string &  filename)
inline

Utility function to parse a file as a TOML file. Returns the root table. Throws a parse_exception if the file cannot be opened.

Definition at line 2502 of file cpptoml.h.

2502 {
2503#if defined(BOOST_NOWIDE_FSTREAM_INCLUDED_HPP)
2504 boost::nowide::ifstream file{filename.c_str()};
2505#elif defined(NOWIDE_FSTREAM_INCLUDED_HPP)
2506 nowide::ifstream file{filename.c_str()};
2507#else
2508 std::ifstream file{filename};
2509#endif
2510 if(!file.is_open()) THROW_(parse_exception, filename + " could not be opened for parsing");
2511 parser p{file};
2512 return p.parse();
2513}
constexpr std::underlying_type< FcCell >::type p(const FcCell property)
Converts property name to underlying integer value.