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

An IO::Properties object persisted in a file on disk. More...

#include <be_io_propertiesfile.h>

Inherits BiometricEvaluation::IO::Properties.

Public Member Functions

 PropertiesFile (const std::string &pathname, IO::Mode mode=IO::Mode::ReadOnly, const std::map< std::string, std::string > &defaults={})
 Construct a new Properties object from an existing or to be created properties file. More...
 
void sync ()
 Write the properties to the underlying file, synchronizing the in-memory and on-disk versions. More...
 
void changeName (const std::string &pathname)
 Change the name of the Properties, which means changing the name of the underlying file that stores the properties. More...
 
 ~PropertiesFile ()
 Destructor. More...
 
 PropertiesFile (const PropertiesFile &other)=delete
 Copy constructor (disabled). More...
 
PropertiesFileoperator= (const PropertiesFile &other)=delete
 Assignment operator (disabled). More...
 
- Public Member Functions inherited from BiometricEvaluation::IO::Properties
 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...
 

Additional Inherited Members

- Protected Member Functions inherited from BiometricEvaluation::IO::Properties
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

An IO::Properties object persisted in a file on disk.

An example file might look like this:

*     Name = John Smith
*     Age = 32
*     Favorite Hex Number = 0xffff
* 

For property keys and values, leading and trailing whitespace is removed, therefore the call

props->setProperty(" My property ", " A Value ");

results in an entry in the property file as

*     My property = A value
* 

Therefore, the property names "Foo", " Foo", "Foo " are equivalent.

Definition at line 49 of file be_io_propertiesfile.h.

Constructor & Destructor Documentation

◆ PropertiesFile() [1/2]

BiometricEvaluation::IO::PropertiesFile::PropertiesFile ( const std::string &  pathname,
IO::Mode  mode = IO::Mode::ReadOnly,
const std::map< std::string, std::string > &  defaults = {} 
)

Construct a new Properties object from an existing or to be created properties file.

The constructor will create the file when it does not exist.

Parameters
[in]pathnameThe path to the file to store the properties.
[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.
Error::FileErrorAn error occurred when using the underlying storage system.

◆ ~PropertiesFile()

BiometricEvaluation::IO::PropertiesFile::~PropertiesFile ( )

Destructor.

◆ PropertiesFile() [2/2]

BiometricEvaluation::IO::PropertiesFile::PropertiesFile ( const PropertiesFile other)
delete

Copy constructor (disabled).

Disabled because this object could represent a file on disk.

Parameters
otherPropertiesFile object to copy.

Member Function Documentation

◆ sync()

void BiometricEvaluation::IO::PropertiesFile::sync ( )

Write the properties to the underlying file, synchronizing the in-memory and on-disk versions.

Exceptions
Error::FileErrorAn error occurred when using the underlying storage system.
Error::StrategyErrorThe object was constructed with nullptr as the file name, or is read-only.

◆ changeName()

void BiometricEvaluation::IO::PropertiesFile::changeName ( const std::string &  pathname)

Change the name of the Properties, which means changing the name of the underlying file that stores the properties.

Note
No check is made that the file is writeable at this time.
Parameters
[in]pathnameThe path to the Properties file.
Exceptions
Error::StrategyErrorThe object is read-only.
Error::ObjectExistsA file at pathname already exists.

◆ operator=()

PropertiesFile & BiometricEvaluation::IO::PropertiesFile::operator= ( const PropertiesFile other)
delete

Assignment operator (disabled).

Disabled because this object could represent a file on disk.

Parameters
otherPropertiesFile object to assign;
Returns
This PropertiesFile object, now containing the contents of other.

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