Utilities

class pstring

This string class does not have its own char array buffer; it only stores the memory position of the first char of an existing char array and its size. When using this class, it is important that the string object being referenced by an instance of this class will stay valid during its life time.

Public Functions

pstring()
pstring(const char *_pos)
pstring(const char *_pos, size_t _size)
pstring(const std::string &s)
std::string str() const
size_t size() const
const char &operator[](size_t idx) const
pstring &operator=(const pstring &r)
const char *get() const
const char *data() const
bool operator==(const pstring &r) const
bool operator!=(const pstring &r) const
bool operator<(const pstring &r) const
bool operator==(const char *_str) const
bool operator!=(const char *_str) const
pstring trim() const
bool empty() const
void clear()
void resize(size_t new_size)
struct hash

Public Functions

size_t operator()(const pstring &val) const
class string_pool

Implements string hash map.

Public Functions

string_pool(const string_pool&)
string_pool &operator=(const string_pool&)
string_pool()
~string_pool()
std::pair<pstring, bool> intern(const char *str)

Intern a string.

Return
pair whose first value is the interned string, and the second value specifies whether it is a newly created instance (true) or a reuse of an existing instance (false).
Parameters
  • str: string to intern. It must be null-terminated.

std::pair<pstring, bool> intern(const char *str, size_t n)

Intern a string.

Return
see above.
Parameters
  • str: string to intern. It doesn’t need to be null-terminated.
  • n: length of the string.

std::pair<pstring, bool> intern(const pstring &str)

Intern a string.

Return
see above.
Parameters
  • str: string to intern.

void dump() const
void clear()
size_t size() const
void swap(string_pool &other)
void merge(string_pool &other)

Merge another string pool instance in. This will not invalidate any string references to the other pool.

The other string pool instance will become empty when this call returns.

Parameters
  • other: string pool instance to merge in.

class tokens

Public Functions

tokens(const char **token_names, size_t token_name_count)
bool is_valid_token(xml_token_t token) const

Check if a token returned from get_token() method is valid.

Return
true if valid, false otherwise.

xml_token_t get_token(const pstring &name) const

Get token from a specified name.

Return
token value representing the given textural token.
Parameters
  • name: textural token name

const char *get_token_name(xml_token_t token) const

Get textural token name from a token value.

Return
textural token name, or empty string in case the given token is not valid.
Parameters
  • token: numeric token value

class cell_buffer

Temporary cell buffer used to convert cell values when needed. This is used in the sax and csv parsers.

Public Functions

cell_buffer()

Logical buffer size. May differ from the actual buffer size.

void append(const char *p, size_t len)
void reset()
const char *get() const
size_t size() const
bool empty() const
class zip_archive

Public Functions

zip_archive(zip_archive_stream *stream)
~zip_archive()
void load()

Loading involves the parsing of the central directory of a zip archive (located toward the end of the stream) and building of file entry data which are stored in the central directory.

void dump_file_entry(size_t index) const

Dump the content of a specified file entry to stdout.

Parameters
  • index: file entry index

void dump_file_entry(const char *entry_name) const

Dump the content of a specified file entry to stdout.

Parameters
  • entry_name: file entry name.

pstring get_file_entry_name(size_t index) const

Get file entry name from its index.

Return
file entry name
Parameters
  • index: file entry index

size_t get_file_entry_count() const

Return the number of file entries stored in this zip archive. Note that a file entry may be a directory, so the number of files stored in the zip archive may not equal the number of file entries.

Return
number of file entries.

bool read_file_entry(const pstring &entry_name, std::vector<unsigned char> &buf) const

Retrieve data stream of specified file entry into buffer. The retrieved data stream gets uncompressed if the original stream is compressed. The method will overwrite the content of passed buffer if there is any pre-existing data in it.

Return
true if successful, false otherwise.
Parameters
  • entry_name: file entry name
  • buf: buffer to put the retrieved data stream into.

XML Types

typedef size_t orcus::xml_token_t
typedef const char *orcus::xmlns_id_t
struct xml_name_t

Public Functions

xml_name_t()
xml_name_t(xmlns_id_t _ns, const pstring &_name)
xml_name_t(const xml_name_t &r)

Public Members

xmlns_id_t ns
pstring name
struct xml_token_attr_t

Public Functions

xml_token_attr_t()
xml_token_attr_t(xmlns_id_t _ns, xml_token_t _name, const pstring &_value, bool _transient)
xml_token_attr_t(xmlns_id_t _ns, xml_token_t _name, const pstring &_raw_name, const pstring &_value, bool _transient)

Public Members

xmlns_id_t ns
xml_token_t name
pstring raw_name
pstring value
bool transient

Whether or not the attribute value is transient. A transient value is only guaranteed to be valid until the end of the start_element call, after which its validity is not guaranteed. A non-transient value is guaranteed to be valid during the life cycle of the xml stream it belongs to.

Other Types

enum orcus::length_unit_t

Values:

unknown = 0
centimeter
millimeter
xlsx_column_digit
inch
point
twip
pixel
struct date_time_t

Public Functions

date_time_t()
date_time_t(int _year, int _month, int _day)
date_time_t(int _year, int _month, int _day, int _hour, int _minute, double _second)
date_time_t(const date_time_t &other)
~date_time_t()
date_time_t &operator=(date_time_t other)
bool operator==(const date_time_t &other) const
bool operator!=(const date_time_t &other) const
std::string to_string() const
void swap(date_time_t &other)

Public Members

int year
int month
int day
int hour
int minute
double second