Rudiments
Public Member Functions | List of all members
sensitivevalue Class Reference

Public Member Functions

 sensitivevalue ()
 
 ~sensitivevalue ()
 
void setIncludeStart (const char *delimiter)
 
void setIncludeStart (const char *delimiter, uint64_t len)
 
void setIncludeEnd (const char *delimiter)
 
void setIncludeEnd (const char *delimiter, uint64_t len)
 
void setVerbatimFormat (sensitivevalue_format_t format)
 
void setFileFormat (sensitivevalue_format_t format)
 
void setChompTextFile (bool chomptextfile)
 
void setPath (const char *path)
 
void setPath (const char *path, uint64_t len)
 
void setTextExtension (const char *ext)
 
void setTextExtension (const char *ext, uint64_t len)
 
void setBinaryExtension (const char *ext)
 
void setBinaryExtension (const char *ext, uint64_t len)
 
void setHexExtension (const char *ext)
 
void setHexExtension (const char *ext, uint64_t len)
 
const char * getIncludeStart ()
 
uint64_t getIncludeStartLength ()
 
const char * getIncludeEnd ()
 
uint64_t getIncludeEndLength ()
 
sensitivevalue_format_t getVerbatimFormat ()
 
sensitivevalue_format_t getFileFormat ()
 
bool getChompTextFile ()
 
const char * getPath ()
 
uint64_t getPathLength ()
 
const char * getTextExtension ()
 
uint64_t getTextExtensionLength ()
 
const char * getBinaryExtension ()
 
uint64_t getBinaryExtensionLength ()
 
const char * getHexExtension ()
 
uint64_t getHexExtensionLength ()
 
void parse (const char *in)
 
void parse (const char *in, uint64_t inlen)
 
const byte_t * getValue ()
 
byte_t * detachValue ()
 
uint64_t getValueSize ()
 
const char * getTextValue ()
 
char * detachTextValue ()
 
uint64_t getTextValueLength ()
 
bool clear ()
 
bool reset ()
 

Constructor & Destructor Documentation

◆ sensitivevalue()

sensitivevalue::sensitivevalue ( )

Creates an instance of the sensitivevalue class.

◆ ~sensitivevalue()

sensitivevalue::~sensitivevalue ( )

Deletes this instance of the sensitivevalue class.

Member Function Documentation

◆ clear()

bool sensitivevalue::clear ( )

Clears the internal buffer containing the value.

Subsequent calls to getValue(), detachValue(), getTextValue(), and detachTextValue() will return NULL until parse() is called again. Similarly, subsequent calls to getValueSize() and getTextValueLength() will return 0 until parse() is called again.

Does not reset properties such as include delimiters, chomp behavior, etc. to defaults.

Always returns true.

◆ detachTextValue()

char* sensitivevalue::detachTextValue ( )

Returns the value stored by a previous call to parse().

Subsequent calls to getValue() or detachValue() will return NULL until parse() is called again.

The calling program must deallocate the string returned from this method.

◆ detachValue()

byte_t* sensitivevalue::detachValue ( )

Returns the value stored by a previous call to parse().

Subsequent calls to getValue() or detachValue() will return NULL until parse() is called again.

The calling program must deallocate the string returned from this method.

◆ getBinaryExtension()

const char* sensitivevalue::getBinaryExtension ( )

Returns the extension that will be used when searching for binary files.

◆ getBinaryExtensionLength()

uint64_t sensitivevalue::getBinaryExtensionLength ( )

Returns the length of the extension that will be used when searching for binary files.

◆ getChompTextFile()

bool sensitivevalue::getChompTextFile ( )

Returns whether or not trailing carriage returns and line feeds will be trimmed from values retrieved from text files.

◆ getFileFormat()

sensitivevalue_format_t sensitivevalue::getFileFormat ( )

Returns whether values retrieved from files will be interpreted as text, binary, or hex data.

◆ getHexExtension()

const char* sensitivevalue::getHexExtension ( )

Returns the extension that will be used when searching for hex files.

◆ getHexExtensionLength()

uint64_t sensitivevalue::getHexExtensionLength ( )

Returns the length of the extension that will be used when searching for hex files.

◆ getIncludeEnd()

const char* sensitivevalue::getIncludeEnd ( )

Returns the delimiter that ends a file include, either the delimiter set by setIncludeEnd() or the default if no delimiter was set.

◆ getIncludeEndLength()

uint64_t sensitivevalue::getIncludeEndLength ( )

Returns the length of the delimiter that ends a file include, either the length of the delimiter set by setIncludeEnd() or the length of the default if no delimiter was set.

◆ getIncludeStart()

const char* sensitivevalue::getIncludeStart ( )

Returns the delimiter that starts a file include, either the delimiter set by setIncludeStart() or the default if no delimiter was set.

◆ getIncludeStartLength()

uint64_t sensitivevalue::getIncludeStartLength ( )

Returns the length of the delimiter that starts a file include, either the length of the delimiter set by setIncludeStart() or the length of the default if no delimiter was set.

◆ getPath()

const char* sensitivevalue::getPath ( )

Returns the file search path.

◆ getPathLength()

uint64_t sensitivevalue::getPathLength ( )

Returns the file search path length.

◆ getTextExtension()

const char* sensitivevalue::getTextExtension ( )

Returns the extension that will be used when searching for text files.

◆ getTextExtensionLength()

uint64_t sensitivevalue::getTextExtensionLength ( )

Returns the length of the extension that will be used when searching for text files.

◆ getTextValue()

const char* sensitivevalue::getTextValue ( )

Returns the value stored by a previous call to parse().

◆ getTextValueLength()

uint64_t sensitivevalue::getTextValueLength ( )

Returns the number of characters that getTextValue() or detachTextValue() would return.

Note that in most cases, this should be called prior to calling detachTextValue() as calling it after the value has been detached will return 0.

◆ getValue()

const byte_t* sensitivevalue::getValue ( )

Returns the value stored by a previous call to parse().

◆ getValueSize()

uint64_t sensitivevalue::getValueSize ( )

Returns the number of bytes that getValue() or detachValue() would return.

Note that in most cases, this should be called prior to calling detachValue() as calling it after the value has been detached will return 0.

◆ getVerbatimFormat()

sensitivevalue_format_t sensitivevalue::getVerbatimFormat ( )

Returns whether values passed directly into parse() will be interpreted as text, binary, or hex data.

◆ parse() [1/2]

void sensitivevalue::parse ( const char *  in)

Parses "in".

If "in" does not begin and end with the delimiters set by setIncludeStart()/setIncludeEnd() (or square brackets by default) then:

  • Subsequent calls to getValue()/detachValue() or getTextValue()/detachTextValue() will return "in".
  • If setVerbatimFormat() was set to FORMAT_TEXT (the default), then subsequent calls to getValue()/detachValue() or getTextValue()/detachTextValue() will return "in" verbatim and subsequent calls to getValueSize()/getTextValueLength() will return the size (in bytes) or length (in characters) of "in".
  • If setVerbatimFormat() was set to FORMAT_BINARY then subsequent calls to getValue()/detachValue() will return "in" verbatim and subsequent calls to getValueSize() will return the size (in bytes) of "in".

    Subsequent calls to getTextValue()/detachTextValue() will also return "in" verbatim, and subsequent calls to getTextValueLength() will return the length (in characters) of "in", but may be unreliable, as "in" may contain NULLs which would be interpreted as string terminators.

  • If setVerbatimFormat() was set to FORMAT_HEX, then the contents of "in" will be interpreted as a string representation of hex values and converted to the corresponding binary data. Subsequent calls to getValue()/detachValue() will return this binary data and subsequent calls to getValueSize() will return the size (in bytes) of this binary data.

    Subsequent calls to getTextValue()/detachTextValue() will also return this binary data, and subsequent calls to getTextValueLength() will return the length (in characters) of this binary data, but may be unreliable, as the data may contain NULLs which would be interpreted as string terminators.

If "in" begins and ends with the delimiters set by setIncludeStart()/setIncludeEnd() (or square brackets by default) then:

  • The string between the delimiters will be interpreted as a file name, and the file will be searched for using the name:
  • If the file is not found then "in" will be interpreted as not having been a file after all. See the previous section for details.
  • If the file is found then the contents will be fetched.
  • If the file format was FORMAT_TEXT, either:
    • by default
    • as set by setFormat()
    • or because the file was found by text extension then if chomp-text-files is true, either:
    • by default
    • or as set by setChompTextFile(true) then trailing carriage returns and line feeds will be removed from the contents of the file.
  • If the file format was FORMAT_HEX, either:
    • as set by setFormat()
    • or because the file was found by text extension then the contents of the file will be interpreted as a string representation of hex values and converted to the corresponding binary data.
  • If the file format was FORMAT_TEXT then subsequent calls to getValue()/detachValue() or getTextValue()/detachTextValue() will return the processed contents of the file and subsequent calls to getValueSize()/getTextValueLength() will return the size (in bytes) or length (in characters) of the processed contents of the file.
  • If the file format was FORMAT_BINARY, then subsequent calls to getValue()/detachValue() will return the contents of the file and subsequent calls to getValueSize() will return the size (in bytes) of the contents of the file.

    Subsequent calls to getTextValue()/detachTextValue() will also return the contents of the file, and subsequent calls to getTextValueLength() will return the length (in characters) of the contents of the file, but may be unreliable, as the contents of the file may contain NULLs which would be interpreted as string terminators.

  • If the file format was FORMAT_HEX, then subsequent calls to getValue()/detachValue() will return the processed contents of the file and subsequent calls to getValueSize() will return the size (in bytes) of the processed contents of the file.

    Subsequent calls to getTextValue()/detachTextValue() will also return the processed contents of the file, and subsequent calls to getTextValueLength() will return the length (in characters) of the processed contents of the file, but may be unreliable, as the data may contain NULLs which would be interpreted as string terminators.

◆ parse() [2/2]

void sensitivevalue::parse ( const char *  in,
uint64_t  inlen 
)

Parses the first "inlen" bytes of "in". See parse() for details.

◆ reset()

bool sensitivevalue::reset ( )

Clears the internal buffer containing the value and resets properties such as include delimiters, chomp behavior, etc. to defaults.

Always returns true.

◆ setBinaryExtension() [1/2]

void sensitivevalue::setBinaryExtension ( const char *  ext)

Sets the extension to use when searching for binary files. Defaults to NULL. See parse() for details.

◆ setBinaryExtension() [2/2]

void sensitivevalue::setBinaryExtension ( const char *  ext,
uint64_t  len 
)

Sets the extension to use when searching for binary files. Defaults to NULL, 0. See parse() for details.

◆ setChompTextFile()

void sensitivevalue::setChompTextFile ( bool  chomptextfile)

Sets whether or not to trim trailing carriage returns and line feeds will be trimmed from text files. Defaults to true. See parse() for details.

◆ setFileFormat()

void sensitivevalue::setFileFormat ( sensitivevalue_format_t  format)

Sets whether values retrieved from files will be interpreted as text, binary, or hex data. Defaults to text. See parse() for details.

◆ setHexExtension() [1/2]

void sensitivevalue::setHexExtension ( const char *  ext)

Sets the extension to use when searching for hex files. Defaults to NULL. See parse() for details.

◆ setHexExtension() [2/2]

void sensitivevalue::setHexExtension ( const char *  ext,
uint64_t  len 
)

Sets the extension to use when searching for hex files. Defaults to NULL, 0. See parse() for details.

◆ setIncludeEnd() [1/2]

void sensitivevalue::setIncludeEnd ( const char *  delimiter)

Sets the delimiter that ends a file include to "delimiter". Defaults to a right square bracket - "]". See parse() for details.

◆ setIncludeEnd() [2/2]

void sensitivevalue::setIncludeEnd ( const char *  delimiter,
uint64_t  len 
)

Sets the delimiter that ends a file include to "delimiter" of length "len". Defaults to a right square bracket - "]". See parse() for details.

◆ setIncludeStart() [1/2]

void sensitivevalue::setIncludeStart ( const char *  delimiter)

Sets the delimiter that starts a file include to "delimiter". Defaults to a left square bracket - "[". See parse() for details.

◆ setIncludeStart() [2/2]

void sensitivevalue::setIncludeStart ( const char *  delimiter,
uint64_t  len 
)

Sets the delimiter that starts a file include to "delimiter" of length "len". Defaults to a left square bracket - "[". See parse() for details.

◆ setPath() [1/2]

void sensitivevalue::setPath ( const char *  path)

Sets the file search path. Defaults to NULL. See parse() for details.

◆ setPath() [2/2]

void sensitivevalue::setPath ( const char *  path,
uint64_t  len 
)

Sets the file search path. Defaults to NULL, 0. See parse() for details.

◆ setTextExtension() [1/2]

void sensitivevalue::setTextExtension ( const char *  ext)

Sets the extension to use when searching for text files. Defaults to NULL. See parse() for details.

◆ setTextExtension() [2/2]

void sensitivevalue::setTextExtension ( const char *  ext,
uint64_t  len 
)

Sets the extension to use when searching for text files. Defaults to NULL, 0. See parse() for details.

◆ setVerbatimFormat()

void sensitivevalue::setVerbatimFormat ( sensitivevalue_format_t  format)

Sets whether values passed directly into parse() will be interpreted as text, binary, or hex data. Defaults to text. See parse() for details.