MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
cpptoml::consumer< OnError > Class Template Reference

#include <cpptoml.h>

Collaboration diagram for cpptoml::consumer< OnError >:
[legend]

Public Member Functions

 consumer (std::string::iterator &it, const std::string::iterator &end, OnError &&on_error)
 
void operator() (char c)
 
template<std::size_t N>
void operator() (const char(&str)[N])
 
int eat_digits (int len)
 
void error ()
 

Private Attributes

std::string::iterator & it_
 
const std::string::iterator & end_
 
OnError on_error_
 

Detailed Description

template<class OnError>
class cpptoml::consumer< OnError >

Helper object for consuming expected characters.

Definition at line 1477 of file cpptoml.h.

Constructor & Destructor Documentation

◆ consumer()

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

Definition at line 1479 of file cpptoml.h.

1480 : it_(it), end_(end), on_error_(std::forward<OnError>(on_error)) {
1481 // nothing
1482 }
std::string::iterator & it_
Definition: cpptoml.h:1506
OnError on_error_
Definition: cpptoml.h:1508
const std::string::iterator & end_
Definition: cpptoml.h:1507

Member Function Documentation

◆ eat_digits()

template<class OnError >
int cpptoml::consumer< OnError >::eat_digits ( int  len)
inline

Definition at line 1494 of file cpptoml.h.

1494 {
1495 int val = 0;
1496 for(int i = 0; i < len; ++i) {
1497 if(!is_number(*it_) || it_ == end_) on_error_();
1498 val = 10 * val + (*it_++ - '0');
1499 }
1500 return val;
1501 }
MBool is_number(char c)
Definition: cpptoml.h:1471

◆ error()

template<class OnError >
void cpptoml::consumer< OnError >::error ( )
inline

Definition at line 1503 of file cpptoml.h.

1503{ on_error_(); }

◆ operator()() [1/2]

template<class OnError >
void cpptoml::consumer< OnError >::operator() ( char  c)
inline

Definition at line 1484 of file cpptoml.h.

1484 {
1485 if(it_ == end_ || *it_ != c) on_error_();
1486 ++it_;
1487 }

◆ operator()() [2/2]

template<class OnError >
template<std::size_t N>
void cpptoml::consumer< OnError >::operator() ( const char(&)  str[N])
inline

Definition at line 1490 of file cpptoml.h.

1490 {
1491 std::for_each(std::begin(str), std::end(str) - 1, [&](char c) { (*this)(c); });
1492 }

Member Data Documentation

◆ end_

template<class OnError >
const std::string::iterator& cpptoml::consumer< OnError >::end_
private

Definition at line 1507 of file cpptoml.h.

◆ it_

template<class OnError >
std::string::iterator& cpptoml::consumer< OnError >::it_
private

Definition at line 1506 of file cpptoml.h.

◆ on_error_

template<class OnError >
OnError cpptoml::consumer< OnError >::on_error_
private

Definition at line 1508 of file cpptoml.h.


The documentation for this class was generated from the following file: