A single field of a Distributed Class, either atomic or molecular. More...
#include "dcField.h"
Public Member Functions | |
DCField (const std::string &name, DCClass *dclass) | |
virtual DCAtomicField * | as_atomic_field () |
Returns the same field pointer converted to an atomic field pointer, if this is in fact an atomic field; otherwise, returns NULL. More... | |
virtual const DCAtomicField * | as_atomic_field () const |
Returns the same field pointer converted to an atomic field pointer, if this is in fact an atomic field; otherwise, returns NULL. More... | |
virtual DCField * | as_field () |
virtual const DCField * | as_field () const |
virtual DCMolecularField * | as_molecular_field () |
Returns the same field pointer converted to a molecular field pointer, if this is in fact a molecular field; otherwise, returns NULL. More... | |
virtual const DCMolecularField * | as_molecular_field () const |
Returns the same field pointer converted to a molecular field pointer, if this is in fact a molecular field; otherwise, returns NULL. More... | |
virtual DCParameter * | as_parameter () |
virtual const DCParameter * | as_parameter () const |
std::string | format_data (const vector_uchar &packed_data, bool show_field_names=true) |
Given a blob that represents the packed data for this field, returns a string formatting it for human consumption. More... | |
virtual void | generate_hash (HashGenerator &hashgen) const |
Accumulates the properties of this field into the hash. More... | |
DCClass * | get_class () const |
Returns the DCClass pointer for the class that contains this field. More... | |
const vector_uchar & | get_default_value () const |
Returns the default value for this field. More... | |
int | get_number () const |
Returns a unique index number associated with this field. More... | |
bool | has_default_value () const |
Returns true if a default value has been explicitly established for this field, false otherwise. More... | |
bool | is_airecv () const |
Returns true if the "airecv" flag is set for this field, false otherwise. More... | |
bool | is_bogus_field () const |
Returns true if the field has been flagged as a bogus field. More... | |
bool | is_broadcast () const |
Returns true if the "broadcast" flag is set for this field, false otherwise. More... | |
bool | is_clrecv () const |
Returns true if the "clrecv" flag is set for this field, false otherwise. More... | |
bool | is_clsend () const |
Returns true if the "clsend" flag is set for this field, false otherwise. More... | |
bool | is_db () const |
Returns true if the "db" flag is set for this field, false otherwise. More... | |
bool | is_ownrecv () const |
Returns true if the "ownrecv" flag is set for this field, false otherwise. More... | |
bool | is_ownsend () const |
Returns true if the "ownsend" flag is set for this field, false otherwise. More... | |
bool | is_ram () const |
Returns true if the "ram" flag is set for this field, false otherwise. More... | |
bool | is_required () const |
Returns true if the "required" flag is set for this field, false otherwise. More... | |
void | output (std::ostream &out) const |
Write a string representation of this instance to <out>. More... | |
virtual void | output (std::ostream &out, bool brief) const =0 |
virtual bool | pack_default_value (DCPackData &pack_data, bool &pack_error) const |
Packs the field's specified default value (or a sensible default if no value is specified) into the stream. More... | |
vector_uchar | parse_string (const std::string &formatted_string) |
Given a human-formatted string (for instance, as returned by format_data(), above) that represents the value of this field, parse the string and return the corresponding packed data. More... | |
void | set_class (DCClass *dclass) |
Assigns the class pointer to this field. More... | |
void | set_default_value (vector_uchar default_value) |
Establishes a default value for this field. More... | |
virtual void | set_name (const std::string &name) |
Sets the name of this field. More... | |
void | set_number (int number) |
Assigns the unique number to this field. More... | |
bool | validate_ranges (const vector_uchar &packed_data) const |
Verifies that all of the packed values in the field data are within the specified ranges and that there are no extra bytes on the end of the record. More... | |
void | write (std::ostream &out, int indent_level) const |
Write a string representation of this instance to <out>. More... | |
virtual void | write (std::ostream &out, bool brief, int indent_level) const =0 |
Public Member Functions inherited from DCPackerInterface | |
DCPackerInterface (const std::string &name=std::string()) | |
DCPackerInterface (const DCPackerInterface ©) | |
virtual DCClassParameter * | as_class_parameter () |
virtual const DCClassParameter * | as_class_parameter () const |
virtual DCSwitchParameter * | as_switch_parameter () |
virtual const DCSwitchParameter * | as_switch_parameter () const |
virtual int | calc_num_nested_fields (size_t length_bytes) const |
This flavor of get_num_nested_fields is used during unpacking. More... | |
bool | check_match (const DCPackerInterface *other) const |
Returns true if the other interface is bitwise the same as this one–that is, a uint32 only matches a uint32, etc. More... | |
bool | check_match (const std::string &description, DCFile *dcfile=nullptr) const |
Returns true if this interface is bitwise the same as the interface described with the indicated formatted string, e.g. More... | |
virtual bool | do_check_match_array_parameter (const DCArrayParameter *other) const |
Returns true if this field matches the indicated array parameter, false otherwise. More... | |
virtual bool | do_check_match_atomic_field (const DCAtomicField *other) const |
Returns true if this field matches the indicated atomic field, false otherwise. More... | |
virtual bool | do_check_match_class_parameter (const DCClassParameter *other) const |
Returns true if this field matches the indicated class parameter, false otherwise. More... | |
virtual bool | do_check_match_molecular_field (const DCMolecularField *other) const |
Returns true if this field matches the indicated molecular field, false otherwise. More... | |
virtual bool | do_check_match_simple_parameter (const DCSimpleParameter *other) const |
Returns true if this field matches the indicated simple parameter, false otherwise. More... | |
virtual bool | do_check_match_switch_parameter (const DCSwitchParameter *other) const |
Returns true if this field matches the indicated switch parameter, false otherwise. More... | |
int | find_seek_index (const std::string &name) const |
Returns the index number to be passed to a future call to DCPacker::seek() to seek directly to the named field without having to look up the field name in a table later, or -1 if the named field cannot be found. More... | |
const DCPackerCatalog * | get_catalog () const |
Returns the DCPackerCatalog associated with this field, listing all of the nested fields by name. More... | |
size_t | get_fixed_byte_size () const |
If has_fixed_byte_size() returns true, this returns the number of bytes this field type will use. More... | |
const std::string & | get_name () const |
Returns the name of this field, or empty string if the field is unnamed. More... | |
virtual DCPackerInterface * | get_nested_field (int n) const |
Returns the DCPackerInterface object that represents the nth nested field. More... | |
size_t | get_num_length_bytes () const |
Returns the number of bytes that should be written into the stream on a push() to record the number of bytes in the record up until the next pop(). More... | |
int | get_num_nested_fields () const |
Returns the number of nested fields required by this field type. More... | |
DCPackType | get_pack_type () const |
Returns the type of value expected by this field. More... | |
bool | has_fixed_byte_size () const |
Returns true if this field type always packs to the same number of bytes, false if it is variable. More... | |
bool | has_fixed_structure () const |
Returns true if this field type always has the same structure regardless of the data in the stream, or false if its structure may vary. More... | |
bool | has_nested_fields () const |
Returns true if this field type has any nested fields (and thus expects a push() . More... | |
bool | has_range_limits () const |
Returns true if this field, or any sub-field of this field, has a limit imposed in the DC file on its legal values. More... | |
virtual void | pack_blob (DCPackData &pack_data, const vector_uchar &value, bool &pack_error, bool &range_error) const |
Packs the indicated numeric or string value into the stream. More... | |
virtual void | pack_double (DCPackData &pack_data, double value, bool &pack_error, bool &range_error) const |
Packs the indicated numeric or string value into the stream. More... | |
virtual void | pack_int (DCPackData &pack_data, int value, bool &pack_error, bool &range_error) const |
Packs the indicated numeric or string value into the stream. More... | |
virtual void | pack_int64 (DCPackData &pack_data, int64_t value, bool &pack_error, bool &range_error) const |
Packs the indicated numeric or string value into the stream. More... | |
virtual void | pack_string (DCPackData &pack_data, const std::string &value, bool &pack_error, bool &range_error) const |
Packs the indicated numeric or string value into the stream. More... | |
virtual void | pack_uint (DCPackData &pack_data, unsigned int value, bool &pack_error, bool &range_error) const |
Packs the indicated numeric or string value into the stream. More... | |
virtual void | pack_uint64 (DCPackData &pack_data, uint64_t value, bool &pack_error, bool &range_error) const |
Packs the indicated numeric or string value into the stream. More... | |
virtual void | unpack_blob (const char *data, size_t length, size_t &p, vector_uchar &value, bool &pack_error, bool &range_error) const |
Unpacks the current numeric or string value from the stream. More... | |
virtual void | unpack_double (const char *data, size_t length, size_t &p, double &value, bool &pack_error, bool &range_error) const |
Unpacks the current numeric or string value from the stream. More... | |
virtual void | unpack_int (const char *data, size_t length, size_t &p, int &value, bool &pack_error, bool &range_error) const |
Unpacks the current numeric or string value from the stream. More... | |
virtual void | unpack_int64 (const char *data, size_t length, size_t &p, int64_t &value, bool &pack_error, bool &range_error) const |
Unpacks the current numeric or string value from the stream. More... | |
virtual bool | unpack_skip (const char *data, size_t length, size_t &p, bool &pack_error) const |
Increments p to the end of the current field without actually unpacking any data or performing any range validation. More... | |
virtual void | unpack_string (const char *data, size_t length, size_t &p, std::string &value, bool &pack_error, bool &range_error) const |
Unpacks the current numeric or string value from the stream. More... | |
virtual void | unpack_uint (const char *data, size_t length, size_t &p, unsigned int &value, bool &pack_error, bool &range_error) const |
Unpacks the current numeric or string value from the stream. More... | |
virtual void | unpack_uint64 (const char *data, size_t length, size_t &p, uint64_t &value, bool &pack_error, bool &range_error) const |
Unpacks the current numeric or string value from the stream. More... | |
virtual bool | unpack_validate (const char *data, size_t length, size_t &p, bool &pack_error, bool &range_error) const |
Internally unpacks the current numeric or string value and validates it against the type range limits, but does not return the value. More... | |
virtual bool | validate_num_nested_fields (int num_nested_fields) const |
After a number of fields have been packed via push() . More... | |
Public Member Functions inherited from DCKeywordList | |
DCKeywordList (const DCKeywordList ©) | |
bool | add_keyword (const DCKeyword *keyword) |
Adds the indicated keyword to the list. More... | |
void | clear_keywords () |
Removes all keywords from the field. More... | |
bool | compare_keywords (const DCKeywordList &other) const |
Returns true if this list has the same keywords as the other list, false if some keywords differ. More... | |
void | copy_keywords (const DCKeywordList &other) |
Replaces this keyword list with those from the other list. More... | |
void | generate_hash (HashGenerator &hashgen) const |
Accumulates the properties of these keywords into the hash. More... | |
const DCKeyword * | get_keyword (int n) const |
Returns the nth keyword in the list. More... | |
const DCKeyword * | get_keyword_by_name (const std::string &name) const |
Returns the keyword in the list with the indicated name, or NULL if there is no keyword in the list with that name. More... | |
int | get_num_keywords () const |
Returns the number of keywords in the list. More... | |
bool | has_keyword (const std::string &name) const |
Returns true if this list includes the indicated keyword, false otherwise. More... | |
bool | has_keyword (const DCKeyword *keyword) const |
Returns true if this list includes the indicated keyword, false otherwise. More... | |
void | operator= (const DCKeywordList ©) |
void | output_keywords (std::ostream &out) const |
Additional Inherited Members | |
Static Public Member Functions inherited from DCPackerInterface | |
static void | do_pack_float64 (char *buffer, double value) |
static void | do_pack_int16 (char *buffer, int value) |
static void | do_pack_int32 (char *buffer, int value) |
static void | do_pack_int64 (char *buffer, int64_t value) |
static void | do_pack_int8 (char *buffer, int value) |
static void | do_pack_uint16 (char *buffer, unsigned int value) |
static void | do_pack_uint32 (char *buffer, unsigned int value) |
static void | do_pack_uint64 (char *buffer, uint64_t value) |
static void | do_pack_uint8 (char *buffer, unsigned int value) |
static double | do_unpack_float64 (const char *buffer) |
static int | do_unpack_int16 (const char *buffer) |
static int | do_unpack_int32 (const char *buffer) |
static int64_t | do_unpack_int64 (const char *buffer) |
static int | do_unpack_int8 (const char *buffer) |
static unsigned int | do_unpack_uint16 (const char *buffer) |
static unsigned int | do_unpack_uint32 (const char *buffer) |
static uint64_t | do_unpack_uint64 (const char *buffer) |
static unsigned int | do_unpack_uint8 (const char *buffer) |
static void | validate_int64_limits (int64_t value, int num_bits, bool &range_error) |
Confirms that the signed value fits within num_bits bits. More... | |
static void | validate_int_limits (int value, int num_bits, bool &range_error) |
Confirms that the signed value fits within num_bits bits. More... | |
static void | validate_uint64_limits (uint64_t value, int num_bits, bool &range_error) |
Confirms that the unsigned value fits within num_bits bits. More... | |
static void | validate_uint_limits (unsigned int value, int num_bits, bool &range_error) |
Confirms that the unsigned value fits within num_bits bits. More... | |
A single field of a Distributed Class, either atomic or molecular.
|
virtual |
Returns the same field pointer converted to an atomic field pointer, if this is in fact an atomic field; otherwise, returns NULL.
Reimplemented in DCAtomicField.
Definition at line 112 of file dcField.cxx.
|
virtual |
Returns the same field pointer converted to an atomic field pointer, if this is in fact an atomic field; otherwise, returns NULL.
Reimplemented in DCAtomicField.
Definition at line 121 of file dcField.cxx.
|
virtual |
Returns the same field pointer converted to a molecular field pointer, if this is in fact a molecular field; otherwise, returns NULL.
Reimplemented in DCMolecularField.
Definition at line 130 of file dcField.cxx.
|
virtual |
Returns the same field pointer converted to a molecular field pointer, if this is in fact a molecular field; otherwise, returns NULL.
Reimplemented in DCMolecularField.
Definition at line 139 of file dcField.cxx.
string DCField::format_data | ( | const vector_uchar & | packed_data, |
bool | show_field_names = true |
||
) |
Given a blob that represents the packed data for this field, returns a string formatting it for human consumption.
Returns empty string if there is an error.
Definition at line 165 of file dcField.cxx.
References DCPacker::begin_unpack(), DCPacker::end_unpack(), DCPacker::set_unpack_data(), and DCPacker::unpack_and_format().
Referenced by DCSwitch::output_instance(), and DCSwitch::write_instance().
|
virtual |
Accumulates the properties of this field into the hash.
Reimplemented in DCSimpleParameter, DCParameter, DCAtomicField, DCArrayParameter, DCSwitchParameter, DCClassParameter, and DCMolecularField.
Definition at line 467 of file dcField.cxx.
References HashGenerator::add_string().
Referenced by DCMolecularField::generate_hash(), DCAtomicField::generate_hash(), and DCSwitch::generate_hash().
|
inline |
|
inline |
Returns the default value for this field.
If a default value has been explicitly set (e.g. has_default_value() returns true), returns that value; otherwise, returns an implicit default for the field.
|
inline |
|
inline |
Returns true if a default value has been explicitly established for this field, false otherwise.
Definition at line 36 of file dcField.I.
Referenced by DCAtomicField::add_element(), and DCSwitch::SwitchFields::add_field().
|
inline |
Returns true if the "airecv" flag is set for this field, false otherwise.
Definition at line 133 of file dcField.I.
References DCKeywordList::has_keyword().
|
inline |
Returns true if the field has been flagged as a bogus field.
This is set for fields that are generated by the parser as placeholder for missing fields, as when reading a partial file; it should not occur in a normal valid dc file.
Definition at line 60 of file dcField.I.
Referenced by DCMolecularField::add_atomic().
|
inline |
Returns true if the "broadcast" flag is set for this field, false otherwise.
Definition at line 77 of file dcField.I.
References DCKeywordList::has_keyword().
|
inline |
Returns true if the "clrecv" flag is set for this field, false otherwise.
Definition at line 109 of file dcField.I.
References DCKeywordList::has_keyword().
|
inline |
Returns true if the "clsend" flag is set for this field, false otherwise.
Definition at line 101 of file dcField.I.
References DCKeywordList::has_keyword().
|
inline |
Returns true if the "db" flag is set for this field, false otherwise.
Definition at line 93 of file dcField.I.
References DCKeywordList::has_keyword().
|
inline |
Returns true if the "ownrecv" flag is set for this field, false otherwise.
Definition at line 125 of file dcField.I.
References DCKeywordList::has_keyword().
|
inline |
Returns true if the "ownsend" flag is set for this field, false otherwise.
Definition at line 117 of file dcField.I.
References DCKeywordList::has_keyword().
|
inline |
Returns true if the "ram" flag is set for this field, false otherwise.
Definition at line 85 of file dcField.I.
References DCKeywordList::has_keyword().
|
inline |
Returns true if the "required" flag is set for this field, false otherwise.
Definition at line 68 of file dcField.I.
References DCKeywordList::has_keyword().
|
inline |
Write a string representation of this instance to <out>.
Definition at line 141 of file dcField.I.
Referenced by DCSwitch::output_instance(), and DCSwitch::write_instance().
|
virtual |
Packs the field's specified default value (or a sensible default if no value is specified) into the stream.
Returns true if the default value is packed, false if the field doesn't know how to pack its default value.
Reimplemented from DCPackerInterface.
Reimplemented in DCSimpleParameter, DCArrayParameter, and DCSwitchParameter.
Definition at line 487 of file dcField.cxx.
References DCPackData::append_data().
Referenced by DCSwitchParameter::pack_default_value(), DCArrayParameter::pack_default_value(), and DCSimpleParameter::pack_default_value().
vector_uchar DCField::parse_string | ( | const std::string & | formatted_string | ) |
Given a human-formatted string (for instance, as returned by format_data(), above) that represents the value of this field, parse the string and return the corresponding packed data.
Returns empty string if there is an error.
Definition at line 182 of file dcField.cxx.
References DCPacker::begin_pack(), DCPacker::end_pack(), DCPacker::get_bytes(), and DCPacker::parse_and_pack().
|
inline |
|
inline |
|
virtual |
Sets the name of this field.
Reimplemented from DCPackerInterface.
Definition at line 502 of file dcField.cxx.
References DCFile::mark_inherited_fields_stale(), and DCPackerInterface::set_name().
Referenced by DCTypedef::make_new_parameter().
|
inline |
Assigns the unique number to this field.
This is normally called only by the DCClass interface as the field is added.
Definition at line 158 of file dcField.I.
Referenced by DCFile::set_new_index_number().
bool DCField::validate_ranges | ( | const vector_uchar & | packed_data | ) | const |
Verifies that all of the packed values in the field data are within the specified ranges and that there are no extra bytes on the end of the record.
Returns true if all fields are valid, false otherwise.
Definition at line 203 of file dcField.cxx.
References DCPacker::begin_unpack(), DCPacker::end_unpack(), DCPacker::get_num_unpacked_bytes(), DCPacker::set_unpack_data(), and DCPacker::unpack_validate().
|
inline |