|
WSF
|
#include <FFIRN_Validator.hpp>


Public Types | |
| using | FFIRN_Func = std::function<bool(void)> |
| using | FFIRN_DescriptorMap = std::unordered_map<std::string, FFIRN_Func> |
Public Member Functions | |
| FFIRN_Validator ()=default | |
| virtual bool | ParseAndValidate (const usmtf::Field &aField)=0 |
| 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 |
Static Public Member Functions | |
| 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 | |
| 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 | |
| Field | mField |
The idea behind FFIRNValidators is simple. In the USMTF Spec there lives FFIRN/FUDN numbers that are identifiers to a set of rules that validate field content. Programmatically were representing this as classes that the content of the field will be ran through. Interested parties will extract the data they are interested in.
| using usmtf::FFIRN_Validator::FFIRN_DescriptorMap = std::unordered_map<std::string, FFIRN_Func> |
The Descriptor Map is an optimization technique so that if Descriptors are present only that set of validations needs to be ran.
| using usmtf::FFIRN_Validator::FFIRN_Func = std::function<bool(void)> |
|
default |
|
staticnoexcept |
Returns the positions of a specified delimiter if present, npos if not.
References CheckForAnyDelimeter(), and pos.
Referenced by CheckForAnyDelimeter(), CheckForAnyDelimeter(), usmtf::EllipticalArea::IsValidAxis(), usmtf::IntervalDuration::IsValidIntervalDuration(), usmtf::Radius::IsValidRadius(), usmtf::TrackWidth::IsValidTrackWidth(), usmtf::VerticalDimension::IsValidVerticalDimensionBaseToFlightLevel(), usmtf::VerticalDimension::IsValidVerticalDimensionBaseToRelativeAlt(), usmtf::VerticalDimension::IsValidVerticalDimensionFlightLevelToFlightLevel(), usmtf::VerticalDimension::IsValidVerticalDimensionRelativeAltToFlightLevel(), usmtf::VerticalDimension::IsValidVerticalDimensionRelativeAltToRelativeAlt(), ParseAndValidate(), and usmtf::SectorGeometry::ParseAndValidate().
|
staticnoexcept |
References CheckForAnyDelimeter(), and pos.
|
protectednoexcept |
Clear Errors If the validator is Valid. Confusingly this IS a possible state. Given Validation can pass one of many rules, the errors added by prior validations that passed will need to be cleared to make IsValid() accurate, as it just returns whether or not the error container has errors. So instead of forcing users to clear it in each of their validation function an potentially forgetting, we slim that potential to a single call in their ParseAndValidate override.
References usmtf::ErrorManager::ClearErrors(), and ClearErrorsIfValid().
Referenced by ClearErrorsIfValid(), usmtf::IntervalDuration::ParseAndValidate(), usmtf::TimePoint::ParseAndValidate(), usmtf::VariantValidator< UTM_Location, NamedLocation, FreeText >::ParseAndValidate(), and usmtf::VerifiedTimePoint::ParseAndValidate().
|
noexcept |
References GetFieldContent(), and mField.
Referenced by GetFieldContent().
|
noexcept |
Return the content of the field as it was in the USMTF set.
References GetRawContent(), and mField.
Referenced by usmtf::AerialRefuelingInfo::AerialRefuelingInfo(), and GetRawContent().
|
inlinestaticnoexcept |
Referenced by usmtf::RangeValidator< T >::IsInvalidRange(), usmtf::EllipticalArea::IsValidAxis(), usmtf::VerifiedTimePoint::IsValidContextQuantity(), usmtf::TimePoint::IsValidDay(), usmtf::EllipticalArea::IsValidDegree(), usmtf::TimePoint::IsValidHour(), usmtf::IntervalDuration::IsValidIntervalDuration(), usmtf::LatLon::IsValidLattitudinalDegree(), usmtf::LatLon::IsValidLongitudinalDegree(), usmtf::LatLon::IsValidMinuteOrSecond(), usmtf::TimePoint::IsValidMinuteOrSecond(), usmtf::RadialBearing::IsValidRadialBearing(), usmtf::Radius::IsValidRadius(), usmtf::VerticalDimension::IsValidRelativeAltitude(), usmtf::VerticalDimension::IsValidVerticalDimensionBaseToFlightLevel(), usmtf::VerticalDimension::IsValidVerticalDimensionBaseToRelativeAlt(), usmtf::VerticalDimension::IsValidVerticalDimensionRelativeAltToFlightLevel(), usmtf::VerticalDimension::IsValidVerticalDimensionRelativeAltToRelativeAlt(), and usmtf::TimePoint::IsValidYear().
|
staticnoexcept |
Static for reusable outside a need of an instance. Confirms a string is within a vector of strings. I expect using Sets might be faster.
References IsInSelection().
Referenced by usmtf::Message::GetSets(), IsInSelection(), usmtf::AirspaceTimeMode::IsValidAirspaceTimeMode(), usmtf::VerticalDimension::IsValidAltitudeBaseReferencePoint(), usmtf::VerticalDimension::IsValidAltitudeUOM(), usmtf::IntervalFrequency::IsValidIntervalFrequency(), usmtf::TimePoint::IsValidMonthName(), usmtf::OrbitAlignment::IsValidOrbitAlignment(), usmtf::TimePoint::IsValidStopTimeQualifier(), usmtf::TimePoint::IsValidTimeZone(), usmtf::AirspaceShape::IsValidTypeOfAirspaceShape(), usmtf::Radius::IsValidUnitOfMeasureForRadius(), usmtf::IntervalDuration::IsValidUnitOfTimeMeasurement(), and ParseAndValidate().
|
staticnoexcept |
References IsStringLength().
Referenced by IsStringLength(), usmtf::AirspaceTimeMode::IsValidAirspaceTimeMode(), usmtf::TimePoint::IsValidDateTimeGroup(), usmtf::TimePoint::IsValidDayTimeMonth(), usmtf::LatLon::IsValidLatLonMinutes(), usmtf::LatLon::IsValidLatLonSeconds(), usmtf::RadialBearing::IsValidRadialBearing(), usmtf::VerifiedTimePoint::IsValidVerifiedMonthDateTime(), usmtf::VerticalDimension::IsValidVerticalDimensionFlightLevelToFlightLevel(), ParseAndValidate(), usmtf::SectorGeometry::ParseAndValidate(), usmtf::TimePoint::ValidateDayTime(), and usmtf::VerifiedTimePoint::ValidateVerifiedDateTime().
|
pure virtual |
I am not a huge fan of violating command query separation. But, in this case it makes sense. The functions that come into ParseAndValidate have to parse to get value of the component, sometimes there are many components in a single field. Unfortunately parsing is an intertwined attribute of validation. You cant parse according to some rule set if the field is invalid, making it impossible to separate the two notions easily. I have opted to instead name the functions for what they are actually doing. Parsing components and validating them as well. Optionally members can be set within the function as well.
Implemented in usmtf::AerialRefuelingSystem, usmtf::AircraftControlAgency, usmtf::AirspaceShape, usmtf::AirspaceTimeMode, usmtf::Altitude, usmtf::Beacon, usmtf::EllipticalArea, usmtf::FreeText, usmtf::Frequency, usmtf::FuelLoad, usmtf::FuelType, usmtf::InnerOuterRange, usmtf::IntervalDuration, usmtf::IntervalFrequency, usmtf::LatLon, usmtf::NamedLocation, usmtf::OrbitAlignment, usmtf::RadialBearing, usmtf::Radius, usmtf::RangeValidator< T >, usmtf::RangeValidator< double >, usmtf::RangeValidator< float >, usmtf::RangeValidator< int >, usmtf::RegexValidator, usmtf::RelativeBearingRange, usmtf::SectorGeometry, usmtf::TacanChannel, usmtf::TimePoint, usmtf::TrackWidth, usmtf::UTM_Location, usmtf::VariantValidator< Types >, usmtf::VariantValidator< LatLon, VerifiedLatLonS, RelativeBearingRange, FreeText >, usmtf::VariantValidator< Radius, EllipticalArea, SectorGeometry >, usmtf::VariantValidator< usmtf::Frequency, usmtf::FreeText >, usmtf::VariantValidator< usmtf::LatLon, usmtf::RelativeBearingRange, usmtf::FreeText >, usmtf::VariantValidator< usmtf::LatLon, usmtf::UTM_Location, usmtf::VerifiedLatLonTM, usmtf::VerifiedLatLonDS, usmtf::FreeText >, usmtf::VariantValidator< usmtf::RangeValidator< int >, usmtf::FreeText >, usmtf::VariantValidator< UTM_Location, NamedLocation, FreeText >, usmtf::VerifiedLatLonDS, usmtf::VerifiedLatLonS, usmtf::VerifiedLatLonTM, usmtf::VerifiedTimePoint, and usmtf::VerticalDimension.
References CheckForAnyDelimeter(), IsInSelection(), and IsStringLength().
|
protectednoexcept |
Field Setter for internal use only.
References mField, and SetField().
Referenced by usmtf::TacanChannel::GetRecieverChannel(), usmtf::AirspaceShape::ParseAndValidate(), usmtf::AirspaceTimeMode::ParseAndValidate(), usmtf::Altitude::ParseAndValidate(), usmtf::EllipticalArea::ParseAndValidate(), usmtf::IntervalDuration::ParseAndValidate(), usmtf::IntervalFrequency::ParseAndValidate(), usmtf::LatLon::ParseAndValidate(), usmtf::OrbitAlignment::ParseAndValidate(), usmtf::RadialBearing::ParseAndValidate(), usmtf::Radius::ParseAndValidate(), usmtf::RangeValidator< T >::ParseAndValidate(), usmtf::RegexValidator::ParseAndValidate(), usmtf::TimePoint::ParseAndValidate(), usmtf::TrackWidth::ParseAndValidate(), usmtf::VerifiedTimePoint::ParseAndValidate(), usmtf::VerticalDimension::ParseAndValidate(), and SetField().
| std::vector< std::string > usmtf::FFIRN_Validator::SplitOnDelimeter | ( | const std::string & | value, |
| const std::string & | delimeter ) |
Values separated by delimeter.
References SplitOnDelimeter().
Referenced by usmtf::EllipticalArea::IsValidEllipsesArea(), usmtf::InnerOuterRange::ParseAndValidate(), usmtf::SectorGeometry::ParseAndValidate(), and SplitOnDelimeter().
|
protected |
Speed up validation if descriptor is present. Runs all functions if it isn't.
References mField.
Referenced by usmtf::LatLon::ParseAndValidate(), and usmtf::VerticalDimension::ParseAndValidate().
|
protected |
Referenced by usmtf::UTM_Location::ConvertToLLPos(), GetFieldContent(), GetRawContent(), usmtf::IntervalDuration::IsUntilFurtherNotice(), usmtf::AirspaceTimeMode::IsValidAirspaceTimeMode(), usmtf::TimePoint::IsValidDateTimeGroup(), usmtf::TimePoint::IsValidDayTime(), usmtf::TimePoint::IsValidDayTimeMonth(), usmtf::EllipticalArea::IsValidEllipsesArea(), usmtf::IntervalDuration::IsValidIntervalDuration(), usmtf::IntervalFrequency::IsValidIntervalFrequency(), usmtf::LatLon::IsValidLatLonMinutes(), usmtf::LatLon::IsValidLatLonSeconds(), usmtf::OrbitAlignment::IsValidOrbitAlignment(), usmtf::RadialBearing::IsValidRadialBearing(), usmtf::Radius::IsValidRadius(), usmtf::TimePoint::IsValidStopTimeQualifier(), usmtf::TrackWidth::IsValidTrackWidth(), usmtf::AirspaceShape::IsValidTypeOfAirspaceShape(), usmtf::VerifiedTimePoint::IsValidVerifiedDateTime(), usmtf::VerifiedTimePoint::IsValidVerifiedMonthDateTime(), usmtf::VerticalDimension::IsValidVerticalDimensionBaseToFlightLevel(), usmtf::VerticalDimension::IsValidVerticalDimensionBaseToRelativeAlt(), usmtf::VerticalDimension::IsValidVerticalDimensionFlightLevelToFlightLevel(), usmtf::VerticalDimension::IsValidVerticalDimensionRelativeAltToFlightLevel(), usmtf::VerticalDimension::IsValidVerticalDimensionRelativeAltToRelativeAlt(), SetField(), and ValidateByDescriptor().