aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-08-01 15:40:55 (GMT)
committerPavel Labath <pavelo@centrum.sk>2011-08-01 15:40:55 (GMT)
commit1875b9be72be6a114a74d7f5a570664148f84a36 (patch)
tree47ca0092692866a37cacfa94bbe03e51ef90afa5 /src
parent9c9da611e2012a95505b1089e81219d0cebf6e02 (diff)
downloadfluxbox_pavel-1875b9be72be6a114a74d7f5a570664148f84a36.zip
fluxbox_pavel-1875b9be72be6a114a74d7f5a570664148f84a36.tar.bz2
Remove remnants of old menu parsing code
as it's no longed needed
Diffstat (limited to 'src')
-rw-r--r--src/FbMenuParser.cc135
-rw-r--r--src/FbMenuParser.hh56
-rw-r--r--src/FbTk/Makefile.am2
-rw-r--r--src/FbTk/Parser.cc26
-rw-r--r--src/FbTk/Parser.hh52
-rw-r--r--src/Makefile.am1
6 files changed, 1 insertions, 271 deletions
diff --git a/src/FbMenuParser.cc b/src/FbMenuParser.cc
deleted file mode 100644
index 716ced2..0000000
--- a/src/FbMenuParser.cc
+++ /dev/null
@@ -1,135 +0,0 @@
1// FbMenuParser.cc for Fluxbox
2// Copyright (c) 2004 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org)
3// and Simon Bowden (rathnor at users.sourceforge.net)
4//
5// Permission is hereby granted, free of charge, to any person obtaining a
6// copy of this software and associated documentation files (the "Software"),
7// to deal in the Software without restriction, including without limitation
8// the rights to use, copy, modify, merge, publish, distribute, sublicense,
9// and/or sell copies of the Software, and to permit persons to whom the
10// Software is furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE.
22
23#include "FbMenuParser.hh"
24
25#include "FbTk/StringUtil.hh"
26
27bool FbMenuParser::open(const std::string &filename) {
28 m_file.open(filename.c_str());
29 m_curr_pos = 0;
30 m_row = 0;
31 m_curr_token = DONE;
32 return isLoaded();
33}
34
35FbTk::Parser &FbMenuParser::operator >> (FbTk::Parser::Item &out) {
36 if (eof()) {
37 out = FbTk::Parser::s_empty_item;
38 return *this;
39 }
40
41 if (m_curr_line.empty())
42 m_curr_token = DONE; // try next line
43
44 char first = '[';
45 char second = ']';
46
47 switch (m_curr_token) {
48 case TYPE:
49 first = '[';
50 second = ']';
51 break;
52 case NAME:
53 first = '(';
54 second = ')';
55 break;
56 case ARGUMENT:
57 first = '{';
58 second = '}';
59 break;
60 case ICON:
61 first = '<';
62 second = '>';
63 break;
64 case DONE: // get new line and call this again
65 if (!nextLine()) {
66 out = FbTk::Parser::s_empty_item;
67 return *this;
68 }
69 return (*this)>>out;
70 break;
71 }
72
73 std::string key;
74 int err = FbTk::StringUtil::
75 getStringBetween(key, m_curr_line.c_str() + m_curr_pos,
76 first, second);
77 if (err <= 0) {
78 if (m_curr_token == TYPE)
79 m_curr_token = NAME;
80 else if (m_curr_token == NAME)
81 m_curr_token = ARGUMENT;
82 else if (m_curr_token == ARGUMENT)
83 m_curr_token = ICON;
84 else if (m_curr_token == ICON)
85 m_curr_token = DONE;
86
87 out = FbTk::Parser::s_empty_item;
88 return *this;
89 }
90
91 m_curr_pos += err; // update current position in current line
92
93 // set value
94 out.second = key;
95
96 // set type and next token to be read
97 switch (m_curr_token) {
98 case TYPE:
99 out.first = "TYPE";
100 m_curr_token = NAME;
101 break;
102 case NAME:
103 out.first = "NAME";
104 m_curr_token = ARGUMENT;
105 break;
106 case ARGUMENT:
107 out.first = "ARGUMENT";
108 m_curr_token = ICON;
109 break;
110 case ICON:
111 out.first = "ICON";
112 m_curr_token = DONE;
113 break;
114 case DONE:
115 break;
116 }
117 return *this;
118}
119
120FbTk::Parser::Item FbMenuParser::nextItem() {
121 FbTk::Parser::Item item;
122 (*this)>>item;
123 return item;
124}
125
126bool FbMenuParser::nextLine() {
127 if (!std::getline(m_file, m_curr_line))
128 return false;
129
130 m_row++;
131 m_curr_pos = 0;
132 m_curr_token = TYPE;
133
134 return true;
135}
diff --git a/src/FbMenuParser.hh b/src/FbMenuParser.hh
deleted file mode 100644
index c690ab9..0000000
--- a/src/FbMenuParser.hh
+++ /dev/null
@@ -1,56 +0,0 @@
1// FbMenuParser.hh for Fluxbox
2// Copyright (c) 2004 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org)
3// and Simon Bowden (rathnor at users.sourceforge.net)
4//
5// Permission is hereby granted, free of charge, to any person obtaining a
6// copy of this software and associated documentation files (the "Software"),
7// to deal in the Software without restriction, including without limitation
8// the rights to use, copy, modify, merge, publish, distribute, sublicense,
9// and/or sell copies of the Software, and to permit persons to whom the
10// Software is furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE.
22
23#ifndef FBMENUPARSER_HH
24#define FBMENUPARSER_HH
25
26#include "FbTk/Parser.hh"
27
28#include <fstream>
29
30class FbMenuParser: public FbTk::Parser {
31public:
32 FbMenuParser():m_row(0), m_curr_pos(0), m_curr_token(TYPE) {}
33 FbMenuParser(const std::string &filename):m_row(0), m_curr_pos(0),
34 m_curr_token(TYPE) { open(filename); }
35 ~FbMenuParser() { close(); }
36
37 bool open(const std::string &filename);
38 void close() { m_file.close(); }
39 FbTk::Parser &operator >> (FbTk::Parser::Item &out);
40 FbTk::Parser::Item nextItem();
41
42 bool isLoaded() const { return m_file.is_open(); }
43 bool eof() const { return m_file.eof(); }
44 int row() const { return m_row; }
45 std::string line() const { return m_curr_line; }
46private:
47 bool nextLine();
48
49 mutable std::ifstream m_file;
50 int m_row;
51 int m_curr_pos;
52 std::string m_curr_line;
53 enum Object {TYPE, NAME, ARGUMENT, ICON, DONE} m_curr_token;
54};
55
56#endif // FBMENUPARSER_HH
diff --git a/src/FbTk/Makefile.am b/src/FbTk/Makefile.am
index dba4478..d807479 100644
--- a/src/FbTk/Makefile.am
+++ b/src/FbTk/Makefile.am
@@ -45,7 +45,7 @@ libFbTk_a_SOURCES = App.hh App.cc Color.cc Color.hh Command.hh \
45 MultLayers.cc MultLayers.hh \ 45 MultLayers.cc MultLayers.hh \
46 Layer.cc Layer.hh LayerItem.cc LayerItem.hh \ 46 Layer.cc Layer.hh LayerItem.cc LayerItem.hh \
47 Resource.hh Resource.cc \ 47 Resource.hh Resource.cc \
48 StringUtil.hh StringUtil.cc Parser.hh Parser.cc \ 48 StringUtil.hh StringUtil.cc \
49 RegExp.hh RegExp.cc \ 49 RegExp.hh RegExp.cc \
50 FbString.hh FbString.cc \ 50 FbString.hh FbString.cc \
51 AutoReloadHelper.hh AutoReloadHelper.cc \ 51 AutoReloadHelper.hh AutoReloadHelper.cc \
diff --git a/src/FbTk/Parser.cc b/src/FbTk/Parser.cc
deleted file mode 100644
index 0555a1a..0000000
--- a/src/FbTk/Parser.cc
+++ /dev/null
@@ -1,26 +0,0 @@
1// Parser.cc for FbTk
2// Copyright (c) 2004 - 2006 Fluxbox Team (fluxgen at fluxbox dot org)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22#include "Parser.hh"
23
24namespace FbTk {
25 const Parser::Item Parser::s_empty_item("", "");
26}
diff --git a/src/FbTk/Parser.hh b/src/FbTk/Parser.hh
deleted file mode 100644
index dbb5119..0000000
--- a/src/FbTk/Parser.hh
+++ /dev/null
@@ -1,52 +0,0 @@
1// Parser.hh for FbTk
2// Copyright (c) 2004 Henrik Kinnunen (fluxgen at fluxbox dot org)
3// and Simon Bowden (rathnor at users.sourceforge.net)
4//
5// Permission is hereby granted, free of charge, to any person obtaining a
6// copy of this software and associated documentation files (the "Software"),
7// to deal in the Software without restriction, including without limitation
8// the rights to use, copy, modify, merge, publish, distribute, sublicense,
9// and/or sell copies of the Software, and to permit persons to whom the
10// Software is furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE.
22
23#ifndef FBTK_PARSER_HH
24#define FBTK_PARSER_HH
25
26#include <string>
27#include <utility>
28
29namespace FbTk {
30
31// interface class for a generic Parser
32class Parser {
33public:
34 typedef std::pair<std::string, std::string> Item;
35 static const Item s_empty_item;
36
37 virtual ~Parser() { }
38
39 virtual bool open(const std::string &filename) = 0;
40 virtual void close() = 0;
41 virtual bool eof() const = 0;
42 virtual bool isLoaded() const = 0;
43 virtual int row() const = 0;
44 virtual std::string line() const = 0;
45 virtual Parser &operator >> (Item &out) = 0;
46 virtual Item nextItem() = 0;
47
48};
49
50} // end namespace FbTk
51
52#endif // FBTK_PARSER_HH
diff --git a/src/Makefile.am b/src/Makefile.am
index 72b5930..3329de8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -132,7 +132,6 @@ fluxbox_SOURCES = AtomHandler.hh ArrowButton.hh ArrowButton.cc \
132 TextDialog.hh TextDialog.cc \ 132 TextDialog.hh TextDialog.cc \
133 CommandDialog.hh CommandDialog.cc SendToMenu.hh SendToMenu.cc \ 133 CommandDialog.hh CommandDialog.cc SendToMenu.hh SendToMenu.cc \
134 AlphaMenu.hh AlphaMenu.cc \ 134 AlphaMenu.hh AlphaMenu.cc \
135 FbMenuParser.hh FbMenuParser.cc \
136 StyleMenuItem.hh StyleMenuItem.cc \ 135 StyleMenuItem.hh StyleMenuItem.cc \
137 RootCmdMenuItem.hh RootCmdMenuItem.cc\ 136 RootCmdMenuItem.hh RootCmdMenuItem.cc\
138 MenuCreator.hh MenuCreator.cc \ 137 MenuCreator.hh MenuCreator.cc \