From 97c44eced460777a1d83f2ced653bd2a198eaba8 Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Mon, 11 May 2009 14:04:16 +0000 Subject: [PATCH] push and pop functions; making assert... functions visible git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1378 8eb893ce-cfd4-0310-b710-fb5ebe64c474 --- core/AmArg.cpp | 11 +++++++++++ core/AmArg.h | 19 ++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/core/AmArg.cpp b/core/AmArg.cpp index 4a0ae3aa..fed45e33 100644 --- a/core/AmArg.cpp +++ b/core/AmArg.cpp @@ -170,6 +170,17 @@ void AmArg::push(const AmArg& a) { v_array->push_back(a); } +void AmArg::push(const string &key, const AmArg &val) { + assertStruct(); + (*v_struct)[key] = val; +} + +void AmArg::pop(AmArg &a) { + assertArray(); + a = v_array->front(); + v_array->erase(v_array->begin()); +} + void AmArg::concat(const AmArg& a) { assertArray(); if (a.getType() == Array) { diff --git a/core/AmArg.h b/core/AmArg.h index 6d64d4ee..975c99a4 100644 --- a/core/AmArg.h +++ b/core/AmArg.h @@ -122,11 +122,6 @@ class AmArg void invalidate(); public: - void assertArray(); - void assertArray() const; - - void assertStruct(); - void assertStruct() const; AmArg() : type(Undef) @@ -150,6 +145,12 @@ class AmArg v_cstr = strdup(v); } + AmArg(const string &v) + : type(CStr) + { + v_cstr = strdup(v.c_str()); + } + AmArg(const ArgBlob v) : type(Blob) { @@ -165,6 +166,12 @@ class AmArg ~AmArg() { invalidate(); } + void assertArray(); + void assertArray() const; + + void assertStruct(); + void assertStruct() const; + short getType() const { return type; } AmArg& operator=(const AmArg& rhs); @@ -227,6 +234,8 @@ class AmArg void assertArray(size_t s); void push(const AmArg& a); + void push(const string &key, const AmArg &val); + void pop(AmArg &a); void concat(const AmArg& a);