Represents a string field in a binary file.
More...
#include <StringField.h>
|
| | StringField (size_t size) |
| | Constructor; creates a new instance of StringField.
|
| | StringField (std::string value) |
| | Constructor; creates a new instance of StringField.
|
| | StringField (const StringField &other) |
| | Copy constructor; creates a deep copy of the field.
|
| std::string | Value () const |
| | Gets the value of the field as a string.
|
| void | SetValue (std::string value) |
| | Sets the value of the field.
|
| std::string | ToString () const override |
| | Converts the field's data to a string representation.
|
| std::string | ToString (StringFormat format) const override |
| | Converts the field's data to a string representation.
|
| StringField & | operator= (const StringField &other) |
| | Assignment operator for StringField.
|
| | RawField (size_t size) |
| | Constructor; creates a new instance of Field.
|
| | RawField (const RawField &other) |
| | Copy constructor; creates a deep copy of the field.
|
| size_t | Size () const override |
| | Gets the size of the data in the field.
|
| char * | RawData () override |
| | Provides access to the field's raw data via pointer.
|
| const char * | RawData () const override |
| | Provides access to the field's raw data via const pointer.
|
| RawField & | operator= (const RawField &other) |
| | Assignment operator for RawField.
|
| virtual | ~DataField ()=default |
| | Default destructor; properly destroys the instance.
|
| virtual void | CopyRawDataTo (DataField *other) |
| | Copies the raw data to another DataField.
|
Represents a string field in a binary file.
Binary files can sometimes still contain text fields or strings. Use the string field to read or write these types of fields from and to a Binary::Stream, such as a Binary::FileStream.
◆ StringField() [1/3]
| Binary::StringField::StringField |
( |
size_t | size | ) |
|
|
inline |
Constructor; creates a new instance of StringField.
- Parameters
-
| size | The size of the field, in bytes. |
- Precondition
- Size is > 0.
◆ StringField() [2/3]
| Binary::StringField::StringField |
( |
std::string | value | ) |
|
|
inline |
Constructor; creates a new instance of StringField.
This constructor creates a new StringField instance of the same size as the specified string and initializes it to the same value as the specified string.
- Parameters
-
| value | The string to create the field from. |
- Precondition
- Specified string length is > 0.
- Exceptions
-
| std::invalid_argument | if specified string length is 0. |
◆ StringField() [3/3]
| Binary::StringField::StringField |
( |
const StringField & | other | ) |
|
|
inline |
Copy constructor; creates a deep copy of the field.
- Parameters
-
◆ operator=()
◆ SetValue()
| void Binary::StringField::SetValue |
( |
std::string | value | ) |
|
Sets the value of the field.
If the specified string's size is greater than the field's size, the specified value will be truncated to fit the field.
- Parameters
-
| value | The string to set the field's value to. |
- Postcondition
- Writes min(Size(), value.length()) bytes to the field.
-
Bytes beyond value.length() are unchanged.
◆ ToString() [1/2]
| std::string Binary::StringField::ToString |
( |
| ) |
const |
|
inlineoverridevirtual |
Converts the field's data to a string representation.
- Returns
- A string representation of the field's data.
Reimplemented from Binary::RawField.
◆ ToString() [2/2]
| std::string Binary::StringField::ToString |
( |
StringFormat | format | ) |
const |
|
inlineoverridevirtual |
Converts the field's data to a string representation.
- Returns
- A string representation of the field's data.
Reimplemented from Binary::RawField.
◆ Value()
| std::string Binary::StringField::Value |
( |
| ) |
const |
Gets the value of the field as a string.
- Returns
- A string representing the value of the field.
The documentation for this class was generated from the following file: