NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
Public Member Functions | Protected Member Functions | List of all members
BiometricEvaluation::IO::Properties Class Reference

Maintain key/value pairs of strings, with each property matched to one value. More...

#include <be_io_properties.h>

Inherited by BiometricEvaluation::IO::PropertiesFile.

Public Member Functions

 Properties (IO::Mode mode=IO::Mode::ReadWrite, const std::map< std::string, std::string > &defaults={})
 Construct a new Properties object. More...
 
 Properties (const uint8_t *buffer, const size_t size, IO::Mode mode=IO::Mode::ReadWrite, const std::map< std::string, std::string > &defaults={})
 Construct a new Properties object from the contents of a buffer. More...
 
virtual void setProperty (const std::string &property, const std::string &value)
 Set a property with a value. More...
 
virtual void setPropertyFromInteger (const std::string &property, int64_t value)
 Set a property with an integer value. More...
 
virtual void setPropertyFromDouble (const std::string &property, double value)
 Set a property with a double value. More...
 
virtual void setPropertyFromBoolean (const std::string &property, bool value)
 Set a property with a boolean value. More...
 
virtual void removeProperty (const std::string &property)
 Remove a property. More...
 
virtual std::string getProperty (const std::string &property) const
 Retrieve a property value as a string object. More...
 
virtual int64_t getPropertyAsInteger (const std::string &property) const
 Retrieve a property value as an integer value. More...
 
virtual double getPropertyAsDouble (const std::string &property) const
 Retrieve a property value as a double value. More...
 
virtual bool getPropertyAsBoolean (const std::string &property) const
 
std::vector< std::string > getPropertyKeys () const
 Retrieve a set of all property keys. More...
 
virtual ~Properties ()
 Destructor. More...
 

Protected Member Functions

BiometricEvaluation::IO::Mode getMode () const
 Obtain the mode of the Properties object. More...
 
void initWithBuffer (const Memory::uint8Array &buffer, const std::map< std::string, std::string > &defaults)
 Initialize the PropertiesMap with the contents of a properly formatted buffer. More...
 
void initWithBuffer (const uint8_t *const buffer, size_t size, const std::map< std::string, std::string > &defaults)
 Initialize the PropertiesMap with the contents of a properly formatted buffer. More...
 

Detailed Description

Maintain key/value pairs of strings, with each property matched to one value.

Definition at line 30 of file be_io_properties.h.

Constructor & Destructor Documentation

◆ Properties() [1/2]

BiometricEvaluation::IO::Properties::Properties ( IO::Mode  mode = IO::Mode::ReadWrite,
const std::map< std::string, std::string > &  defaults = {} 
)

Construct a new Properties object.

Parameters
[in]modeThe read/write mode of the object.
[in]defaultsDefault property/value pairs to insert.

◆ Properties() [2/2]

BiometricEvaluation::IO::Properties::Properties ( const uint8_t *  buffer,
const size_t  size,
IO::Mode  mode = IO::Mode::ReadWrite,
const std::map< std::string, std::string > &  defaults = {} 
)

Construct a new Properties object from the contents of a buffer.

The format of the buffer can be seen in PropertiesFile.

Parameters
[in]bufferA buffer that contains the contents of a Property file.
[in]sizeThe size of buffer.
[in]modeThe read/write mode of the object.
[in]defaultsDefault property/value pairs to insert.
Exceptions
Error::StrategyErrorA line in the properties file is malformed.

◆ ~Properties()

virtual BiometricEvaluation::IO::Properties::~Properties ( )
virtual

Destructor.

Member Function Documentation

◆ setProperty()

virtual void BiometricEvaluation::IO::Properties::setProperty ( const std::string &  property,
const std::string &  value 
)
virtual

Set a property with a value.

Both the property and value will have leading and trailing whitespace removed. If the property already exists in the set, its value will be replaced with the new value; otherwise, the property will be created.

Parameters
[in]propertyThe name of the property to set.
[in]valueThe value associated with the property.
Exceptions
Error::StrategyErrorThe Properties object is read-only.

◆ setPropertyFromInteger()

virtual void BiometricEvaluation::IO::Properties::setPropertyFromInteger ( const std::string &  property,
int64_t  value 
)
virtual

Set a property with an integer value.

The property will have leading and trailing whitespace removed. If the property already exists in the set, its value will be replaced with the new value; otherwise the property will be created.

Parameters
[in]propertyThe name of the property to set.
[in]valueThe value associated with the property.
Exceptions
Error::StrategyErrorThe Properties object is read-only.

◆ setPropertyFromDouble()

virtual void BiometricEvaluation::IO::Properties::setPropertyFromDouble ( const std::string &  property,
double  value 
)
virtual

Set a property with a double value.

The property will have leading and trailing whitespace removed. If the property already exists in the set, its value will be replaced with the new value; otherwise the property will be created.

Parameters
[in]propertyThe name of the property to set.
[in]valueThe value associated with the property.
Exceptions
Error::StrategyErrorThe Properties object is read-only.

◆ setPropertyFromBoolean()

virtual void BiometricEvaluation::IO::Properties::setPropertyFromBoolean ( const std::string &  property,
bool  value 
)
virtual

Set a property with a boolean value.

The actual value to be written is implementation- defined and may not actually be preserved, but the boolean value is guaranteed to remain valid when read with getPropertyAsBoolean().

Parameters
[in]propertyThe name of the property to set.
[in]valueThe value associated with the property.
Exceptions
Error::StrategyErrorThe Properties object is read-only.

◆ removeProperty()

virtual void BiometricEvaluation::IO::Properties::removeProperty ( const std::string &  property)
virtual

Remove a property.

Parameters
[in]propertyThe name of the property to set.
Exceptions
Error::ObjectDoesNotExistThe named property does not exist.
Error::StrategyErrorThe Properties object is read-only.

◆ getProperty()

virtual std::string BiometricEvaluation::IO::Properties::getProperty ( const std::string &  property) const
virtual

Retrieve a property value as a string object.

Parameters
[in]propertyThe name of the property to get.
Exceptions
Error::ObjectDoesNotExistThe named property does not exist.

◆ getPropertyAsInteger()

virtual int64_t BiometricEvaluation::IO::Properties::getPropertyAsInteger ( const std::string &  property) const
virtual

Retrieve a property value as an integer value.

Integer value strings for properties can represent either decimal or hexadecimal values, which must be preceded with either "0x" or "0X".

Parameters
[in]propertyThe name of the property to get.
Exceptions
Error::ObjectDoesNotExistThe named property does not exist.
Error::ConversionErrorThe property value cannot be converted, due to non-numeric characters in the string, or the value is the empty string.

◆ getPropertyAsDouble()

virtual double BiometricEvaluation::IO::Properties::getPropertyAsDouble ( const std::string &  property) const
virtual

Retrieve a property value as a double value.

Parameters
[in]propertyThe name of the property to get.
Exceptions
Error::ObjectDoesNotExistThe named property does not exist.
Error::ConversionErrorThe property value cannot be converted, due to non-numeric characters in the string, or the value is the empty string.

◆ getPropertyAsBoolean()

virtual bool BiometricEvaluation::IO::Properties::getPropertyAsBoolean ( const std::string &  property) const
virtual

◆ getPropertyKeys()

std::vector< std::string > BiometricEvaluation::IO::Properties::getPropertyKeys ( ) const

Retrieve a set of all property keys.

Returns
A vector of property key strings.

◆ getMode()

BiometricEvaluation::IO::Mode BiometricEvaluation::IO::Properties::getMode ( ) const
protected

Obtain the mode of the Properties object.

Returns
Mode (Mode::ReadOnly or Mode::ReadWrite)

◆ initWithBuffer() [1/2]

void BiometricEvaluation::IO::Properties::initWithBuffer ( const Memory::uint8Array buffer,
const std::map< std::string, std::string > &  defaults 
)
protected

Initialize the PropertiesMap with the contents of a properly formatted buffer.

This method ensures that the PropertiesMap contains only the properties found within the buffer.

Parameters
bufferContents of a properties file.
defaultsDefault property/value pairs.
Exceptions
Error::StrategyErrorA line of the buffer is malformed.

◆ initWithBuffer() [2/2]

void BiometricEvaluation::IO::Properties::initWithBuffer ( const uint8_t *const  buffer,
size_t  size,
const std::map< std::string, std::string > &  defaults 
)
protected

Initialize the PropertiesMap with the contents of a properly formatted buffer.

This method ensures that the PropertiesMap contains only the properties found within the buffer.

Parameters
bufferContents of a properties file.
sizeSize of the buffer.
defaultsDefault property/value pairs.
Exceptions
Error::StrategyErrorA line of the buffer is malformed.

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