Tawara  0.1.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tawara::StringElement Class Reference

String primitive element. More...

#include <tawara/string_element.h>

Inheritance diagram for tawara::StringElement:
Inheritance graph
[legend]
Collaboration diagram for tawara::StringElement:
Collaboration graph
[legend]

Public Member Functions

 StringElement (uint32_t id, std::string value)
 Create a new string element with no default. More...
 
 StringElement (uint32_t id, std::string value, std::string default_value)
 Create a new string element with a default value. More...
 
virtual StringElementoperator= (std::string const &rhs)
 Value assignment operator. More...
 
virtual uint64_t padding () const
 Get the amount of padding used. More...
 
virtual void padding (uint64_t padding)
 Set the amount of padding to use. More...
 
virtual std::streamsize write_body (std::ostream &output)
 Element body writing. More...
 
- Public Member Functions inherited from tawara::PrimitiveElement< std::string >
 PrimitiveElement (uint32_t id, std::stringvalue)
 Create a new element with no default. More...
 
 PrimitiveElement (uint32_t id, std::stringvalue, std::stringdefault_value)
 Create a signed integer element with a default value. More...
 
virtual uint32_t id () const
 Get the element's ID. More...
 
virtual void id (uint32_t id)
 Set the element's ID. More...
 
virtual std::string value () const
 Get the value. More...
 
virtual void value (std::stringvalue)
 Set the value. More...
 
 operator std::string () const
 Cast to the stored type. More...
 
virtual bool has_default () const
 Check if a default value is set. More...
 
virtual std::string get_default () const
 Get the default value. More...
 
virtual void set_default (std::stringdefault_value)
 Set the default value. More...
 
virtual std::string remove_default ()
 Remove the default value. More...
 
virtual bool is_default () const
 Check if this element is at the default value. More...
 
- Public Member Functions inherited from tawara::Element
 Element (tawara::ids::ID id)
 Create a new Element. More...
 
virtual ~Element ()
 Destructor. More...
 
uint32_t id () const
 Get the element's ID. More...
 
std::streampos offset () const
 Get the element's offset in the byte stream. More...
 
virtual std::streamsize size () const
 Get the total size of the element. More...
 
virtual std::streamsize write (std::ostream &output)
 Element writing. More...
 
virtual std::streamsize read (std::istream &input)
 Element reading. More...
 

Protected Member Functions

virtual std::streamsize body_size () const
 Get the size of the body of this element. More...
 
virtual std::streamsize read_body (std::istream &input, std::streamsize size)
 Element body loading. More...
 
- Protected Member Functions inherited from tawara::PrimitiveElement< std::string >
virtual bool equal_ (PrimitiveElement< std::string > const &rhs)
 
- Protected Member Functions inherited from tawara::Element
std::streamsize write_id (std::ostream &output)
 Element ID writing. More...
 
virtual std::streamsize write_size (std::ostream &output)
 Element size writing. More...
 

Protected Attributes

uint64_t padding_
 
- Protected Attributes inherited from tawara::PrimitiveElement< std::string >
std::string value_
 
std::string default_
 
bool has_default_
 
- Protected Attributes inherited from tawara::Element
tawara::ids::ID id_
 
std::streampos offset_
 

Detailed Description

String primitive element.

This element stores a UTF-8 string. Upon writing to a store, the string may or may not be padded with null bytes.

Definition at line 57 of file string_element.h.

Constructor & Destructor Documentation

tawara::StringElement::StringElement ( uint32_t  id,
std::string  value 
)

Create a new string element with no default.

Parameters
[in]idThe element's ID, as an unsigned integer up to 28 bits.
[in]valueThe element's value.
tawara::StringElement::StringElement ( uint32_t  id,
std::string  value,
std::string  default_value 
)

Create a new string element with a default value.

Parameters
[in]idThe element's ID, as an unsigned integer up to 28 bits.
[in]valueThe element's value.
[in]default_valueThe default value of the element.

Member Function Documentation

virtual std::streamsize tawara::StringElement::body_size ( ) const
protectedvirtual

Get the size of the body of this element.

Implements tawara::Element.

virtual StringElement& tawara::StringElement::operator= ( std::string const &  rhs)
virtual

Value assignment operator.

Reimplemented from tawara::PrimitiveElement< std::string >.

virtual uint64_t tawara::StringElement::padding ( ) const
inlinevirtual

Get the amount of padding used.

Definition at line 82 of file string_element.h.

virtual void tawara::StringElement::padding ( uint64_t  padding)
inlinevirtual

Set the amount of padding to use.

Strings can be zero-padded at the end. This is particularly useful when overwriting an existing string with one that is shorter, so that the file does not need to be rewritten or a void element used.

Management of this value is the responsibility of the user of the StringElement. It will never be adjusted automatically.

Definition at line 93 of file string_element.h.

virtual std::streamsize tawara::StringElement::read_body ( std::istream &  input,
std::streamsize  size 
)
protectedvirtual

Element body loading.

Implements tawara::Element.

virtual std::streamsize tawara::StringElement::write_body ( std::ostream &  output)
virtual

Element body writing.

Implements tawara::Element.

Member Data Documentation

uint64_t tawara::StringElement::padding_
protected

Definition at line 99 of file string_element.h.


The documentation for this class was generated from the following file: