From 1eb80ce64236026445929fe42f3843da9e53a937 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 1 Aug 2011 17:40:55 +0200 Subject: Remove remnants of old menu parsing code as it's no longed needed --- src/FbMenuParser.cc | 135 --------------------------------------------------- src/FbMenuParser.hh | 56 --------------------- src/FbTk/Makefile.am | 2 +- src/FbTk/Parser.cc | 26 ---------- src/FbTk/Parser.hh | 52 -------------------- src/Makefile.am | 1 - 6 files changed, 1 insertion(+), 271 deletions(-) delete mode 100644 src/FbMenuParser.cc delete mode 100644 src/FbMenuParser.hh delete mode 100644 src/FbTk/Parser.cc delete mode 100644 src/FbTk/Parser.hh 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 @@ -// FbMenuParser.cc for Fluxbox -// Copyright (c) 2004 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) -// and Simon Bowden (rathnor at users.sourceforge.net) -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#include "FbMenuParser.hh" - -#include "FbTk/StringUtil.hh" - -bool FbMenuParser::open(const std::string &filename) { - m_file.open(filename.c_str()); - m_curr_pos = 0; - m_row = 0; - m_curr_token = DONE; - return isLoaded(); -} - -FbTk::Parser &FbMenuParser::operator >> (FbTk::Parser::Item &out) { - if (eof()) { - out = FbTk::Parser::s_empty_item; - return *this; - } - - if (m_curr_line.empty()) - m_curr_token = DONE; // try next line - - char first = '['; - char second = ']'; - - switch (m_curr_token) { - case TYPE: - first = '['; - second = ']'; - break; - case NAME: - first = '('; - second = ')'; - break; - case ARGUMENT: - first = '{'; - second = '}'; - break; - case ICON: - first = '<'; - second = '>'; - break; - case DONE: // get new line and call this again - if (!nextLine()) { - out = FbTk::Parser::s_empty_item; - return *this; - } - return (*this)>>out; - break; - } - - std::string key; - int err = FbTk::StringUtil:: - getStringBetween(key, m_curr_line.c_str() + m_curr_pos, - first, second); - if (err <= 0) { - if (m_curr_token == TYPE) - m_curr_token = NAME; - else if (m_curr_token == NAME) - m_curr_token = ARGUMENT; - else if (m_curr_token == ARGUMENT) - m_curr_token = ICON; - else if (m_curr_token == ICON) - m_curr_token = DONE; - - out = FbTk::Parser::s_empty_item; - return *this; - } - - m_curr_pos += err; // update current position in current line - - // set value - out.second = key; - - // set type and next token to be read - switch (m_curr_token) { - case TYPE: - out.first = "TYPE"; - m_curr_token = NAME; - break; - case NAME: - out.first = "NAME"; - m_curr_token = ARGUMENT; - break; - case ARGUMENT: - out.first = "ARGUMENT"; - m_curr_token = ICON; - break; - case ICON: - out.first = "ICON"; - m_curr_token = DONE; - break; - case DONE: - break; - } - return *this; -} - -FbTk::Parser::Item FbMenuParser::nextItem() { - FbTk::Parser::Item item; - (*this)>>item; - return item; -} - -bool FbMenuParser::nextLine() { - if (!std::getline(m_file, m_curr_line)) - return false; - - m_row++; - m_curr_pos = 0; - m_curr_token = TYPE; - - return true; -} 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 @@ -// FbMenuParser.hh for Fluxbox -// Copyright (c) 2004 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) -// and Simon Bowden (rathnor at users.sourceforge.net) -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#ifndef FBMENUPARSER_HH -#define FBMENUPARSER_HH - -#include "FbTk/Parser.hh" - -#include - -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), - m_curr_token(TYPE) { open(filename); } - ~FbMenuParser() { close(); } - - bool open(const std::string &filename); - void close() { m_file.close(); } - 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(); } - int row() const { return m_row; } - std::string line() const { return m_curr_line; } -private: - bool nextLine(); - - mutable std::ifstream m_file; - int m_row; - int m_curr_pos; - std::string m_curr_line; - enum Object {TYPE, NAME, ARGUMENT, ICON, DONE} m_curr_token; -}; - -#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 \ MultLayers.cc MultLayers.hh \ Layer.cc Layer.hh LayerItem.cc LayerItem.hh \ Resource.hh Resource.cc \ - StringUtil.hh StringUtil.cc Parser.hh Parser.cc \ + StringUtil.hh StringUtil.cc \ RegExp.hh RegExp.cc \ FbString.hh FbString.cc \ 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 @@ -// 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 -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#include "Parser.hh" - -namespace FbTk { - const Parser::Item Parser::s_empty_item("", ""); -} 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 @@ -// Parser.hh for FbTk -// Copyright (c) 2004 Henrik Kinnunen (fluxgen at fluxbox dot org) -// and Simon Bowden (rathnor at users.sourceforge.net) -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#ifndef FBTK_PARSER_HH -#define FBTK_PARSER_HH - -#include -#include - -namespace FbTk { - -// interface class for a generic Parser -class Parser { -public: - typedef std::pair Item; - static const Item s_empty_item; - - virtual ~Parser() { } - - virtual bool open(const std::string &filename) = 0; - virtual void close() = 0; - virtual bool eof() const = 0; - virtual bool isLoaded() const = 0; - virtual int row() const = 0; - virtual std::string line() const = 0; - virtual Parser &operator >> (Item &out) = 0; - virtual Item nextItem() = 0; - -}; - -} // end namespace FbTk - -#endif // FBTK_PARSER_HH diff --git a/src/Makefile.am b/src/Makefile.am index c84f4cc..335a090 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -136,7 +136,6 @@ fluxbox_SOURCES = AtomHandler.hh ArrowButton.hh ArrowButton.cc \ TextDialog.hh TextDialog.cc \ CommandDialog.hh CommandDialog.cc SendToMenu.hh SendToMenu.cc \ AlphaMenu.hh AlphaMenu.cc \ - FbMenuParser.hh FbMenuParser.cc \ StyleMenuItem.hh StyleMenuItem.cc \ RootCmdMenuItem.hh RootCmdMenuItem.cc\ MenuCreator.hh MenuCreator.cc \ -- cgit v0.11.2