using stringstream header in FbTk

This commit is contained in:
fluxgen 2005-02-13 16:36:54 +00:00
parent b8a39c1e6c
commit bac15c745e
2 changed files with 16 additions and 40 deletions

View file

@ -34,22 +34,10 @@
#include "FbTk/StringUtil.hh" #include "FbTk/StringUtil.hh"
#include "FbTk/MacroCommand.hh" #include "FbTk/MacroCommand.hh"
#include "FbTk/stringstream.hh"
#include <string> #include <string>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif // HAVE_CONFIG_H
#ifdef HAVE_SSTREAM
#include <sstream>
#define FB_istringstream istringstream
#elif HAVE_STRSTREAM
#include <strstream>
#define FB_istringstream istrstream
#else
#error "You dont have sstream or strstream headers!"
#endif // HAVE_STRSTREAM
using namespace std; using namespace std;
@ -151,11 +139,11 @@ FbCommandFactory::FbCommandFactory() {
"workspace12", "workspace12",
/* end note */ /* end note */
"workspacemenu", "workspacemenu",
"" 0
}; };
for (int i=0;; ++i) { for (int i=0;; ++i) {
if (strcmp(commands[i], "") == 0) if (commands[i] == 0)
break; break;
addCommand(commands[i]); addCommand(commands[i]);
} }
@ -229,13 +217,13 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command,
else if (command == "maximizehorizontal") else if (command == "maximizehorizontal")
return new CurrentWindowCmd(&FluxboxWindow::maximizeHorizontal); return new CurrentWindowCmd(&FluxboxWindow::maximizeHorizontal);
else if (command == "resize") { else if (command == "resize") {
FB_istringstream is(arguments.c_str()); FbTk_istringstream is(arguments.c_str());
int dx = 0, dy = 0; int dx = 0, dy = 0;
is >> dx >> dy; is >> dx >> dy;
return new ResizeCmd(dx, dy); return new ResizeCmd(dx, dy);
} }
else if (command == "resizeto") { else if (command == "resizeto") {
FB_istringstream is(arguments.c_str()); FbTk_istringstream is(arguments.c_str());
int dx = 0, dy = 0; int dx = 0, dy = 0;
is >> dx >> dy; is >> dx >> dy;
return new ResizeToCmd(dx, dy); return new ResizeToCmd(dx, dy);
@ -245,13 +233,13 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command,
else if (command == "resizevertical") else if (command == "resizevertical")
return new ResizeCmd(0,atoi(arguments.c_str())); return new ResizeCmd(0,atoi(arguments.c_str()));
else if (command == "moveto") { else if (command == "moveto") {
FB_istringstream is(arguments.c_str()); FbTk_istringstream is(arguments.c_str());
int dx = 0, dy = 0; int dx = 0, dy = 0;
is >> dx >> dy; is >> dx >> dy;
return new MoveToCmd(dx,dy); return new MoveToCmd(dx,dy);
} }
else if (command == "move") { else if (command == "move") {
FB_istringstream is(arguments.c_str()); FbTk_istringstream is(arguments.c_str());
int dx = 0, dy = 0; int dx = 0, dy = 0;
is >> dx >> dy; is >> dx >> dy;
return new MoveCmd(dx, dy); return new MoveCmd(dx, dy);
@ -367,7 +355,7 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command,
// //
else if (command == "deiconify") { else if (command == "deiconify") {
FB_istringstream iss(arguments); FbTk_istringstream iss(arguments);
string mode; string mode;
string d; string d;
DeiconifyCmd::Destination dest; DeiconifyCmd::Destination dest;
@ -419,7 +407,7 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command,
c= FbTk::StringUtil::toLower(cmd); c= FbTk::StringUtil::toLower(cmd);
FbTk::Command* fbcmd= stringToCommand(c,a); FbTk::Command* fbcmd= stringToCommand(c,a);
if ( fbcmd ) { if (fbcmd) {
FbTk::RefCount<FbTk::Command> rfbcmd(fbcmd); FbTk::RefCount<FbTk::Command> rfbcmd(fbcmd);
macro->add(rfbcmd); macro->add(rfbcmd);
} }

View file

@ -36,6 +36,7 @@
#include "FbTk/StringUtil.hh" #include "FbTk/StringUtil.hh"
#include "FbTk/MenuItem.hh" #include "FbTk/MenuItem.hh"
#include "FbTk/App.hh" #include "FbTk/App.hh"
#include "FbTk/stringstream.hh"
#include <X11/Xlib.h> #include <X11/Xlib.h>
@ -52,19 +53,6 @@
#include <memory> #include <memory>
#include <set> #include <set>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif // HAVE_CONFIG_H
#ifdef HAVE_SSTREAM
#include <sstream>
#define FB_istringstream istringstream
#elif HAVE_STRSTREAM
#include <strstream>
#define FB_istringstream istrstream
#else
#error "You dont have sstream or strstream headers!"
#endif // HAVE_STRSTREAM
using namespace std; using namespace std;
@ -173,7 +161,7 @@ bool handleStartupItem(const string &line, int offset) {
if (pos > 0) { if (pos > 0) {
option = str.substr(0, pos); option = str.substr(0, pos);
if (option == "screen") { if (option == "screen") {
FB_istringstream iss(str.c_str() + pos + 1); FbTk_istringstream iss(str.c_str() + pos + 1);
iss >> screen; iss >> screen;
} else { } else {
error = true; error = true;
@ -333,7 +321,7 @@ int Remember::parseApp(ifstream &file, Application &app, string *first_line) {
continue; //read next line continue; //read next line
if (str_key == "Workspace") { if (str_key == "Workspace") {
unsigned int w; unsigned int w;
FB_istringstream iss(str_label.c_str()); FbTk_istringstream iss(str_label.c_str());
iss >> w; iss >> w;
app.rememberWorkspace(w); app.rememberWorkspace(w);
} else if (str_key == "Head") { } else if (str_key == "Head") {
@ -356,17 +344,17 @@ int Remember::parseApp(ifstream &file, Application &app, string *first_line) {
} else if (str_label == "MENU") { } else if (str_label == "MENU") {
l = Fluxbox::instance()->getMenuLayer(); l = Fluxbox::instance()->getMenuLayer();
} else { } else {
FB_istringstream iss(str_label.c_str()); FbTk_istringstream iss(str_label.c_str());
iss >> l; iss >> l;
} }
app.rememberLayer(l); app.rememberLayer(l);
} else if (str_key == "Dimensions") { } else if (str_key == "Dimensions") {
unsigned int h,w; unsigned int h,w;
FB_istringstream iss(str_label.c_str()); FbTk_istringstream iss(str_label.c_str());
iss >> w >> h; iss >> w >> h;
app.rememberDimensions(w,h); app.rememberDimensions(w,h);
} else if (str_key == "Position") { } else if (str_key == "Position") {
FB_istringstream iss; FbTk_istringstream iss;
unsigned int r= 0; unsigned int r= 0;
unsigned int x= 0; unsigned int x= 0;
unsigned int y= 0; unsigned int y= 0;
@ -426,7 +414,7 @@ int Remember::parseApp(ifstream &file, Application &app, string *first_line) {
unsigned int mask; unsigned int mask;
const char * str = str_label.c_str(); const char * str = str_label.c_str();
// it'll have at least one char and \0, so this is safe // it'll have at least one char and \0, so this is safe
FB_istringstream iss(str); FbTk_istringstream iss(str);
// check for hex // check for hex
if (str[0] == '0' && str[1] == 'x') { if (str[0] == '0' && str[1] == 'x') {
iss.seekg(2); iss.seekg(2);