From 6c27b9b4024331558e6a719293f2b44a6ae77c28 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 7 Mar 2008 23:12:59 +0000 Subject: Minor updates to MiniMacro --- src/minimacro.cpp | 15 ++++++++++++++- src/minimacro.h | 6 ++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/minimacro.cpp b/src/minimacro.cpp index 3e69fe4..c6a868f 100644 --- a/src/minimacro.cpp +++ b/src/minimacro.cpp @@ -14,6 +14,14 @@ Bu::MiniMacro::MiniMacro() hFuncs.insert("tolower", new FuncToLower() ); } +Bu::MiniMacro::MiniMacro( const StrHash &sVarSrc ) +{ + for( StrHash::const_iterator i = sVarSrc.begin(); i != sVarSrc.end(); i++ ) + { + addVar( i.getKey(), i.getValue() ); + } +} + Bu::MiniMacro::~MiniMacro() { } @@ -163,11 +171,16 @@ bool Bu::MiniMacro::hasVar( const Bu::FString &sName ) return hVars.has( sName ); } -const Bu::FString &Bu::MiniMacro::getvar( const Bu::FString &sName ) +const Bu::FString &Bu::MiniMacro::getVar( const Bu::FString &sName ) { return hVars.get( sName ); } +const Bu::StrHash &Bu::MiniMacro::getVars() +{ + return hVars; +} + int Bu::MiniMacro::getPosition() { return iLastPos; diff --git a/src/minimacro.h b/src/minimacro.h index 7aed912..45a8555 100644 --- a/src/minimacro.h +++ b/src/minimacro.h @@ -13,6 +13,7 @@ namespace Bu { + typedef Bu::Hash StrHash; /** * A processor for Libbu++ brand Mini Macros. These are really simple, but * still fairly flexible. It's mainly text replacement, but with a few @@ -59,17 +60,18 @@ namespace Bu {?name="bob":"You're named bob!":"Who are you? I only know bob..."} @endverbatim */ - typedef Bu::Hash StrHash; class MiniMacro { public: MiniMacro(); + MiniMacro( const StrHash &sVarSrc ); virtual ~MiniMacro(); Bu::FString parse( const Bu::FString &sIn ); void addVar( const Bu::FString &sName, const Bu::FString &sValue ); bool hasVar( const Bu::FString &sName ); - const Bu::FString &getvar( const Bu::FString &sName ); + const Bu::FString &getVar( const Bu::FString &sName ); + const StrHash &getVars(); int getPosition(); private: -- cgit v1.2.3