WSF
usmtf::VariantValidator< Types > Class Template Reference

#include <VariantValidator.hpp>

Inheritance diagram for usmtf::VariantValidator< Types >:
Collaboration diagram for usmtf::VariantValidator< Types >:

Public Member Functions

 VariantValidator ()=default
 VariantValidator (const VariantValidator &aOther)=delete
 VariantValidator (const VariantValidator &&aOther)=delete
VariantValidator operator= (const VariantValidator &aOther)=delete
VariantValidator operator= (const VariantValidator &&aOther)=delete
bool ParseAndValidate (const usmtf::Field &aField) override
template<typename T>
T * IsMatch () const
bool HasMatch () const
 Returns false if no match was made or Parse and Validate has yet to be called.
Public Member Functions inherited from usmtf::FFIRN_Validator
 FFIRN_Validator ()=default
const std::string & GetRawContent () const noexcept
 Return the content of the field as it was in the USMTF set.
std::vector< std::string > SplitOnDelimeter (const std::string &value, const std::string &delimeter)
 Values separated by delimeter.
const std::string & GetFieldContent () const noexcept
Public Member Functions inherited from usmtf::Validatable
bool IsValid () const noexcept
Public Member Functions inherited from usmtf::ErrorManager
virtual ~ErrorManager ()=default
bool HasErrors () const noexcept
void LogErrors (std::ostream &aOut) const noexcept
const std::vector< ValidationError > & GetErrors () const

Additional Inherited Members

Public Types inherited from usmtf::FFIRN_Validator
using FFIRN_Func = std::function<bool(void)>
using FFIRN_DescriptorMap = std::unordered_map<std::string, FFIRN_Func>
Static Public Member Functions inherited from usmtf::FFIRN_Validator
static bool IsInSelection (const std::string &aValue, const std::vector< std::string > &choices) noexcept
static bool IsStringLength (const std::string &aValue, size_t aLength) noexcept
static size_t CheckForAnyDelimeter (const std::string &aValue, const std::vector< std::string > &aDelimeters) noexcept
 Returns the positions of a specified delimiter if present, npos if not.
static size_t CheckForAnyDelimeter (const std::string &aValue, const std::vector< std::string > &aDelimeters, std::string &aFoundDelimeter) noexcept
template<class T>
static bool IsInRange (T aValue, T aLowerBound, T aUpperBound) noexcept
Protected Member Functions inherited from usmtf::FFIRN_Validator
bool ValidateByDescriptor (const FFIRN_DescriptorMap &aDescriptorMap)
 Speed up validation if descriptor is present. Runs all functions if it isn't.
void ClearErrorsIfValid (bool aHasAtLeastOnePassed) noexcept
void SetField (const Field &aField) noexcept
 Field Setter for internal use only.
Protected Member Functions inherited from usmtf::ErrorManager
void AddError (const ValidationError &aError) noexcept
void AddError (const std::string &aFailureReason, const std::string &aValueValidatied, const std::string &aOptionalSuggestion="") noexcept
void AddError (const std::string &aErrorMessage) noexcept
void AddErrors (const std::vector< ValidationError > &aErrors) noexcept
void ClearErrors () noexcept
Protected Attributes inherited from usmtf::FFIRN_Validator
Field mField

Detailed Description

template<typename... Types>
class usmtf::VariantValidator< Types >

VariantValidator is for composing together multiple Validators that dont have common components. If the field Validator you are look to model shares common components with its usmtf specified options its best to make a "standard" FFIRN_Validators like LatLon.cpp. This is reserved for when those specified options share no common members and composition is needed. The route would be to model every individual rule set separately and then use this class to compose them together and use as if you would any other validator. Please see test_variant_validator.cpp for usage examples. Note. This class enforces compile time check that ...Types are FFIRN_Validators.

Constructor & Destructor Documentation

◆ VariantValidator() [1/3]

template<typename... Types>
usmtf::VariantValidator< Types >::VariantValidator ( )
default

◆ VariantValidator() [2/3]

template<typename... Types>
usmtf::VariantValidator< Types >::VariantValidator ( const VariantValidator< Types > & aOther)
delete

◆ VariantValidator() [3/3]

template<typename... Types>
usmtf::VariantValidator< Types >::VariantValidator ( const VariantValidator< Types > && aOther)
delete

Member Function Documentation

◆ HasMatch()

template<typename... Types>
bool usmtf::VariantValidator< Types >::HasMatch ( ) const
inline

Returns false if no match was made or Parse and Validate has yet to be called.

◆ IsMatch()

template<typename... Types>
template<typename T>
T * usmtf::VariantValidator< Types >::IsMatch ( ) const
inline

Returns casted * if the validator that passed is the same as T, nullptr otherwise. This can be used to effectively test the type of the passed variant, the validators validity state, get your needed validator or all 3. more examples in test_variant_validator.cpp.

◆ operator=() [1/2]

template<typename... Types>
VariantValidator usmtf::VariantValidator< Types >::operator= ( const VariantValidator< Types > && aOther)
delete

◆ operator=() [2/2]

template<typename... Types>
VariantValidator usmtf::VariantValidator< Types >::operator= ( const VariantValidator< Types > & aOther)
delete

◆ ParseAndValidate()

template<typename... Types>
bool usmtf::VariantValidator< Types >::ParseAndValidate ( const usmtf::Field & aField)
inlineoverridevirtual

API contract for a FFIRN_Validator, delegates to a recursive template to achieve the composite validation of its members. only one passing validator is stored as the variant, and its simply the first the passes ParseAndValidate.

Implements usmtf::FFIRN_Validator.


The documentation for this class was generated from the following file:
Copyrights Multiple, All Rights Reserved