normativeTypesCPP
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
epics::nt::Result Struct Reference

Validation methods for NT types. More...

#include <validator.h>

Classes

struct  Error
 

Public Types

enum  result_t { Pass, Fail }
 

Public Member Functions

 Result (const epics::pvData::FieldConstPtr &field, const std::string &path=std::string())
 
 Result ()
 
Resultoperator|= (const Result &other)
 
bool valid (void) const
 
template<typename T >
Resultis (void)
 
template<typename T >
Resultis (const std::string &id)
 
template<Result &(*)(Result &) fn>
Resulthas (const std::string &name)
 
template<Result &(*)(Result &) fn>
ResultmaybeHas (const std::string &name)
 
template<Result &(*)(Result &) fn, typename T >
Resulthas (const std::string &name)
 
template<Result &(*)(Result &) fn, typename T >
ResultmaybeHas (const std::string &name)
 
template<typename T >
Resulthas (const std::string &name)
 
template<typename T >
ResultmaybeHas (const std::string &name)
 
std::ostream & dump (std::ostream &os) const
 

Public Attributes

epics::pvData::FieldConstPtr field
 
std::string path
 
std::vector< Errorerrors
 
enum epics::nt::Result::result_t result
 

Detailed Description

Validation methods for NT types.

Author
bsm

Definition at line 23 of file validator.h.

Member Enumeration Documentation

◆ result_t

Enumerator
Pass 
Fail 

Definition at line 56 of file validator.h.

Constructor & Destructor Documentation

◆ Result() [1/2]

epics::nt::Result::Result ( const epics::pvData::FieldConstPtr &  field,
const std::string &  path = std::string() 
)
inline

Definition at line 61 of file validator.h.

◆ Result() [2/2]

epics::nt::Result::Result ( )
inline

Definition at line 64 of file validator.h.

Member Function Documentation

◆ dump()

std::ostream& epics::nt::Result::dump ( std::ostream &  os) const
inline

◆ has() [1/3]

template<Result &(*)(Result &) fn>
Result& epics::nt::Result::has ( const std::string &  name)
inline

Test that this Result's field has a subfield with name 'name' and apply the function 'fn' to the subfield.

Appends an Error::Type::IncorrectType if the field is not one of Structure, StructureArray, Union, UnionArray. Appends an Error::Type::MissingField if the subfield is not present.

Returns
itself

Definition at line 132 of file validator.h.

Referenced by dump(), epics::nt::NTContinuum::wrapUnsafe(), epics::nt::NTAttribute::wrapUnsafe(), epics::nt::NTNDArrayAttribute::wrapUnsafe(), epics::nt::NTHistogram::wrapUnsafe(), epics::nt::NTNameValue::wrapUnsafe(), epics::nt::NTNDArray::wrapUnsafe(), epics::nt::NTURI::wrapUnsafe(), epics::nt::NTTable::wrapUnsafe(), epics::nt::NTAggregate::wrapUnsafe(), epics::nt::NTMultiChannel::wrapUnsafe(), and epics::nt::NTScalarMultiChannel::wrapUnsafe().

◆ has() [2/3]

template<Result &(*)(Result &) fn, typename T >
Result& epics::nt::Result::has ( const std::string &  name)
inline

Test that this Result's field has a subfield with name 'name', apply the function 'fn' to the subfield and test that the subfield is of type 'T'.

Appends an Error::Type::IncorrectType if the field is not one of Structure, StructureArray, Union, UnionArray. Appends an Error::Type::IncorrectType if the subfield is not of type 'T'. Appends an Error::Type::MissingField if the subfield is not present.

Returns
itself

Definition at line 165 of file validator.h.

◆ has() [3/3]

template<typename T >
Result& epics::nt::Result::has ( const std::string &  name)
inline

Test that this Result's field has a subfield with name 'name' and test that the subfield is of type 'T'.

Appends an Error::Type::IncorrectType if the field is not one of Structure, StructureArray, Union, UnionArray. Appends an Error::Type::IncorrectType if the subfield is not of type 'T'. Appends an Error::Type::MissingField if the subfield is not present.

Returns
itself

Definition at line 200 of file validator.h.

◆ is() [1/2]

template<typename T >
Result& epics::nt::Result::is ( void  )
inline

◆ is() [2/2]

template<typename T >
Result& epics::nt::Result::is ( const std::string &  id)
inline

Test that this Result's field is of a particular type 'T' and has an ID equal to 'id'.

Appends an Error::Type::IncorrectType if the field is not of type 'T'. Appends an Error::Type::IncorrectId if the field does not have an ID equal to 'id'.

Returns
itself

Definition at line 108 of file validator.h.

References epics::nt::Result::Error::Error(), Fail, epics::nt::Result::Error::IncorrectId, and epics::nt::Result::Error::IncorrectType.

◆ maybeHas() [1/3]

template<Result &(*)(Result &) fn>
Result& epics::nt::Result::maybeHas ( const std::string &  name)
inline

◆ maybeHas() [2/3]

template<Result &(*)(Result &) fn, typename T >
Result& epics::nt::Result::maybeHas ( const std::string &  name)
inline

Test that this Result's field has an optional subfield with name 'name' and, if it has, apply the function 'fn' to the subfield and test that the subfield is of type 'T'.

Appends an Error::Type::IncorrectType if the field is not one of Structure, StructureArray, Union, UnionArray. Appends an Error::Type::IncorrectType if the subfield exists and is not of type 'T'.

Returns
itself

Definition at line 182 of file validator.h.

◆ maybeHas() [3/3]

template<typename T >
Result& epics::nt::Result::maybeHas ( const std::string &  name)
inline

Test that this Result's field has an optional subfield with name 'name' and, if it has, test that the subfield is of type 'T'.

Appends an Error::Type::IncorrectType if the field is not one of Structure, StructureArray, Union, UnionArray. Appends an Error::Type::IncorrectType if the subfield exists and is not of type 'T'.

Returns
itself

Definition at line 216 of file validator.h.

◆ operator|=()

Result& epics::nt::Result::operator|= ( const Result other)
inline

Definition at line 66 of file validator.h.

References errors, and result.

◆ valid()

bool epics::nt::Result::valid ( void  ) const
inline

Member Data Documentation

◆ errors

std::vector<Error> epics::nt::Result::errors

Definition at line 54 of file validator.h.

Referenced by operator|=().

◆ field

epics::pvData::FieldConstPtr epics::nt::Result::field

Definition at line 52 of file validator.h.

◆ path

std::string epics::nt::Result::path

Definition at line 53 of file validator.h.

◆ result

enum epics::nt::Result::result_t epics::nt::Result::result

Referenced by operator|=().


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