Template Struct FieldBase< std::string >

Inheritance Relationships

Derived Type

Struct Documentation

template<>
struct FieldBase<std::string>

Field base class specialization for strings.

Subclassed by lsst::afw::table::Key< std::string >

Public Types

typedef std::string Value

the type returned by BaseRecord::get

typedef char *Reference

the type returned by BaseRecord::operator[]

typedef char const *ConstReference

the type returned by BaseRecord::operator[] (const)

typedef char Element

the type of subfields and array elements

Public Functions

FieldBase(int size = -1)

Construct a FieldBase with the given size.

A size == 0 indicates a variable-length string. Negative sizes are not permitted.

This constructor is implicit and has an invalid default so it can be used in the Field constructor (as if it were an int argument) without specializing Field. In other words, it allows one to construct a 25-character string field like this:

Field< std::string >("name", "documentation", 25);

…even though the third argument to the Field constructor takes a FieldBase, not an int.

FieldBase(FieldBase const&)
FieldBase(FieldBase&&)
FieldBase &operator=(FieldBase const&)
FieldBase &operator=(FieldBase&&)
~FieldBase()
int getElementCount() const

Return the number of subfield elements (equal to the size of the string, including a null terminator), or 0 for a variable-length string.

int getSize() const

Return the maximum length of the string, including a null terminator (equal to the number of subfield elements), or 0 for a variable-length string.

bool isVariableLength() const

Return true if the field is variable-length (each record can have a different size array).

Public Static Functions

static std::string getTypeString()

Return a string description of the field type.

Protected Functions

void stream(std::ostream &os) const

Defines how Fields are printed.

Reference getReference(Element *p, ndarray::Manager::Ptr const &m) const

Used to implement BaseRecord::operator[] (non-const).

ConstReference getConstReference(Element const *p, ndarray::Manager::Ptr const &m) const

Used to implement BaseRecord::operator[] (const).

Value getValue(Element const *p, ndarray::Manager::Ptr const &m) const

Used to implement BaseRecord::get.

void setValue(Element *p, ndarray::Manager::Ptr const&, std::string const &value) const

Used to implement BaseRecord::set Fixed-lengths strings are handled by copying the data into p through p + _size, nulling extra characters, if any. The data is only null-terminated if value.size() < _size. Variable-length strings are handled by setting p to the address of a std::string that is a copy of value

Protected Static Functions

static FieldBase makeDefault()

Needed to allow Keys to be default-constructed.