aboutsummaryrefslogtreecommitdiff
path: root/util/FbMenuParser.hh
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-08-19 15:01:07 (GMT)
committerPaul Tagliamonte <paultag@fluxbox.org>2012-04-07 02:13:14 (GMT)
commit23736ab3339e9e5d6d1d7a09218f8df9a39a5ff5 (patch)
treec4313b638fbb361f932af02d651c1ed9c9de3ab1 /util/FbMenuParser.hh
parentb7ab35e5f5624589f57c9de8afefab952dfffd32 (diff)
downloadfluxbox_paul-23736ab3339e9e5d6d1d7a09218f8df9a39a5ff5.zip
fluxbox_paul-23736ab3339e9e5d6d1d7a09218f8df9a39a5ff5.tar.bz2
fluxbox-update_configs: automatically update menu file
To achieve this, I had to partially resurrect (and heavily modify) the old parsing code in MenuCreator.cc.
Diffstat (limited to 'util/FbMenuParser.hh')
-rw-r--r--util/FbMenuParser.hh59
1 files changed, 59 insertions, 0 deletions
diff --git a/util/FbMenuParser.hh b/util/FbMenuParser.hh
new file mode 100644
index 0000000..8bd9e31
--- /dev/null
+++ b/util/FbMenuParser.hh
@@ -0,0 +1,59 @@
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 <fstream>
27
28#include "../src/FbTk/NotCopyable.hh"
29
30class FbMenuParser: public FbTk::NotCopyable {
31public:
32 typedef std::pair<std::string, std::string> Item;
33 static const Item s_empty_item;
34
35 FbMenuParser():m_row(0), m_curr_pos(0), m_curr_token(TYPE) {}
36 FbMenuParser(const std::string &filename):m_row(0), m_curr_pos(0),
37 m_curr_token(TYPE) { open(filename); }
38 ~FbMenuParser() { close(); }
39
40 bool open(const std::string &filename);
41 void close() { m_file.close(); }
42 FbMenuParser &operator >> (Item &out);
43 Item nextItem();
44
45 bool isLoaded() const { return m_file.is_open(); }
46 bool eof() const { return m_file.eof(); }
47 int row() const { return m_row; }
48 std::string line() const { return m_curr_line; }
49private:
50 bool nextLine();
51
52 mutable std::ifstream m_file;
53 int m_row;
54 int m_curr_pos;
55 std::string m_curr_line;
56 enum Object {TYPE, NAME, ARGUMENT, ICON, DONE} m_curr_token;
57};
58
59#endif // FBMENUPARSER_HH