MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
utils::Properties Class Reference

#include <Properties.hpp>

Inheritance diagram for utils::Properties:
Collaboration diagram for utils::Properties:

Public Member Functions

void load (const char *filename) throw (ios_base::failure)
void load (istream &is) throw (ios_base::failure)
void load (streambuf &ib) throw (ios_base::failure)
void store (const char *filename, const wstring *header=NULL) const throw (ios_base::failure)
void store (ostream &os, const wstring *header=NULL) const throw (ios_base::failure)
void store (streambuf &ob, const wstring *header=NULL) const throw (ios_base::failure)

Static Protected Member Functions

static bool isWS (int c)
static bool isNL (int c)
static bool isComment (int c)
static bool isAssign (int c)
static bool isKeyTerminator (int c)
static bool isEsc (int c)
static void skipWS (streambuf &ib)
static void skipComment (streambuf &ib)
static void readIgnored (streambuf &ib)
static void readEsc (wstring &s, streambuf &ib)
static void readKey (wstring &s, streambuf &ib)
static void readValue (wstring &s, streambuf &ib)
static bool isPrintableAscii (wchar_t c)
static void writeAsciiEsc (streambuf &os, wchar_t c)
static void writeUnicodeEsc (streambuf &os, wchar_t c)
static void writeKey (streambuf &os, const wstring &s)
static void writeValue (streambuf &os, const wstring &s)
static void writeChar (streambuf &os, char c)

Detailed Description

The Properties class is a specialized map container that stores elements composed of a key string and a corresponding value string.

This class offers load/store functions to read properties from or save them to a std::streambuf, stream, or file. The format for reading and writing properties is the same used by Java Properties: http://java.sun.com/javase/6/docs/api/java/util/Properties.html http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html http://java.sun.com/j2se/1.4.2/docs/api/java/util/Properties.html

This implementation supports non-Ascii characters but assumes: ... XXX ...

This class derives publicly from std::map. Generally, this would be problematic, since std::map does not seem to provide a virtual destructor (at least, GNU's Standard C++ Library v3 does not). In other words, without a virtual destructor, std::map does not support derived types whose instances can also pass as std::maps.

Under this limitation, the best approach would be for Properties to derive privately (or protectedly) from std::map only, so that Properties instances are not exposed to being deleted through a std::map base pointer. As a consequence, this requires to publicly redeclare most of the std::map members (e.g. "using std::map<std::wstring,std::wstring>::operator[];").

However, class Properties is lucky, though, in that it does not declare any data members and destructor, for it conceptually posesses no state apart from the inherited std::map for the key, value mapping. It is therefore unproblematic if a Properties instance is deleted through its base pointer.

Nevertheless, any classes publicly derived from Properties would have to reconsider the lack of a virtual destuctor in std::map.

Definition at line 85 of file Properties.hpp.

Member Function Documentation

bool Properties::isWS ( int  c)
inlinestaticprotected

Writes this property table to the wide character output stream. Writes this property table to the wide character buffer.

The format is suitable for reading the properties using the load function. The stream is written using the UTF-32/UCS-4 character encoding, and characters of the key and value strings are not rendered as an escape sequence.

If the header argument is not null, then an ASCII # character, the header string, and a line separator are first written to the output stream. Thus, the header can serve as an identifying comment.

Definition at line 255 of file Properties.hpp.

void Properties::load ( const char *  filename) throw (ios_base::failure)
inline

Reads properties from the character file and adds them to this property table.

Definition at line 572 of file Properties.hpp.

void Properties::load ( istream &  is) throw (ios_base::failure)
inline

Reads properties from the character input stream and adds them to this property table.

Definition at line 585 of file Properties.hpp.

void Properties::load ( streambuf &  ib) throw (ios_base::failure)
inline

Reads properties from the character buffer and adds them to this property table.

The line-oriented format is the same as used by Java Properties. The byte stream is read under the ISO 8859-1 character encoding, so, all non-ISO 8859-1 characters of the key and value strings need to be expressed as an escape sequence.

Definition at line 597 of file Properties.hpp.

void Properties::store ( const char *  filename,
const wstring *  header = NULL 
) const throw (ios_base::failure)
inline

Reads properties from the wide character input stream and adds them to this property table. Reads properties from the wide character buffer and adds them to this property table.

The byte stream is read under the UTF-32/UCS-4 character encoding, and characters of the key and value strings are not parsed as an escape sequence. Writes this property table to the character file.

Definition at line 617 of file Properties.hpp.

void Properties::store ( ostream &  os,
const wstring *  header = NULL 
) const throw (ios_base::failure)
inline

Writes this property table to the character output stream.

Definition at line 630 of file Properties.hpp.

void Properties::store ( streambuf &  ob,
const wstring *  header = NULL 
) const throw (ios_base::failure)
inline

Writes this property table to the character buffer.

The format is suitable for reading the properties using the load function. The stream is written using the ISO 8859-1 character encoding and characters of the key and value strings are examined to see whether they should be rendered as an escape sequence.

If the header argument is not null, then an ASCII # character, the header string, and a line separator are first written to the output stream. Thus, the header can serve as an identifying comment.

Definition at line 642 of file Properties.hpp.


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