From 65c6e5bed3996d5cefdfa6c325533edc0da1fcf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Fri, 29 Jun 2001 06:40:08 +0000 Subject: [PATCH] variables.diff git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2157 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 4 ++++ src/Variables.C | 52 ++++++++++++++++++++++++------------------------- src/Variables.h | 24 +++++++++++------------ 3 files changed, 42 insertions(+), 38 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index e4a9f34bec..5cd39f00fa 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2001-06-29 John Levon + + * Variables.[Ch]: fix indentation, rename set to isSet + 2001-06-29 Lars Gullik Bjønnes * lyxfunc.C (Dispatch): fix typo diff --git a/src/Variables.C b/src/Variables.C index dd178f29d1..25e3c44539 100644 --- a/src/Variables.C +++ b/src/Variables.C @@ -30,40 +30,40 @@ void Variables::set(string const & var, string const & val) string const Variables::get(string const & var) const { - Vars::const_iterator cit = vars_.find(var); - if (cit != vars_.end()) - return (*cit).second; - else - return string(); + Vars::const_iterator cit = vars_.find(var); + if (cit != vars_.end()) + return (*cit).second; + else + return string(); } -bool Variables::set(string const & var) const +bool Variables::isSet(string const & var) const { - Vars::const_iterator cit = vars_.find(var); - return (cit != vars_.end()); + Vars::const_iterator cit = vars_.find(var); + return (cit != vars_.end()); } string const Variables::expand(string const & s) const { - string str(s); - LRegex reg("\\$\\{\\(.*\\)\\}"); + string str(s); + LRegex reg("\\$\\{\\(.*\\)\\}"); - if (!reg.exact_match(str)) - return str; + if (!reg.exact_match(str)) + return str; - LRegex::MatchPair match; - string var; - - do { - match = reg.first_match(str); - var = str.substr(match.first,match.second); - // we correct the match to take ${} in account. - str.replace(match.first - 2, match.second + 3, get(var)); - } while (reg.exact_match(str)); + LRegex::MatchPair match; + string var; - return str; + do { + match = reg.first_match(str); + var = str.substr(match.first,match.second); + // we correct the match to take ${} in account. + str.replace(match.first - 2, match.second + 3, get(var)); + } while (reg.exact_match(str)); + + return str; } #ifdef TEST @@ -73,10 +73,10 @@ using std::endl; using std::cout; int main() { - Variables vars; - vars.set("x", "hello"); - vars.set("y", "world"); - cout << vars.expand("${x}") << endl; + Variables vars; + vars.set("x", "hello"); + vars.set("y", "world"); + cout << vars.expand("${x}") << endl; } #endif diff --git a/src/Variables.h b/src/Variables.h index 89b3884955..c7c092a5c0 100644 --- a/src/Variables.h +++ b/src/Variables.h @@ -23,19 +23,19 @@ /// class Variables { public: - /// - void set(string const &, string const &); - /// - string const get(string const &) const; - /// - bool set(string const & var) const; - /// - string const expand(string const &) const; + /// + void set(string const &, string const &); + /// + string const get(string const &) const; + /// + bool isSet(string const & var) const; + /// + string const expand(string const &) const; private: - /// - typedef std::map Vars; - /// - Vars vars_; + /// + typedef std::map Vars; + /// + Vars vars_; }; #endif