summaryrefslogtreecommitdiff
path: root/xml.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-04-20 02:14:53 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:38:28 -0400
commitb84f676946941df6f7e8476d77d1db0cbe7736c5 (patch)
tree9ee7c7a2d3b7496b38ad127519210adfeced2241 /xml.h
parent539370ff1b37772e9f11439f652ffd3583beeedb (diff)
downloadledger-b84f676946941df6f7e8476d77d1db0cbe7736c5.tar.gz
ledger-b84f676946941df6f7e8476d77d1db0cbe7736c5.tar.bz2
ledger-b84f676946941df6f7e8476d77d1db0cbe7736c5.zip
Did some optimization and memory cleanup
Diffstat (limited to 'xml.h')
-rw-r--r--xml.h36
1 files changed, 20 insertions, 16 deletions
diff --git a/xml.h b/xml.h
index 09b3180e..108a383b 100644
--- a/xml.h
+++ b/xml.h
@@ -28,12 +28,12 @@ class document_t
const char ** builtins;
const int builtins_size;
- typedef std::deque<std::string> names_array;
+ typedef std::deque<string> names_array;
names_array names;
- typedef std::map<std::string, int> names_map;
- typedef std::pair<std::string, int> names_pair;
+ typedef std::map<string, int> names_map;
+ typedef std::pair<string, int> names_pair;
names_map names_index;
@@ -48,11 +48,12 @@ class document_t
document_t(node_t * _top = NULL, const char ** _builtins = NULL,
const int _builtins_size = 0);
+ ~document_t();
void set_top(node_t * _top);
- int register_name(const std::string& name);
- int lookup_name_id(const std::string& name) const;
+ int register_name(const string& name);
+ int lookup_name_id(const string& name) const;
const char * lookup_name(int id) const;
void write(std::ostream& out) const;
@@ -62,7 +63,7 @@ class document_t
class conversion_error : public error {
public:
- conversion_error(const std::string& _reason,
+ conversion_error(const string& _reason,
error_context * _ctxt = NULL) throw()
: error(_reason, _ctxt) {}
virtual ~conversion_error() throw() {}
@@ -85,8 +86,8 @@ public:
unsigned int flags;
void * info;
- typedef std::map<std::string, std::string> attrs_map;
- typedef std::pair<std::string, std::string> attrs_pair;
+ typedef std::map<string, string> attrs_map;
+ typedef std::pair<string, string> attrs_pair;
attrs_map * attrs;
@@ -138,11 +139,11 @@ public:
int id = document->lookup_name_id(_name);
return lookup_child(id);
}
- node_t * lookup_child(const std::string& _name) {
+ node_t * lookup_child(const string& _name) {
int id = document->lookup_name_id(_name);
return lookup_child(id);
}
- virtual node_t * lookup_child(int _name_id) {
+ virtual node_t * lookup_child(int /* _name_id */) {
return NULL;
}
@@ -194,7 +195,7 @@ private:
class terminal_node_t : public node_t
{
- std::string data;
+ string data;
public:
terminal_node_t(document_t * _document, parent_node_t * _parent = NULL)
@@ -202,6 +203,9 @@ public:
{
TRACE_CTOR("terminal_node_t(document_t *, parent_node_t *)");
}
+ virtual ~terminal_node_t() {
+ TRACE_DTOR("terminal_node_t");
+ }
virtual const char * text() const {
return data.c_str();
@@ -209,7 +213,7 @@ public:
virtual void set_text(const char * _data) {
data = _data;
}
- virtual void set_text(const std::string& _data) {
+ virtual void set_text(const string& _data) {
data = _data;
}
@@ -231,7 +235,7 @@ class parser_t
public:
document_t * document;
XML_Parser parser;
- std::string have_error;
+ string have_error;
const char * pending;
node_t::attrs_map * pending_attrs;
bool handled_data;
@@ -250,7 +254,7 @@ class parser_t
class parse_error : public error {
public:
- parse_error(const std::string& _reason,
+ parse_error(const string& _reason,
error_context * _ctxt = NULL) throw()
: error(_reason, _ctxt) {}
virtual ~parse_error() throw() {}
@@ -311,8 +315,8 @@ public:
transaction_node_t(document_t * _document,
transaction_t * _transaction,
parent_node_t * _parent = NULL)
- : parent_node_t(_document, _parent), transaction(_transaction),
- payee_virtual_node(NULL) {
+ : parent_node_t(_document, _parent), payee_virtual_node(NULL),
+ transaction(_transaction) {
TRACE_CTOR("transaction_node_t(document_t *, transaction_t *, parent_node_t *)");
set_name("transaction");
payee_id = document->register_name("payee");