vrmlproc & togeom
 
Loading...
Searching...
No Matches
ExtractorVisitor< T > Struct Template Reference

Visitor for VRML field value extraction. More...

#include <VrmlFieldExtractor.hpp>

Inheritance diagram for ExtractorVisitor< T >:

Public Member Functions

cpp::result< std::reference_wrapper< const T >, std::optional< std::string > > operator() (const std::string &value) const
 
cpp::result< std::reference_wrapper< const T >, std::optional< std::string > > operator() (const bool &value) const
 
cpp::result< std::reference_wrapper< const T >, std::optional< std::string > > operator() (const vrml_proc::parser::model::Vec3fArray &value) const
 
cpp::result< std::reference_wrapper< const T >, std::optional< std::string > > operator() (const vrml_proc::parser::model::Vec2fArray &value) const
 
cpp::result< std::reference_wrapper< const T >, std::optional< std::string > > operator() (const vrml_proc::parser::model::Int32Array &value) const
 
cpp::result< std::reference_wrapper< const T >, std::optional< std::string > > operator() (const float &value) const
 
cpp::result< std::reference_wrapper< const T >, std::optional< std::string > > operator() (const int32_t &value) const
 
cpp::result< std::reference_wrapper< const T >, std::optional< std::string > > operator() (const vrml_proc::parser::model::Vec2f &value) const
 
cpp::result< std::reference_wrapper< const T >, std::optional< std::string > > operator() (const vrml_proc::parser::model::Vec3f &value) const
 
cpp::result< std::reference_wrapper< const T >, std::optional< std::string > > operator() (const vrml_proc::parser::model::Vec4f &value) const
 
cpp::result< std::reference_wrapper< const T >, std::optional< std::string > > operator() (const vrml_proc::parser::model::UseNode &value) const
 
cpp::result< std::reference_wrapper< const T >, std::optional< std::string > > operator() (const boost::recursive_wrapper< vrml_proc::parser::model::UseNode > &node) const
 
cpp::result< std::reference_wrapper< const T >, std::optional< std::string > > operator() (const boost::recursive_wrapper< vrml_proc::parser::model::VrmlNode > &node) const
 
cpp::result< std::reference_wrapper< const T >, std::optional< std::string > > operator() (const vrml_proc::parser::model::VrmlNode &node) const
 
cpp::result< std::reference_wrapper< const T >, std::optional< std::string > > operator() (const std::vector< boost::variant< boost::recursive_wrapper< vrml_proc::parser::model::VrmlNode >, boost::recursive_wrapper< vrml_proc::parser::model::UseNode > > > &value) const
 
template<typename U>
cpp::result< std::reference_wrapper< const T >, std::optional< std::string > > operator() (const U &) const
 

Detailed Description

template<typename T>
struct ExtractorVisitor< T >

Visitor for VRML field value extraction.

Returns
result type where value is const reference to queried data entry; if there is error, string describing unexpected error type is returned (or possibly other error message)
Note
The visitor is thread-safe. It uses only read-only data. There are two exceptions to this. 1. case is for Vec3fArray, where it is needed to examine, if the value is not empty array. If it is an empty array, we check if current requestd type T cannot be reinterpreted as empty array. Possibly we create empty static array in such cases only initialized once (guaranteed by C++11+ thread-safe static initialization). The reason for this is that parser, parsing an emprt array, will always resovle it as Vec3fArray simply because it is the first rule.
  1. case is about float/int situation. The grammar handles all (singular!) number without decimal points as ints. The following table shows the problematic behavirour ('X' signs where the special treatment has to be made to be able to e.g. take value '0' as both int and float):

number 0 (as int) number 0 (as float) X number 5.0 (as int) X number 5.0 (as float) number 5.5 (as float)

The logic is that we convert int to float and then store this value inside cache (see ExtractorCache class) or we try to convert float to int (must be in format xyz.0) and also store it. If we encounter the query for the problematic value, we look it up inside the map to retrieve the same valid reference. ExtractorCache is thread-safe.

auto result = boost::apply_visitor(visitor, fieldValue);
Visitor for VRML field value extraction.
Definition VrmlFieldExtractor.hpp:396

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