From 39224b0142078376d2bd39789b4de24a18377cf0 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Thu, 27 Dec 2007 21:52:00 -0800 Subject: [PATCH] move Parser to FbTk --- src/FbMenuParser.cc | 12 ++++++------ src/FbMenuParser.hh | 8 ++++---- src/FbTk/Makefile.am | 2 +- src/{ => FbTk}/Parser.cc | 8 ++++---- src/{ => FbTk}/Parser.hh | 13 +++++++------ src/Makefile.am | 2 +- src/MenuCreator.cc | 16 ++++++++-------- 7 files changed, 31 insertions(+), 30 deletions(-) rename src/{ => FbTk}/Parser.cc (92%) rename src/{ => FbTk}/Parser.hh (92%) diff --git a/src/FbMenuParser.cc b/src/FbMenuParser.cc index d0f5e9bf..a5f52bdd 100644 --- a/src/FbMenuParser.cc +++ b/src/FbMenuParser.cc @@ -34,9 +34,9 @@ bool FbMenuParser::open(const std::string &filename) { return isLoaded(); } -Parser &FbMenuParser::operator >> (Parser::Item &out) { +FbTk::Parser &FbMenuParser::operator >> (FbTk::Parser::Item &out) { if (eof()) { - out = Parser::s_empty_item; + out = FbTk::Parser::s_empty_item; return *this; } @@ -65,7 +65,7 @@ Parser &FbMenuParser::operator >> (Parser::Item &out) { break; case DONE: // get new line and call this again if (!nextLine()) { - out = Parser::s_empty_item; + out = FbTk::Parser::s_empty_item; return *this; } return (*this)>>out; @@ -86,7 +86,7 @@ Parser &FbMenuParser::operator >> (Parser::Item &out) { else if (m_curr_token == ICON) m_curr_token = DONE; - out = Parser::s_empty_item; + out = FbTk::Parser::s_empty_item; return *this; } @@ -119,8 +119,8 @@ Parser &FbMenuParser::operator >> (Parser::Item &out) { return *this; } -Parser::Item FbMenuParser::nextItem() { - Parser::Item item; +FbTk::Parser::Item FbMenuParser::nextItem() { + FbTk::Parser::Item item; (*this)>>item; return item; } diff --git a/src/FbMenuParser.hh b/src/FbMenuParser.hh index 53bb1300..923347ee 100644 --- a/src/FbMenuParser.hh +++ b/src/FbMenuParser.hh @@ -25,11 +25,11 @@ #ifndef FBMENUPARSER_HH #define FBMENUPARSER_HH -#include "Parser.hh" +#include "FbTk/Parser.hh" #include -class FbMenuParser: public Parser { +class FbMenuParser: public FbTk::Parser { public: FbMenuParser():m_row(0), m_curr_pos(0), m_curr_token(TYPE) {} FbMenuParser(const std::string &filename):m_row(0), m_curr_pos(0), @@ -38,8 +38,8 @@ public: bool open(const std::string &filename); void close() { m_file.close(); } - Parser &operator >> (Parser::Item &out); - Parser::Item nextItem(); + FbTk::Parser &operator >> (FbTk::Parser::Item &out); + FbTk::Parser::Item nextItem(); bool isLoaded() const { return m_file.is_open(); } bool eof() const { return m_file.eof(); } diff --git a/src/FbTk/Makefile.am b/src/FbTk/Makefile.am index b3dd277f..86f85947 100644 --- a/src/FbTk/Makefile.am +++ b/src/FbTk/Makefile.am @@ -40,7 +40,7 @@ libFbTk_a_SOURCES = App.hh App.cc Color.cc Color.hh Command.hh \ Layer.hh LayerItem.hh MultLayers.cc MultLayers.hh \ XLayer.cc XLayer.hh XLayerItem.cc XLayerItem.hh \ Resource.hh Resource.cc \ - StringUtil.hh StringUtil.cc \ + StringUtil.hh StringUtil.cc Parser.hh Parser.cc \ FbString.hh FbString.cc \ Subject.hh Subject.cc Observer.hh Observer.cc \ Transparent.hh Transparent.cc \ diff --git a/src/Parser.cc b/src/FbTk/Parser.cc similarity index 92% rename from src/Parser.cc rename to src/FbTk/Parser.cc index 3461c0e7..9e08a538 100644 --- a/src/Parser.cc +++ b/src/FbTk/Parser.cc @@ -1,4 +1,4 @@ -// Parser.cc +// Parser.cc for FbTk // Copyright (c) 2004 - 2006 Fluxbox Team (fluxgen at fluxbox dot org) // // Permission is hereby granted, free of charge, to any person obtaining a @@ -19,8 +19,8 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id$ - #include "Parser.hh" -const Parser::Item Parser::s_empty_item("", ""); +namespace FbTk { + const Parser::Item Parser::s_empty_item("", ""); +}; diff --git a/src/Parser.hh b/src/FbTk/Parser.hh similarity index 92% rename from src/Parser.hh rename to src/FbTk/Parser.hh index 30f2a951..8415d4a8 100644 --- a/src/Parser.hh +++ b/src/FbTk/Parser.hh @@ -1,4 +1,4 @@ -// IconMenuItem.hh for Fluxbox Window Manager +// Parser.hh for FbTk // Copyright (c) 2004 Henrik Kinnunen (fluxgen at fluxbox dot org) // and Simon Bowden (rathnor at users.sourceforge.net) // @@ -20,14 +20,14 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id$ - -#ifndef PARSER_HH -#define PARSER_HH +#ifndef FBTK_PARSER_HH +#define FBTK_PARSER_HH #include #include +namespace FbTk { + // interface class for a generic Parser class Parser { public: @@ -47,5 +47,6 @@ public: }; +}; // end namespace FbTk -#endif // PARSER_HH +#endif // FBTK_PARSER_HH diff --git a/src/Makefile.am b/src/Makefile.am index d7ed54d8..dfed93b7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -122,7 +122,7 @@ fluxbox_SOURCES = AtomHandler.hh ArrowButton.hh ArrowButton.cc \ CommandDialog.hh CommandDialog.cc SendToMenu.hh SendToMenu.cc \ AlphaMenu.hh AlphaMenu.cc ObjectResource.hh \ CompareWindow.hh \ - Parser.hh Parser.cc FbMenuParser.hh FbMenuParser.cc \ + FbMenuParser.hh FbMenuParser.cc \ StyleMenuItem.hh StyleMenuItem.cc \ RootCmdMenuItem.hh RootCmdMenuItem.cc\ MenuCreator.hh MenuCreator.cc \ diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc index df6f829b..d68b6fdf 100644 --- a/src/MenuCreator.cc +++ b/src/MenuCreator.cc @@ -143,7 +143,7 @@ class ParseItem { public: explicit ParseItem(FbTk::Menu *menu):m_menu(menu) {} - inline void load(Parser &p, FbTk::StringConvertor &m_labelconvertor) { + inline void load(FbTk::Parser &p, FbTk::StringConvertor &m_labelconvertor) { p>>m_key>>m_label>>m_cmd>>m_icon; m_label.second = m_labelconvertor.recode(m_label.second); } @@ -153,7 +153,7 @@ public: inline const string &key() const { return m_key.second; } inline FbTk::Menu *menu() { return m_menu; } private: - Parser::Item m_key, m_label, m_cmd, m_icon; + FbTk::Parser::Item m_key, m_label, m_cmd, m_icon; FbTk::Menu *m_menu; }; @@ -172,10 +172,10 @@ public: }; -static void translateMenuItem(Parser &parse, ParseItem &item, FbTk::StringConvertor &labelconvertor); +static void translateMenuItem(FbTk::Parser &parse, ParseItem &item, FbTk::StringConvertor &labelconvertor); -static void parseMenu(Parser &pars, FbTk::Menu &menu, FbTk::StringConvertor &label_convertor) { +static void parseMenu(FbTk::Parser &pars, FbTk::Menu &menu, FbTk::StringConvertor &label_convertor) { ParseItem pitem(&menu); while (!pars.eof()) { pitem.load(pars, label_convertor); @@ -185,7 +185,7 @@ static void parseMenu(Parser &pars, FbTk::Menu &menu, FbTk::StringConvertor &lab } } -static void translateMenuItem(Parser &parse, ParseItem &pitem, FbTk::StringConvertor &labelconvertor) { +static void translateMenuItem(FbTk::Parser &parse, ParseItem &pitem, FbTk::StringConvertor &labelconvertor) { if (pitem.menu() == 0) throw string("translateMenuItem: We must have a menu in ParseItem!"); @@ -315,8 +315,8 @@ static void translateMenuItem(Parser &parse, ParseItem &pitem, FbTk::StringConve } else if (str_key == "endencoding") { MenuCreator::endEncoding(); } - else { // ok, if we didn't find any special menu item we try with command parser - // we need to attach command with arguments so command parser can parse it + else { // ok, if we didn't find any special menu item we try with command FbTk::Parser + // we need to attach command with arguments so command FbTk::Parser can parse it string line = str_key + " " + str_cmd; FbTk::RefCount command(FbTk::ObjectRegistry::instance().parse(line)); if (*command != 0) { @@ -341,7 +341,7 @@ static void translateMenuItem(Parser &parse, ParseItem &pitem, FbTk::StringConve } -static void parseWindowMenu(Parser &parse, FbTk::Menu &menu, FbTk::StringConvertor &labelconvertor) { +static void parseWindowMenu(FbTk::Parser &parse, FbTk::Menu &menu, FbTk::StringConvertor &labelconvertor) { ParseItem pitem(&menu); while (!parse.eof()) {