Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/usnistgov/NFIQ2/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The NFIQ2::Data class provides a foundation for binary data handling in NFIQ 2. It extends std::basic_string<uint8_t> and provides convenient methods for reading, writing, and converting binary data. This class serves as the base class for NFIQ2::FingerprintImageData and other data-handling classes in the library.

Class Definition

namespace NFIQ2 {
    class Data : public std::basic_string<uint8_t> {
        // Public interface
    };
}

Constructors

Default Constructor

Data();
Creates an empty Data object.

Constructor with Data Pointer

Data(const uint8_t *pData, uint32_t dataSize);
pData
const uint8_t*
required
Pointer to binary data
dataSize
uint32_t
required
Size of data at the pointer in bytes
Creates a Data object from an existing data buffer.

Copy Constructor

Data(const Data &otherData);
otherData
const Data&
required
Data object to copy from

String Constructor

explicit Data(const std::basic_string<uint8_t> &otherData);
otherData
const std::basic_string<uint8_t>&
required
Binary data in string format

Methods

readFromFile

void readFromFile(const std::string &filename);
Reads the content from a file into this object.
filename
const std::string&
required
Path to the file to read
Throws: NFIQ2::Exception if the file cannot be opened. Example:
NFIQ2::Data data;
data.readFromFile("/path/to/file.dat");

writeToFile

void writeToFile(const std::string &filename) const;
Writes the content to a file.
filename
const std::string&
required
Path to the file to write
Throws: NFIQ2::Exception if the file cannot be opened. Example:
data.writeToFile("/path/to/output.dat");

toHexString

std::string toHexString() const;
Generates a hexadecimal string representation of the buffer. Returns: The content of the buffer as a hexadecimal string. Throws: NFIQ2::Exception if no data is available in the buffer. Example:
std::string hexStr = data.toHexString();
std::cout << "Hex: " << hexStr << std::endl;

fromBase64String

void fromBase64String(const std::string &base64String);
Imports data from a Base64 encoded string.
base64String
const std::string&
required
Base64 encoded string to decode
Throws: NFIQ2::Exception if an invalid character is detected in the string. Example:
NFIQ2::Data data;
data.fromBase64String("SGVsbG8gV29ybGQh");

toBase64String

std::string toBase64String() const;
Generates a Base64 encoded string of the buffer. Returns: The content of the buffer as a Base64 encoded string. Example:
std::string base64 = data.toBase64String();
std::cout << "Base64: " << base64 << std::endl;

Usage Example

#include <nfiq2.hpp>

// Reading binary data from file
NFIQ2::Data imageData;
imageData.readFromFile("fingerprint.raw");

// Convert to base64 for transmission
std::string encoded = imageData.toBase64String();

// Later, decode back
NFIQ2::Data decodedData;
decodedData.fromBase64String(encoded);

// Write to new file
decodedData.writeToFile("fingerprint_copy.raw");

Inherited Methods

Since Data extends std::basic_string<uint8_t>, all standard string methods are available:
  • size() - Get the size of the data
  • empty() - Check if data is empty
  • clear() - Clear the data
  • data() - Get raw pointer to data
  • Standard iterators and operators

See Also

FingerprintImageData

Extends Data for fingerprint images

Exception

Error handling in NFIQ 2