Rudiments: sensitivevalue Class Reference

Rudiments

Public Member Functions | List of all members
sensitivevalue Class Reference

## Public Member Functions
| sensitivevalue ()
| ~sensitivevalue ()
void | setRedirectStart (const char *delimiter)
void | setRedirectStart (const char *delimiter, uint64_t len)
void | setRedirectEnd (const char *delimiter)
void | setRedirectEnd (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 * | getRedirectStart ()
uint64_t | getRedirectStartLength ()
const char * | getRedirectEnd ()
uint64_t | getRedirectEndLength ()
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 unsigned char * | getValue ()
unsigned char * | detachValue ()
uint64_t | getValueSize ()
const char * | getTextValue ()
char * | detachTextValue ()
uint64_t | getTextValueLength ()
void | clear ()

## 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()

void sensitivevalue::clear | ( |  | ) |

Empties 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.

Note that clear() does not reset class properties such as redirect delimiters, chomp behavior, etc. to defaults.

## ◆ 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()

unsigned char* 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.

## ◆ getPath()

const char* sensitivevalue::getPath | ( |  | ) |

Returns the file search path.

## ◆ getPathLength()

uint64_t sensitivevalue::getPathLength | ( |  | ) |

Returns the file search path length.

## ◆ getRedirectEnd()

const char* sensitivevalue::getRedirectEnd | ( |  | ) |

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

## ◆ getRedirectEndLength()

uint64_t sensitivevalue::getRedirectEndLength | ( |  | ) |

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

## ◆ getRedirectStart()

const char* sensitivevalue::getRedirectStart | ( |  | ) |

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

## ◆ getRedirectStartLength()

uint64_t sensitivevalue::getRedirectStartLength | ( |  | ) |

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

## ◆ 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 unsigned char* 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 setRedirectStart()/setRedirectEnd() (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 setRedirectStart()/setRedirectEnd() (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:
  - as-is
  - with the path defined by setPath() prepended (if not NULL)
  - with the extension defined by setTextExtension() appended (if not NULL)
  - with the path defined by setPath() prepended (if not NULL) and the extension defined by setTextExtension() appended (if not NULL)
  - with the extension defined by setBinaryExtension() appended (if not NULL)
  - with the path defined by setPath() prepended (if not NULL) and the extension defined by setBinaryExtension() appended (if not NULL)
  - with the extension defined by setHexExtension() appended (if not NULL)
  - with the path defined by setPath() prepended (if not NULL) and the extension defined by setHexExtension() appended (if not NULL)
- 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.

## ◆ 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.

## ◆ 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.

## ◆ setRedirectEnd() [1/2]

void sensitivevalue::setRedirectEnd | ( | const char * | delimiter | ) |

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

## ◆ setRedirectEnd() [2/2]

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

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

## ◆ setRedirectStart() [1/2]

void sensitivevalue::setRedirectStart | ( | const char * | delimiter | ) |

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

## ◆ setRedirectStart() [2/2]

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

Sets the delimiter that starts a file redirection to "delimiter" of length "len". Defaults to a left square bracket - "[". 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.