move Parser to FbTk

This commit is contained in:
Mark Tiefenbruck 2007-12-27 21:52:00 -08:00
parent e8a2f155e8
commit 39224b0142
7 changed files with 31 additions and 30 deletions

View file

@ -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;
}

View file

@ -25,11 +25,11 @@
#ifndef FBMENUPARSER_HH
#define FBMENUPARSER_HH
#include "Parser.hh"
#include "FbTk/Parser.hh"
#include <fstream>
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(); }

View file

@ -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 \

View file

@ -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("", "");
};

View file

@ -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 <string>
#include <utility>
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

View file

@ -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 \

View file

@ -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<FbTk::Command> command(FbTk::ObjectRegistry<FbTk::Command>::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()) {