diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2007-12-28 05:52:00 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2007-12-28 05:52:00 (GMT) |
commit | 39224b0142078376d2bd39789b4de24a18377cf0 (patch) | |
tree | 874755d12b5f0ae395ebc3eae29697237667cd31 | |
parent | e8a2f155e8d5a082a8c04f291e65c137c20a05cb (diff) | |
download | fluxbox_paul-39224b0142078376d2bd39789b4de24a18377cf0.zip fluxbox_paul-39224b0142078376d2bd39789b4de24a18377cf0.tar.bz2 |
move Parser to FbTk
-rw-r--r-- | src/FbMenuParser.cc | 12 | ||||
-rw-r--r-- | src/FbMenuParser.hh | 8 | ||||
-rw-r--r-- | src/FbTk/Makefile.am | 2 | ||||
-rw-r--r-- | src/FbTk/Parser.cc (renamed from src/Parser.cc) | 8 | ||||
-rw-r--r-- | src/FbTk/Parser.hh (renamed from src/Parser.hh) | 13 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/MenuCreator.cc | 16 |
7 files changed, 31 insertions, 30 deletions
diff --git a/src/FbMenuParser.cc b/src/FbMenuParser.cc index d0f5e9b..a5f52bd 100644 --- a/src/FbMenuParser.cc +++ b/src/FbMenuParser.cc | |||
@@ -34,9 +34,9 @@ bool FbMenuParser::open(const std::string &filename) { | |||
34 | return isLoaded(); | 34 | return isLoaded(); |
35 | } | 35 | } |
36 | 36 | ||
37 | Parser &FbMenuParser::operator >> (Parser::Item &out) { | 37 | FbTk::Parser &FbMenuParser::operator >> (FbTk::Parser::Item &out) { |
38 | if (eof()) { | 38 | if (eof()) { |
39 | out = Parser::s_empty_item; | 39 | out = FbTk::Parser::s_empty_item; |
40 | return *this; | 40 | return *this; |
41 | } | 41 | } |
42 | 42 | ||
@@ -65,7 +65,7 @@ Parser &FbMenuParser::operator >> (Parser::Item &out) { | |||
65 | break; | 65 | break; |
66 | case DONE: // get new line and call this again | 66 | case DONE: // get new line and call this again |
67 | if (!nextLine()) { | 67 | if (!nextLine()) { |
68 | out = Parser::s_empty_item; | 68 | out = FbTk::Parser::s_empty_item; |
69 | return *this; | 69 | return *this; |
70 | } | 70 | } |
71 | return (*this)>>out; | 71 | return (*this)>>out; |
@@ -86,7 +86,7 @@ Parser &FbMenuParser::operator >> (Parser::Item &out) { | |||
86 | else if (m_curr_token == ICON) | 86 | else if (m_curr_token == ICON) |
87 | m_curr_token = DONE; | 87 | m_curr_token = DONE; |
88 | 88 | ||
89 | out = Parser::s_empty_item; | 89 | out = FbTk::Parser::s_empty_item; |
90 | return *this; | 90 | return *this; |
91 | } | 91 | } |
92 | 92 | ||
@@ -119,8 +119,8 @@ Parser &FbMenuParser::operator >> (Parser::Item &out) { | |||
119 | return *this; | 119 | return *this; |
120 | } | 120 | } |
121 | 121 | ||
122 | Parser::Item FbMenuParser::nextItem() { | 122 | FbTk::Parser::Item FbMenuParser::nextItem() { |
123 | Parser::Item item; | 123 | FbTk::Parser::Item item; |
124 | (*this)>>item; | 124 | (*this)>>item; |
125 | return item; | 125 | return item; |
126 | } | 126 | } |
diff --git a/src/FbMenuParser.hh b/src/FbMenuParser.hh index 53bb130..923347e 100644 --- a/src/FbMenuParser.hh +++ b/src/FbMenuParser.hh | |||
@@ -25,11 +25,11 @@ | |||
25 | #ifndef FBMENUPARSER_HH | 25 | #ifndef FBMENUPARSER_HH |
26 | #define FBMENUPARSER_HH | 26 | #define FBMENUPARSER_HH |
27 | 27 | ||
28 | #include "Parser.hh" | 28 | #include "FbTk/Parser.hh" |
29 | 29 | ||
30 | #include <fstream> | 30 | #include <fstream> |
31 | 31 | ||
32 | class FbMenuParser: public Parser { | 32 | class FbMenuParser: public FbTk::Parser { |
33 | public: | 33 | public: |
34 | FbMenuParser():m_row(0), m_curr_pos(0), m_curr_token(TYPE) {} | 34 | FbMenuParser():m_row(0), m_curr_pos(0), m_curr_token(TYPE) {} |
35 | FbMenuParser(const std::string &filename):m_row(0), m_curr_pos(0), | 35 | FbMenuParser(const std::string &filename):m_row(0), m_curr_pos(0), |
@@ -38,8 +38,8 @@ public: | |||
38 | 38 | ||
39 | bool open(const std::string &filename); | 39 | bool open(const std::string &filename); |
40 | void close() { m_file.close(); } | 40 | void close() { m_file.close(); } |
41 | Parser &operator >> (Parser::Item &out); | 41 | FbTk::Parser &operator >> (FbTk::Parser::Item &out); |
42 | Parser::Item nextItem(); | 42 | FbTk::Parser::Item nextItem(); |
43 | 43 | ||
44 | bool isLoaded() const { return m_file.is_open(); } | 44 | bool isLoaded() const { return m_file.is_open(); } |
45 | bool eof() const { return m_file.eof(); } | 45 | bool eof() const { return m_file.eof(); } |
diff --git a/src/FbTk/Makefile.am b/src/FbTk/Makefile.am index b3dd277..86f8594 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 \ | |||
40 | Layer.hh LayerItem.hh MultLayers.cc MultLayers.hh \ | 40 | Layer.hh LayerItem.hh MultLayers.cc MultLayers.hh \ |
41 | XLayer.cc XLayer.hh XLayerItem.cc XLayerItem.hh \ | 41 | XLayer.cc XLayer.hh XLayerItem.cc XLayerItem.hh \ |
42 | Resource.hh Resource.cc \ | 42 | Resource.hh Resource.cc \ |
43 | StringUtil.hh StringUtil.cc \ | 43 | StringUtil.hh StringUtil.cc Parser.hh Parser.cc \ |
44 | FbString.hh FbString.cc \ | 44 | FbString.hh FbString.cc \ |
45 | Subject.hh Subject.cc Observer.hh Observer.cc \ | 45 | Subject.hh Subject.cc Observer.hh Observer.cc \ |
46 | Transparent.hh Transparent.cc \ | 46 | Transparent.hh Transparent.cc \ |
diff --git a/src/Parser.cc b/src/FbTk/Parser.cc index 3461c0e..9e08a53 100644 --- a/src/Parser.cc +++ b/src/FbTk/Parser.cc | |||
@@ -1,4 +1,4 @@ | |||
1 | // Parser.cc | 1 | // Parser.cc for FbTk |
2 | // Copyright (c) 2004 - 2006 Fluxbox Team (fluxgen at fluxbox dot org) | 2 | // Copyright (c) 2004 - 2006 Fluxbox Team (fluxgen at fluxbox dot org) |
3 | // | 3 | // |
4 | // Permission is hereby granted, free of charge, to any person obtaining a | 4 | // Permission is hereby granted, free of charge, to any person obtaining a |
@@ -19,8 +19,8 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // $Id$ | ||
23 | |||
24 | #include "Parser.hh" | 22 | #include "Parser.hh" |
25 | 23 | ||
26 | const Parser::Item Parser::s_empty_item("", ""); | 24 | namespace FbTk { |
25 | const Parser::Item Parser::s_empty_item("", ""); | ||
26 | }; | ||
diff --git a/src/Parser.hh b/src/FbTk/Parser.hh index 30f2a95..8415d4a 100644 --- a/src/Parser.hh +++ b/src/FbTk/Parser.hh | |||
@@ -1,4 +1,4 @@ | |||
1 | // IconMenuItem.hh for Fluxbox Window Manager | 1 | // Parser.hh for FbTk |
2 | // Copyright (c) 2004 Henrik Kinnunen (fluxgen at fluxbox dot org) | 2 | // Copyright (c) 2004 Henrik Kinnunen (fluxgen at fluxbox dot org) |
3 | // and Simon Bowden (rathnor at users.sourceforge.net) | 3 | // and Simon Bowden (rathnor at users.sourceforge.net) |
4 | // | 4 | // |
@@ -20,14 +20,14 @@ | |||
20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
21 | // DEALINGS IN THE SOFTWARE. | 21 | // DEALINGS IN THE SOFTWARE. |
22 | 22 | ||
23 | // $Id$ | 23 | #ifndef FBTK_PARSER_HH |
24 | 24 | #define FBTK_PARSER_HH | |
25 | #ifndef PARSER_HH | ||
26 | #define PARSER_HH | ||
27 | 25 | ||
28 | #include <string> | 26 | #include <string> |
29 | #include <utility> | 27 | #include <utility> |
30 | 28 | ||
29 | namespace FbTk { | ||
30 | |||
31 | // interface class for a generic Parser | 31 | // interface class for a generic Parser |
32 | class Parser { | 32 | class Parser { |
33 | public: | 33 | public: |
@@ -47,5 +47,6 @@ public: | |||
47 | 47 | ||
48 | }; | 48 | }; |
49 | 49 | ||
50 | }; // end namespace FbTk | ||
50 | 51 | ||
51 | #endif // PARSER_HH | 52 | #endif // FBTK_PARSER_HH |
diff --git a/src/Makefile.am b/src/Makefile.am index d7ed54d..dfed93b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -122,7 +122,7 @@ fluxbox_SOURCES = AtomHandler.hh ArrowButton.hh ArrowButton.cc \ | |||
122 | CommandDialog.hh CommandDialog.cc SendToMenu.hh SendToMenu.cc \ | 122 | CommandDialog.hh CommandDialog.cc SendToMenu.hh SendToMenu.cc \ |
123 | AlphaMenu.hh AlphaMenu.cc ObjectResource.hh \ | 123 | AlphaMenu.hh AlphaMenu.cc ObjectResource.hh \ |
124 | CompareWindow.hh \ | 124 | CompareWindow.hh \ |
125 | Parser.hh Parser.cc FbMenuParser.hh FbMenuParser.cc \ | 125 | FbMenuParser.hh FbMenuParser.cc \ |
126 | StyleMenuItem.hh StyleMenuItem.cc \ | 126 | StyleMenuItem.hh StyleMenuItem.cc \ |
127 | RootCmdMenuItem.hh RootCmdMenuItem.cc\ | 127 | RootCmdMenuItem.hh RootCmdMenuItem.cc\ |
128 | MenuCreator.hh MenuCreator.cc \ | 128 | MenuCreator.hh MenuCreator.cc \ |
diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc index df6f829..d68b6fd 100644 --- a/src/MenuCreator.cc +++ b/src/MenuCreator.cc | |||
@@ -143,7 +143,7 @@ class ParseItem { | |||
143 | public: | 143 | public: |
144 | explicit ParseItem(FbTk::Menu *menu):m_menu(menu) {} | 144 | explicit ParseItem(FbTk::Menu *menu):m_menu(menu) {} |
145 | 145 | ||
146 | inline void load(Parser &p, FbTk::StringConvertor &m_labelconvertor) { | 146 | inline void load(FbTk::Parser &p, FbTk::StringConvertor &m_labelconvertor) { |
147 | p>>m_key>>m_label>>m_cmd>>m_icon; | 147 | p>>m_key>>m_label>>m_cmd>>m_icon; |
148 | m_label.second = m_labelconvertor.recode(m_label.second); | 148 | m_label.second = m_labelconvertor.recode(m_label.second); |
149 | } | 149 | } |
@@ -153,7 +153,7 @@ public: | |||
153 | inline const string &key() const { return m_key.second; } | 153 | inline const string &key() const { return m_key.second; } |
154 | inline FbTk::Menu *menu() { return m_menu; } | 154 | inline FbTk::Menu *menu() { return m_menu; } |
155 | private: | 155 | private: |
156 | Parser::Item m_key, m_label, m_cmd, m_icon; | 156 | FbTk::Parser::Item m_key, m_label, m_cmd, m_icon; |
157 | FbTk::Menu *m_menu; | 157 | FbTk::Menu *m_menu; |
158 | }; | 158 | }; |
159 | 159 | ||
@@ -172,10 +172,10 @@ public: | |||
172 | 172 | ||
173 | }; | 173 | }; |
174 | 174 | ||
175 | static void translateMenuItem(Parser &parse, ParseItem &item, FbTk::StringConvertor &labelconvertor); | 175 | static void translateMenuItem(FbTk::Parser &parse, ParseItem &item, FbTk::StringConvertor &labelconvertor); |
176 | 176 | ||
177 | 177 | ||
178 | static void parseMenu(Parser &pars, FbTk::Menu &menu, FbTk::StringConvertor &label_convertor) { | 178 | static void parseMenu(FbTk::Parser &pars, FbTk::Menu &menu, FbTk::StringConvertor &label_convertor) { |
179 | ParseItem pitem(&menu); | 179 | ParseItem pitem(&menu); |
180 | while (!pars.eof()) { | 180 | while (!pars.eof()) { |
181 | pitem.load(pars, label_convertor); | 181 | pitem.load(pars, label_convertor); |
@@ -185,7 +185,7 @@ static void parseMenu(Parser &pars, FbTk::Menu &menu, FbTk::StringConvertor &lab | |||
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | static void translateMenuItem(Parser &parse, ParseItem &pitem, FbTk::StringConvertor &labelconvertor) { | 188 | static void translateMenuItem(FbTk::Parser &parse, ParseItem &pitem, FbTk::StringConvertor &labelconvertor) { |
189 | if (pitem.menu() == 0) | 189 | if (pitem.menu() == 0) |
190 | throw string("translateMenuItem: We must have a menu in ParseItem!"); | 190 | throw string("translateMenuItem: We must have a menu in ParseItem!"); |
191 | 191 | ||
@@ -315,8 +315,8 @@ static void translateMenuItem(Parser &parse, ParseItem &pitem, FbTk::StringConve | |||
315 | } else if (str_key == "endencoding") { | 315 | } else if (str_key == "endencoding") { |
316 | MenuCreator::endEncoding(); | 316 | MenuCreator::endEncoding(); |
317 | } | 317 | } |
318 | else { // ok, if we didn't find any special menu item we try with command parser | 318 | else { // ok, if we didn't find any special menu item we try with command FbTk::Parser |
319 | // we need to attach command with arguments so command parser can parse it | 319 | // we need to attach command with arguments so command FbTk::Parser can parse it |
320 | string line = str_key + " " + str_cmd; | 320 | string line = str_key + " " + str_cmd; |
321 | FbTk::RefCount<FbTk::Command> command(FbTk::ObjectRegistry<FbTk::Command>::instance().parse(line)); | 321 | FbTk::RefCount<FbTk::Command> command(FbTk::ObjectRegistry<FbTk::Command>::instance().parse(line)); |
322 | if (*command != 0) { | 322 | if (*command != 0) { |
@@ -341,7 +341,7 @@ static void translateMenuItem(Parser &parse, ParseItem &pitem, FbTk::StringConve | |||
341 | } | 341 | } |
342 | 342 | ||
343 | 343 | ||
344 | static void parseWindowMenu(Parser &parse, FbTk::Menu &menu, FbTk::StringConvertor &labelconvertor) { | 344 | static void parseWindowMenu(FbTk::Parser &parse, FbTk::Menu &menu, FbTk::StringConvertor &labelconvertor) { |
345 | 345 | ||
346 | ParseItem pitem(&menu); | 346 | ParseItem pitem(&menu); |
347 | while (!parse.eof()) { | 347 | while (!parse.eof()) { |