1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-07-03 00:51:04 +03:00

pass strings by reference where possible

This commit is contained in:
Lars-Peter Clausen 2010-05-02 14:29:09 +02:00
parent a794a1c01a
commit 40a26e1a9c
68 changed files with 279 additions and 267 deletions

View File

@ -18,7 +18,7 @@ ASFont::ASFont(Surface* font) {
halfLineHeight = getLineHeight()/2; halfLineHeight = getLineHeight()/2;
} }
ASFont::ASFont(string font) { ASFont::ASFont(const string &font) {
this->font.initFont(font); this->font.initFont(font);
halfHeight = getHeight()/2; halfHeight = getHeight()/2;
halfLineHeight = getLineHeight()/2; halfLineHeight = getLineHeight()/2;

View File

@ -24,7 +24,7 @@ class ASFont {
public: public:
ASFont(SDL_Surface* font); ASFont(SDL_Surface* font);
ASFont(Surface* font); ASFont(Surface* font);
ASFont(string font); ASFont(const string &font);
~ASFont(); ~ASFont();
bool utf8Code(unsigned char c); bool utf8Code(unsigned char c);

View File

@ -33,7 +33,7 @@
using namespace std; using namespace std;
using namespace fastdelegate; using namespace fastdelegate;
DirDialog::DirDialog(GMenu2X *gmenu2x, string text, string dir) { DirDialog::DirDialog(GMenu2X *gmenu2x, const string &text, const string &dir) {
this->gmenu2x = gmenu2x; this->gmenu2x = gmenu2x;
this->text = text; this->text = text;
selRow = 0; selRow = 0;

View File

@ -56,7 +56,7 @@ private:
public: public:
string path; string path;
DirDialog(GMenu2X *gmenu2x, string text, string dir=""); DirDialog(GMenu2X *gmenu2x, const string &text, const string &dir="");
bool exec(); bool exec();
}; };

View File

@ -30,7 +30,7 @@
using namespace std; using namespace std;
FileDialog::FileDialog(GMenu2X *gmenu2x, string text, string filter, string file) { FileDialog::FileDialog(GMenu2X *gmenu2x, const string &text, const string &filter, const string &file) {
this->gmenu2x = gmenu2x; this->gmenu2x = gmenu2x;
this->text = text; this->text = text;
this->filter = filter; this->filter = filter;
@ -176,7 +176,7 @@ bool FileDialog::exec() {
return result; return result;
} }
void FileDialog::setPath(string path) { void FileDialog::setPath(const string &path) {
path_v = path; path_v = path;
fl.setPath(path); fl.setPath(path);
selected = 0; selected = 0;

View File

@ -51,11 +51,11 @@ protected:
public: public:
string file; string file;
FileDialog(GMenu2X *gmenu2x, string text, string filter="", string file=""); FileDialog(GMenu2X *gmenu2x, const string &text, const string &filter="", const string &file="");
virtual ~FileDialog() {}; virtual ~FileDialog() {};
virtual string path() { return path_v; }; virtual const string &path() { return path_v; };
virtual void setPath(string path); virtual void setPath(const string &path);
inline virtual void beforeFileList(); inline virtual void beforeFileList();
inline virtual void onChangeDir(); inline virtual void onChangeDir();

View File

@ -30,26 +30,27 @@
using namespace std; using namespace std;
FileLister::FileLister(string startPath, bool showDirectories, bool showFiles) { FileLister::FileLister(const string &startPath, bool showDirectories, bool showFiles) {
this->showDirectories = showDirectories; this->showDirectories = showDirectories;
this->showFiles = showFiles; this->showFiles = showFiles;
setPath(startPath,false); setPath(startPath,false);
} }
string FileLister::getPath() { const string &FileLister::getPath() {
return path; return path;
} }
void FileLister::setPath(string path, bool doBrowse) { void FileLister::setPath(const string &path, bool doBrowse) {
if (path[path.length()-1]!='/') path += "/";
this->path = path; this->path = path;
if (this->path[path.length()-1]!='/')
this->path += "/";
if (doBrowse) if (doBrowse)
browse(); browse();
} }
string FileLister::getFilter() { const string &FileLister::getFilter() {
return filter; return filter;
} }
void FileLister::setFilter(string filter) { void FileLister::setFilter(const string &filter) {
this->filter = filter; this->filter = filter;
} }

View File

@ -33,7 +33,7 @@ private:
bool showDirectories, showFiles; bool showDirectories, showFiles;
public: public:
FileLister(string startPath = "/boot/local", bool showDirectories = true, bool showFiles = true); FileLister(const string &startPath = "/boot/local", bool showDirectories = true, bool showFiles = true);
void browse(); void browse();
vector<string> directories, files, exclude; vector<string> directories, files, exclude;
@ -45,10 +45,10 @@ public:
bool isFile(uint); bool isFile(uint);
bool isDirectory(uint); bool isDirectory(uint);
string getPath(); const string &getPath();
void setPath(string path, bool doBrowse=true); void setPath(const string &path, bool doBrowse=true);
string getFilter(); const string &getFilter();
void setFilter(string filter); void setFilter(const string &filter);
}; };
#endif /*FILELISTER_H_*/ #endif /*FILELISTER_H_*/

View File

@ -695,7 +695,7 @@ void GMenu2X::readTmp() {
} }
} }
void GMenu2X::writeTmp(int selelem, string selectordir) { void GMenu2X::writeTmp(int selelem, const string &selectordir) {
string conffile = "/tmp/gmenu2x.tmp"; string conffile = "/tmp/gmenu2x.tmp";
ofstream inf(conffile.c_str()); ofstream inf(conffile.c_str());
if (inf.is_open()) { if (inf.is_open()) {
@ -1122,7 +1122,7 @@ void GMenu2X::toggleTvOut() {
#endif #endif
} }
void GMenu2X::setSkin(string skin, bool setWallpaper) { void GMenu2X::setSkin(const string &skin, bool setWallpaper) {
confStr["skin"] = skin; confStr["skin"] = skin;
//Clear previous skin settings //Clear previous skin settings
@ -1847,7 +1847,7 @@ int GMenu2X::getVolumeScaler() {
return currentscalefactor; return currentscalefactor;
} }
string GMenu2X::getExePath() { const string &GMenu2X::getExePath() {
if (path.empty()) { if (path.empty()) {
char buf[255]; char buf[255];
int l = readlink("/proc/self/exe",buf,255); int l = readlink("/proc/self/exe",buf,255);
@ -1882,7 +1882,7 @@ int GMenu2X::drawButton(IconButton *btn, int x, int y) {
return x+btn->getRect().w+6; return x+btn->getRect().w+6;
} }
int GMenu2X::drawButton(Surface *s, string btn, string text, int x, int y) { int GMenu2X::drawButton(Surface *s, const string &btn, const string &text, int x, int y) {
if (y<0) y = resY+y; if (y<0) y = resY+y;
SDL_Rect re = {x, y-7, 0, 16}; SDL_Rect re = {x, y-7, 0, 16};
if (sc.skinRes("imgs/buttons/"+btn+".png") != NULL) { if (sc.skinRes("imgs/buttons/"+btn+".png") != NULL) {
@ -1894,7 +1894,7 @@ int GMenu2X::drawButton(Surface *s, string btn, string text, int x, int y) {
return x+re.w+6; return x+re.w+6;
} }
int GMenu2X::drawButtonRight(Surface *s, string btn, string text, int x, int y) { int GMenu2X::drawButtonRight(Surface *s, const string &btn, const string &text, int x, int y) {
if (y<0) y = resY+y; if (y<0) y = resY+y;
if (sc.skinRes("imgs/buttons/"+btn+".png") != NULL) { if (sc.skinRes("imgs/buttons/"+btn+".png") != NULL) {
x -= 16; x -= 16;
@ -1923,7 +1923,7 @@ void GMenu2X::drawScrollBar(uint pagesize, uint totalsize, uint pagepos, uint to
s->box(resX-6, by, 3, bs, skinConfColors["selectionBg"]); s->box(resX-6, by, 3, bs, skinConfColors["selectionBg"]);
} }
void GMenu2X::drawTitleIcon(string icon, bool skinRes, Surface *s) { void GMenu2X::drawTitleIcon(const string &icon, bool skinRes, Surface *s) {
if (s==NULL) s = this->s; if (s==NULL) s = this->s;
Surface *i = NULL; Surface *i = NULL;
@ -1940,12 +1940,12 @@ void GMenu2X::drawTitleIcon(string icon, bool skinRes, Surface *s) {
i->blit(s,4,(skinConfInt["topBarHeight"]-32)/2); i->blit(s,4,(skinConfInt["topBarHeight"]-32)/2);
} }
void GMenu2X::writeTitle(string title, Surface *s) { void GMenu2X::writeTitle(const string &title, Surface *s) {
if (s==NULL) s = this->s; if (s==NULL) s = this->s;
s->write(font,title,40, skinConfInt["topBarHeight"]/4, SFontHAlignLeft, SFontVAlignMiddle); s->write(font,title,40, skinConfInt["topBarHeight"]/4, SFontHAlignLeft, SFontVAlignMiddle);
} }
void GMenu2X::writeSubTitle(string subtitle, Surface *s) { void GMenu2X::writeSubTitle(const string &subtitle, Surface *s) {
if (s==NULL) s = this->s; if (s==NULL) s = this->s;
s->write(font,subtitle,40, skinConfInt["topBarHeight"]/4*3, SFontHAlignLeft, SFontVAlignMiddle); s->write(font,subtitle,40, skinConfInt["topBarHeight"]/4*3, SFontHAlignLeft, SFontVAlignMiddle);
} }

View File

@ -85,7 +85,7 @@ private:
*/ */
unsigned short getBatteryLevel(); unsigned short getBatteryLevel();
FILE* batteryHandle, *backlightHandle, *usbHandle, *acHandle; FILE* batteryHandle, *backlightHandle, *usbHandle, *acHandle;
void browsePath(string path, vector<string>* directories, vector<string>* files); void browsePath(const string &path, vector<string>* directories, vector<string>* files);
/*! /*!
Starts the scanning of the nand and sd filesystems, searching for dge and gpu files and creating the links in 2 dedicated sections. Starts the scanning of the nand and sd filesystems, searching for dge and gpu files and creating the links in 2 dedicated sections.
*/ */
@ -146,7 +146,7 @@ public:
@see path @see path
@return String containing the parent directory @return String containing the parent directory
*/ */
string getExePath(); const string &getExePath();
InputManager input; InputManager input;
Touchscreen ts; Touchscreen ts;
@ -158,7 +158,7 @@ public:
//Configuration settings //Configuration settings
bool useSelectionPng; bool useSelectionPng;
void setSkin(string skin, bool setWallpaper = true); void setSkin(const string &skin, bool setWallpaper = true);
//firmware type and version //firmware type and version
string fwType, fwVersion; string fwType, fwVersion;
//gp2x type //gp2x type
@ -212,7 +212,7 @@ public:
void writeConfig(); void writeConfig();
void writeConfigOpen2x(); void writeConfigOpen2x();
void writeSkinConfig(); void writeSkinConfig();
void writeTmp(int selelem=-1, string selectordir=""); void writeTmp(int selelem=-1, const string &selectordir="");
void ledOn(); void ledOn();
void ledOff(); void ledOff();
@ -226,13 +226,13 @@ public:
void initBG(); void initBG();
int drawButton(IconButton *btn, int x=5, int y=-10); int drawButton(IconButton *btn, int x=5, int y=-10);
int drawButton(Surface *s, string btn, string text, int x=5, int y=-10); int drawButton(Surface *s, const string &btn, const string &text, int x=5, int y=-10);
int drawButtonRight(Surface *s, string btn, string text, int x=5, int y=-10); int drawButtonRight(Surface *s, const string &btn, const string &text, int x=5, int y=-10);
void drawScrollBar(uint pagesize, uint totalsize, uint pagepos, uint top, uint height); void drawScrollBar(uint pagesize, uint totalsize, uint pagepos, uint top, uint height);
void drawTitleIcon(string icon, bool skinRes=true, Surface *s=NULL); void drawTitleIcon(const string &icon, bool skinRes=true, Surface *s=NULL);
void writeTitle(string title, Surface *s=NULL); void writeTitle(const string &title, Surface *s=NULL);
void writeSubTitle(string subtitle, Surface *s=NULL); void writeSubTitle(const string &subtitle, Surface *s=NULL);
void drawTopBar(Surface *s=NULL); void drawTopBar(Surface *s=NULL);
void drawBottomBar(Surface *s=NULL); void drawBottomBar(Surface *s=NULL);

View File

@ -4,7 +4,7 @@
using namespace std; using namespace std;
using namespace fastdelegate; using namespace fastdelegate;
IconButton::IconButton(GMenu2X *gmenu2x, string icon, string label) : Button(gmenu2x) { IconButton::IconButton(GMenu2X *gmenu2x, const string &icon, const string &label) : Button(gmenu2x) {
this->gmenu2x = gmenu2x; this->gmenu2x = gmenu2x;
this->icon = icon; this->icon = icon;
labelPosition = IconButton::DISP_RIGHT; labelPosition = IconButton::DISP_RIGHT;
@ -93,11 +93,11 @@ void IconButton::recalcSize() {
setSize(w, h); setSize(w, h);
} }
string IconButton::getLabel() { const string &IconButton::getLabel() {
return label; return label;
} }
void IconButton::setLabel(string label) { void IconButton::setLabel(const string &label) {
this->label = label; this->label = label;
} }
@ -107,11 +107,11 @@ void IconButton::setLabelPosition(int pos, int margin) {
recalcSize(); recalcSize();
} }
string IconButton::getIcon() { const string &IconButton::getIcon() {
return icon; return icon;
} }
void IconButton::setIcon(string icon) { void IconButton::setIcon(const string &icon) {
this->icon = icon; this->icon = icon;
recalcSize(); recalcSize();
} }

View File

@ -22,7 +22,7 @@ public:
static const int DISP_TOP = 2; static const int DISP_TOP = 2;
static const int DISP_BOTTOM = 3; static const int DISP_BOTTOM = 3;
IconButton(GMenu2X *gmenu2x, string icon, string label=""); IconButton(GMenu2X *gmenu2x, const string &icon, const string &label="");
virtual ~IconButton() {}; virtual ~IconButton() {};
virtual void paint(); virtual void paint();
@ -30,12 +30,12 @@ public:
void setPosition(int x, int y); void setPosition(int x, int y);
string getLabel(); const string &getLabel();
void setLabel(string label); void setLabel(const string &label);
void setLabelPosition(int pos, int margin); void setLabelPosition(int pos, int margin);
string getIcon(); const string &getIcon();
void setIcon(string icon); void setIcon(const string &icon);
void setAction(ButtonAction action); void setAction(ButtonAction action);
}; };

View File

@ -31,20 +31,19 @@
using namespace std; using namespace std;
ImageDialog::ImageDialog(GMenu2X *gmenu2x, string text, string filter, string file) : FileDialog(gmenu2x, text, filter, file) { ImageDialog::ImageDialog(GMenu2X *gmenu2x, const string &text, const string &filter, const string &file) : FileDialog(gmenu2x, text, filter, file) {
this->gmenu2x = gmenu2x; this->gmenu2x = gmenu2x;
this->text = text; this->text = text;
this->filter = filter; this->filter = filter;
this->file = "";
setPath("/card"); setPath("/card");
title = "Image Browser"; title = "Image Browser";
if (!file.empty()) { if (!file.empty()) {
file = strreplace(file,"skin:",gmenu2x->getExePath()+"skins/"+gmenu2x->confStr["skin"]+"/"); this->file = strreplace(file,"skin:",gmenu2x->getExePath()+"skins/"+gmenu2x->confStr["skin"]+"/");
string::size_type pos = file.rfind("/"); string::size_type pos = this->file.rfind("/");
if (pos != string::npos) { if (pos != string::npos) {
setPath( file.substr(0, pos) ); setPath( this->file.substr(0, pos) );
cout << "ib: " << path() << endl; cout << "ib: " << path() << endl;
this->file = file.substr(pos+1,file.length()); this->file = this->file.substr(pos+1,file.length());
} }
} }
selRow = 0; selRow = 0;

View File

@ -31,7 +31,7 @@ class ImageDialog : public FileDialog {
protected: protected:
SurfaceCollection previews; SurfaceCollection previews;
public: public:
ImageDialog(GMenu2X *gmenu2x, string text, string filter="", string file=""); ImageDialog(GMenu2X *gmenu2x, const string &text, const string &filter="", const string &file="");
virtual ~ImageDialog(); virtual ~ImageDialog();
inline virtual void beforeFileList(); inline virtual void beforeFileList();
inline virtual void onChangeDir(); inline virtual void onChangeDir();

View File

@ -26,7 +26,7 @@
using namespace std; using namespace std;
using namespace fastdelegate; using namespace fastdelegate;
InputDialog::InputDialog(GMenu2X *gmenu2x, string text, string startvalue, string title, string icon) { InputDialog::InputDialog(GMenu2X *gmenu2x, const string &text, const string &startvalue, const string &title, const string &icon) {
this->gmenu2x = gmenu2x; this->gmenu2x = gmenu2x;
if (title=="") { if (title=="") {
this->title = text; this->title = text;

View File

@ -67,7 +67,7 @@ private:
void setKeyboard(int); void setKeyboard(int);
public: public:
InputDialog(GMenu2X *gmenu2x, string text, string startvalue="", string title="", string icon=""); InputDialog(GMenu2X *gmenu2x, const string &text, const string &startvalue="", const string &title="", const string &icon="");
string input; string input;
bool exec(); bool exec();

View File

@ -34,7 +34,7 @@ InputManager::~InputManager() {
SDL_JoystickClose(joysticks[x]); SDL_JoystickClose(joysticks[x]);
} }
void InputManager::init(string conffile) { void InputManager::init(const string &conffile) {
SDL_JoystickEventState(SDL_IGNORE); SDL_JoystickEventState(SDL_IGNORE);
int numJoy = SDL_NumJoysticks(); int numJoy = SDL_NumJoysticks();

View File

@ -72,7 +72,7 @@ public:
InputManager(); InputManager();
~InputManager(); ~InputManager();
void init(string conffile = "input.conf"); void init(const string &conffile = "input.conf");
vector <SDL_Joystick*> joysticks; vector <SDL_Joystick*> joysticks;
vector<bool> actions; vector<bool> actions;

View File

@ -57,59 +57,63 @@ void Link::updateSurfaces()
iconSurface = gmenu2x->sc[getIconPath()]; iconSurface = gmenu2x->sc[getIconPath()];
} }
string Link::getTitle() { const string &Link::getTitle() {
return title; return title;
} }
void Link::setTitle(string title) { void Link::setTitle(const string &title) {
this->title = title; this->title = title;
edited = true; edited = true;
} }
string Link::getDescription() { const string &Link::getDescription() {
return description; return description;
} }
void Link::setDescription(string description) { void Link::setDescription(const string &description) {
this->description = description; this->description = description;
edited = true; edited = true;
} }
string Link::getIcon() { const string &Link::getIcon() {
return icon; return icon;
} }
void Link::setIcon(string icon) { void Link::setIcon(const string &icon) {
string skinpath = gmenu2x->getExePath()+"skins/"+gmenu2x->confStr["skin"]; string skinpath = gmenu2x->getExePath()+"skins/"+gmenu2x->confStr["skin"];
if (icon.substr(0,skinpath.length()) == skinpath) { if (icon.substr(0,skinpath.length()) == skinpath) {
string tempIcon = icon.substr(skinpath.length(), icon.length()); string tempIcon = icon.substr(skinpath.length(), icon.length());
string::size_type pos = tempIcon.find("/"); string::size_type pos = tempIcon.find("/");
if (pos != string::npos) if (pos != string::npos)
icon = "skin:"+tempIcon.substr(pos+1,icon.length()); this->icon = "skin:"+tempIcon.substr(pos+1,icon.length());
else
this->icon = icon;
} else {
this->icon = icon;
} }
iconPath = strreplace(icon,"skin:",skinpath+"/"); iconPath = strreplace(this->icon,"skin:",skinpath+"/");
if (iconPath.empty() || !fileExists(iconPath)) { if (iconPath.empty() || !fileExists(iconPath)) {
iconPath = strreplace(icon,"skin:",gmenu2x->getExePath()+"skins/Default/"); iconPath = strreplace(this->icon,"skin:",gmenu2x->getExePath()+"skins/Default/");
if (!fileExists(iconPath)) searchIcon(); if (!fileExists(iconPath)) searchIcon();
} }
this->icon = icon;
edited = true; edited = true;
updateSurfaces(); updateSurfaces();
} }
string Link::searchIcon() { const string &Link::searchIcon() {
iconPath = gmenu2x->sc.getSkinFilePath("icons/generic.png"); iconPath = gmenu2x->sc.getSkinFilePath("icons/generic.png");
return iconPath; return iconPath;
} }
string Link::getIconPath() { const string &Link::getIconPath() {
if (iconPath.empty()) searchIcon(); if (iconPath.empty()) searchIcon();
return iconPath; return iconPath;
} }
void Link::setIconPath(string icon) { void Link::setIconPath(const string &icon) {
if (fileExists(icon)) if (fileExists(icon))
iconPath = icon; iconPath = icon;
else else

View File

@ -59,15 +59,15 @@ public:
void setSize(int w, int h); void setSize(int w, int h);
void setPosition(int x, int y); void setPosition(int x, int y);
string getTitle(); const string &getTitle();
void setTitle(string title); void setTitle(const string &title);
string getDescription(); const string &getDescription();
void setDescription(string description); void setDescription(const string &description);
string getIcon(); const string &getIcon();
void setIcon(string icon); void setIcon(const string &icon);
virtual string searchIcon(); virtual const string &searchIcon();
string getIconPath(); const string &getIconPath();
void setIconPath(string icon); void setIconPath(const string &icon);
virtual void run(); virtual void run();
}; };

View File

@ -109,7 +109,7 @@ LinkApp::LinkApp(GMenu2X *gmenu2x, const char* linkfile)
edited = false; edited = false;
} }
string LinkApp::searchIcon() { const string &LinkApp::searchIcon() {
string execicon = exec; string execicon = exec;
string::size_type pos = exec.rfind("."); string::size_type pos = exec.rfind(".");
if (pos != string::npos) execicon = exec.substr(0,pos); if (pos != string::npos) execicon = exec.substr(0,pos);
@ -133,7 +133,7 @@ int LinkApp::clock() {
return iclock; return iclock;
} }
string LinkApp::clockStr(int maxClock) { const string &LinkApp::clockStr(int maxClock) {
if (iclock>maxClock) setClock(maxClock); if (iclock>maxClock) setClock(maxClock);
return sclock; return sclock;
} }
@ -152,7 +152,7 @@ int LinkApp::volume() {
return ivolume; return ivolume;
} }
string LinkApp::volumeStr() { const string &LinkApp::volumeStr() {
return svolume; return svolume;
} }
@ -174,7 +174,7 @@ int LinkApp::backlight()
return ibacklight; return ibacklight;
} }
string LinkApp::backlightStr() const string &LinkApp::backlightStr()
{ {
return sbacklight; return sbacklight;
} }
@ -194,7 +194,7 @@ int LinkApp::gamma() {
return igamma; return igamma;
} }
string LinkApp::gammaStr() { const string &LinkApp::gammaStr() {
return sgamma; return sgamma;
} }
@ -372,7 +372,7 @@ void LinkApp::showManual() {
} }
} }
void LinkApp::selector(int startSelection, string selectorDir) { void LinkApp::selector(int startSelection, const string &selectorDir) {
//Run selector interface //Run selector interface
Selector sel(gmenu2x, this, selectorDir); Selector sel(gmenu2x, this, selectorDir);
int selection = sel.exec(startSelection); int selection = sel.exec(startSelection);
@ -382,7 +382,7 @@ void LinkApp::selector(int startSelection, string selectorDir) {
} }
} }
void LinkApp::launch(string selectedFile, string selectedDir) { void LinkApp::launch(const string &selectedFile, const string &selectedDir) {
drawRun(); drawRun();
save(); save();
#ifndef TARGET_GP2X #ifndef TARGET_GP2X
@ -405,23 +405,27 @@ void LinkApp::launch(string selectedFile, string selectedDir) {
//selectedFile //selectedFile
if (selectedFile!="") { if (selectedFile!="") {
string selectedFileExtension; string selectedFileExtension;
string selectedFileName;
string dir;
string::size_type i = selectedFile.rfind("."); string::size_type i = selectedFile.rfind(".");
if (i != string::npos) { if (i != string::npos) {
selectedFileExtension = selectedFile.substr(i,selectedFile.length()); selectedFileExtension = selectedFile.substr(i,selectedFile.length());
selectedFile = selectedFile.substr(0,i); selectedFileName = selectedFile.substr(0,i);
} }
if (selectedDir=="") if (selectedDir=="")
selectedDir = getSelectorDir(); dir = getSelectorDir();
else
dir = selectedDir;
if (params=="") { if (params=="") {
params = cmdclean(selectedDir+selectedFile+selectedFileExtension); params = cmdclean(dir+selectedFile);
} else { } else {
string origParams = params; string origParams = params;
params = strreplace(params,"[selFullPath]",cmdclean(selectedDir+selectedFile+selectedFileExtension)); params = strreplace(params,"[selFullPath]",cmdclean(dir+selectedFile));
params = strreplace(params,"[selPath]",cmdclean(selectedDir)); params = strreplace(params,"[selPath]",cmdclean(dir));
params = strreplace(params,"[selFile]",cmdclean(selectedFile)); params = strreplace(params,"[selFile]",cmdclean(selectedFileName));
params = strreplace(params,"[selExt]",cmdclean(selectedFileExtension)); params = strreplace(params,"[selExt]",cmdclean(selectedFileExtension));
if (params == origParams) params += " " + cmdclean(selectedDir+selectedFile+selectedFileExtension); if (params == origParams) params += " " + cmdclean(dir+selectedFile);
} }
} }
@ -480,49 +484,49 @@ void LinkApp::launch(string selectedFile, string selectedDir) {
chdir(gmenu2x->getExePath().c_str()); chdir(gmenu2x->getExePath().c_str());
} }
string LinkApp::getExec() { const string &LinkApp::getExec() {
return exec; return exec;
} }
void LinkApp::setExec(string exec) { void LinkApp::setExec(const string &exec) {
this->exec = exec; this->exec = exec;
edited = true; edited = true;
} }
string LinkApp::getParams() { const string &LinkApp::getParams() {
return params; return params;
} }
void LinkApp::setParams(string params) { void LinkApp::setParams(const string &params) {
this->params = params; this->params = params;
edited = true; edited = true;
} }
string LinkApp::getWorkdir() { const string &LinkApp::getWorkdir() {
return workdir; return workdir;
} }
void LinkApp::setWorkdir(string workdir) { void LinkApp::setWorkdir(const string &workdir) {
this->workdir = workdir; this->workdir = workdir;
edited = true; edited = true;
} }
string LinkApp::getManual() { const string &LinkApp::getManual() {
return manual; return manual;
} }
void LinkApp::setManual(string manual) { void LinkApp::setManual(const string &manual) {
this->manual = manual; this->manual = manual;
edited = true; edited = true;
} }
string LinkApp::getSelectorDir() { const string &LinkApp::getSelectorDir() {
return selectordir; return selectordir;
} }
void LinkApp::setSelectorDir(string selectordir) { void LinkApp::setSelectorDir(const string &selectordir) {
if (selectordir!="" && selectordir[selectordir.length()-1]!='/') selectordir += "/";
this->selectordir = selectordir; this->selectordir = selectordir;
if (this->selectordir!="" && this->selectordir[this->selectordir.length()-1]!='/') this->selectordir += "/";
edited = true; edited = true;
} }
@ -544,29 +548,29 @@ void LinkApp::setUseRamTimings(bool value) {
edited = true; edited = true;
} }
string LinkApp::getSelectorFilter() { const string &LinkApp::getSelectorFilter() {
return selectorfilter; return selectorfilter;
} }
void LinkApp::setSelectorFilter(string selectorfilter) { void LinkApp::setSelectorFilter(const string &selectorfilter) {
this->selectorfilter = selectorfilter; this->selectorfilter = selectorfilter;
edited = true; edited = true;
} }
string LinkApp::getSelectorScreens() { const string &LinkApp::getSelectorScreens() {
return selectorscreens; return selectorscreens;
} }
void LinkApp::setSelectorScreens(string selectorscreens) { void LinkApp::setSelectorScreens(const string &selectorscreens) {
this->selectorscreens = selectorscreens; this->selectorscreens = selectorscreens;
edited = true; edited = true;
} }
string LinkApp::getAliasFile() { const string &LinkApp::getAliasFile() {
return aliasfile; return aliasfile;
} }
void LinkApp::setAliasFile(string aliasfile) { void LinkApp::setAliasFile(const string &aliasfile) {
if (fileExists(aliasfile)) { if (fileExists(aliasfile)) {
this->aliasfile = aliasfile; this->aliasfile = aliasfile;
edited = true; edited = true;

View File

@ -52,46 +52,46 @@ private:
public: public:
LinkApp(GMenu2X *gmenu2x, const char* linkfile); LinkApp(GMenu2X *gmenu2x, const char* linkfile);
virtual string searchIcon(); virtual const string &searchIcon();
string getExec(); const string &getExec();
void setExec(string exec); void setExec(const string &exec);
string getParams(); const string &getParams();
void setParams(string params); void setParams(const string &params);
string getWorkdir(); const string &getWorkdir();
void setWorkdir(string workdir); void setWorkdir(const string &workdir);
string getManual(); const string &getManual();
void setManual(string manual); void setManual(const string &manual);
string getSelectorDir(); const string &getSelectorDir();
void setSelectorDir(string selectordir); void setSelectorDir(const string &selectordir);
bool getSelectorBrowser(); bool getSelectorBrowser();
void setSelectorBrowser(bool value); void setSelectorBrowser(bool value);
bool getUseRamTimings(); bool getUseRamTimings();
void setUseRamTimings(bool value); void setUseRamTimings(bool value);
string getSelectorScreens(); const string &getSelectorScreens();
void setSelectorScreens(string selectorscreens); void setSelectorScreens(const string &selectorscreens);
string getSelectorFilter(); const string &getSelectorFilter();
void setSelectorFilter(string selectorfilter); void setSelectorFilter(const string &selectorfilter);
string getAliasFile(); const string &getAliasFile();
void setAliasFile(string aliasfile); void setAliasFile(const string &aliasfile);
string file; string file;
int clock(); int clock();
string clockStr(int maxClock); const string &clockStr(int maxClock);
void setClock(int mhz); void setClock(int mhz);
int volume(); int volume();
string volumeStr(); const string &volumeStr();
void setVolume(int vol); void setVolume(int vol);
//G //G
int gamma(); int gamma();
string gammaStr(); const string &gammaStr();
void setGamma(int gamma); void setGamma(int gamma);
int backlight(); int backlight();
string backlightStr(); const string &backlightStr();
void setBacklight(int val); void setBacklight(int val);
// /G // /G
@ -101,8 +101,8 @@ public:
bool save(); bool save();
void run(); void run();
void showManual(); void showManual();
void selector(int startSelection=0, string selectorDir=""); void selector(int startSelection=0, const string &selectorDir="");
void launch(string selectedFile="", string selectedDir=""); void launch(const string &selectedFile="", const string &selectedDir="");
bool targetExists(); bool targetExists();
}; };

View File

@ -13,7 +13,7 @@ ListViewItem * ListView::add(ListViewItem *item) {
return item; return item;
} }
ListViewItem * ListView::add(string text) { ListViewItem * ListView::add(const string &text) {
ListViewItem *item = new ListViewItem(this,text); ListViewItem *item = new ListViewItem(this,text);
return add(item); return add(item);
} }

View File

@ -41,7 +41,7 @@ public:
GMenu2X *gmenu2x; GMenu2X *gmenu2x;
ListViewItem *add(ListViewItem *item); ListViewItem *add(ListViewItem *item);
ListViewItem *add(string text); ListViewItem *add(const string &text);
void del(ListViewItem *item); void del(ListViewItem *item);
void del(int itemIndex); void del(int itemIndex);
void clear(); void clear();

View File

@ -1,7 +1,7 @@
#include "listview.h" #include "listview.h"
#include "listviewitem.h" #include "listviewitem.h"
ListViewItem::ListViewItem(ListView * parent, string text) { ListViewItem::ListViewItem(ListView * parent, const string &text) {
this->parent = parent; this->parent = parent;
rect.h = 16; rect.h = 16;
rect.w = parent->getWidth(); rect.w = parent->getWidth();

View File

@ -32,7 +32,7 @@ protected:
SDL_Rect rect; SDL_Rect rect;
public: public:
ListViewItem(ListView *parent, string text); ListViewItem(ListView *parent, const string &text);
virtual ~ListViewItem(); virtual ~ListViewItem();
string text; string text;

View File

@ -133,7 +133,7 @@ int Menu::selSectionIndex() {
return iSection; return iSection;
} }
string Menu::selSection() { const string &Menu::selSection() {
return sections[iSection]; return sections[iSection];
} }
@ -161,7 +161,7 @@ string Menu::sectionPath(int section) {
/*==================================== /*====================================
LINKS MANAGEMENT LINKS MANAGEMENT
====================================*/ ====================================*/
bool Menu::addActionLink(uint section, string title, LinkRunAction action, string description, string icon) { bool Menu::addActionLink(uint section, const string &title, const LinkRunAction &action, const string &description, const string &icon) {
if (section>=sections.size()) return false; if (section>=sections.size()) return false;
LinkAction *linkact = new LinkAction(gmenu2x,action); LinkAction *linkact = new LinkAction(gmenu2x,action);
@ -183,7 +183,6 @@ bool Menu::addLink(string path, string file, string section) {
if (!addSection(section)) if (!addSection(section))
return false; return false;
} }
if (path[path.length()-1]!='/') path += "/";
//if the extension is not equal to gpu or dge then enable the wrapepr by default //if the extension is not equal to gpu or dge then enable the wrapepr by default
bool wrapper = false, pxml = false; bool wrapper = false, pxml = false;
@ -213,6 +212,7 @@ bool Menu::addLink(string path, string file, string section) {
cout << "\033[0;34mGMENU2X:\033[0m Adding link: " << linkpath << endl; cout << "\033[0;34mGMENU2X:\033[0m Adding link: " << linkpath << endl;
#endif #endif
if (path[path.length()-1]!='/') path += "/";
//search for a manual //search for a manual
pos = file.rfind("."); pos = file.rfind(".");
string exename = path+file.substr(0,pos); string exename = path+file.substr(0,pos);
@ -306,7 +306,7 @@ bool Menu::addLink(string path, string file, string section) {
return true; return true;
} }
bool Menu::addSection(string sectionName) { bool Menu::addSection(const string &sectionName) {
string sectiondir = "sections/"+sectionName; string sectiondir = "sections/"+sectionName;
if (mkdir(sectiondir.c_str(),0777)==0) { if (mkdir(sectiondir.c_str(),0777)==0) {
sections.push_back(sectionName); sections.push_back(sectionName);

View File

@ -54,16 +54,16 @@ public:
linklist *sectionLinks(int i = -1); linklist *sectionLinks(int i = -1);
int selSectionIndex(); int selSectionIndex();
string selSection(); const string &selSection();
void decSectionIndex(); void decSectionIndex();
void incSectionIndex(); void incSectionIndex();
void setSectionIndex(int i); void setSectionIndex(int i);
uint firstDispSection(); uint firstDispSection();
uint firstDispRow(); uint firstDispRow();
bool addActionLink(uint section, string title, LinkRunAction action, string description="", string icon=""); bool addActionLink(uint section, const string &title, const LinkRunAction &action, const string &description="", const string &icon="");
bool addLink(string path, string file, string section=""); bool addLink(string path, string file, string section="");
bool addSection(string sectionName); bool addSection(const string &sectionName);
void deleteSelectedLink(); void deleteSelectedLink();
void deleteSelectedSection(); void deleteSelectedSection();

View File

@ -19,7 +19,7 @@
***************************************************************************/ ***************************************************************************/
#include "menusetting.h" #include "menusetting.h"
MenuSetting::MenuSetting(GMenu2X *gmenu2x, string name, string description) { MenuSetting::MenuSetting(GMenu2X *gmenu2x, const string &name, const string &description) {
this->gmenu2x = gmenu2x; this->gmenu2x = gmenu2x;
this->name = name; this->name = name;
this->description = description; this->description = description;

View File

@ -38,7 +38,7 @@ private:
GMenu2X *gmenu2x; GMenu2X *gmenu2x;
public: public:
MenuSetting(GMenu2X *gmenu2x, string name, string description); MenuSetting(GMenu2X *gmenu2x, const string &name, const string &description);
virtual ~MenuSetting() {}; virtual ~MenuSetting() {};
virtual void draw(int y); virtual void draw(int y);

View File

@ -24,7 +24,7 @@
using namespace std; using namespace std;
using namespace fastdelegate; using namespace fastdelegate;
MenuSettingBool::MenuSettingBool(GMenu2X *gmenu2x, string name, string description, int *value) MenuSettingBool::MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, int *value)
: MenuSetting(gmenu2x,name,description) { : MenuSetting(gmenu2x,name,description) {
this->gmenu2x = gmenu2x; this->gmenu2x = gmenu2x;
_ivalue = value; _ivalue = value;
@ -36,7 +36,7 @@ MenuSettingBool::MenuSettingBool(GMenu2X *gmenu2x, string name, string descripti
btnToggle->setAction(MakeDelegate(this, &MenuSettingBool::toggle)); btnToggle->setAction(MakeDelegate(this, &MenuSettingBool::toggle));
} }
MenuSettingBool::MenuSettingBool(GMenu2X *gmenu2x, string name, string description, bool *value) MenuSettingBool::MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, bool *value)
: MenuSetting(gmenu2x,name,description) { : MenuSetting(gmenu2x,name,description) {
this->gmenu2x = gmenu2x; this->gmenu2x = gmenu2x;
_value = value; _value = value;

View File

@ -38,8 +38,8 @@ private:
void toggle(); void toggle();
public: public:
MenuSettingBool(GMenu2X *gmenu2x, string name, string description, bool *value); MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, bool *value);
MenuSettingBool(GMenu2X *gmenu2x, string name, string description, int *value); MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, int *value);
virtual ~MenuSettingBool() {}; virtual ~MenuSettingBool() {};
virtual void draw(int y); virtual void draw(int y);

View File

@ -24,7 +24,7 @@
using namespace std; using namespace std;
using namespace fastdelegate; using namespace fastdelegate;
MenuSettingDir::MenuSettingDir(GMenu2X *gmenu2x, string name, string description, string *value) MenuSettingDir::MenuSettingDir(GMenu2X *gmenu2x, const string &name, const string &description, string *value)
: MenuSetting(gmenu2x,name,description) { : MenuSetting(gmenu2x,name,description) {
this->gmenu2x = gmenu2x; this->gmenu2x = gmenu2x;
_value = value; _value = value;
@ -61,11 +61,11 @@ void MenuSettingDir::select() {
if (dd.exec()) setValue( dd.path ); if (dd.exec()) setValue( dd.path );
} }
void MenuSettingDir::setValue(string value) { void MenuSettingDir::setValue(const string &value) {
*_value = value; *_value = value;
} }
string MenuSettingDir::value() { const string &MenuSettingDir::value() {
return *_value; return *_value;
} }

View File

@ -36,7 +36,7 @@ private:
void clear(); void clear();
public: public:
MenuSettingDir(GMenu2X *gmenu2x, string name, string description, string *value); MenuSettingDir(GMenu2X *gmenu2x, const string &name, const string &description, string *value);
virtual ~MenuSettingDir() {}; virtual ~MenuSettingDir() {};
virtual void draw(int y); virtual void draw(int y);
@ -46,8 +46,8 @@ public:
virtual void drawSelected(int y); virtual void drawSelected(int y);
virtual bool edited(); virtual bool edited();
void setValue(string value); void setValue(const string &value);
string value(); const string &value();
}; };
#endif #endif

View File

@ -24,7 +24,7 @@
using namespace std; using namespace std;
using namespace fastdelegate; using namespace fastdelegate;
MenuSettingFile::MenuSettingFile(GMenu2X *gmenu2x, string name, string description, string *value, string filter) MenuSettingFile::MenuSettingFile(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const string &filter)
: MenuSetting(gmenu2x,name,description) { : MenuSetting(gmenu2x,name,description) {
this->gmenu2x = gmenu2x; this->gmenu2x = gmenu2x;
this->filter = filter; this->filter = filter;
@ -62,11 +62,11 @@ void MenuSettingFile::select() {
if (fd.exec()) setValue( fd.path()+"/"+fd.file ); if (fd.exec()) setValue( fd.path()+"/"+fd.file );
} }
void MenuSettingFile::setValue(string value) { void MenuSettingFile::setValue(const string &value) {
*_value = value; *_value = value;
} }
string MenuSettingFile::value() { const string &MenuSettingFile::value() {
return *_value; return *_value;
} }

View File

@ -37,7 +37,7 @@ protected:
void clear(); void clear();
public: public:
MenuSettingFile(GMenu2X *gmenu2x, string name, string description, string *value, string filter=""); MenuSettingFile(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const string &filter="");
virtual ~MenuSettingFile() {}; virtual ~MenuSettingFile() {};
virtual void draw(int y); virtual void draw(int y);
@ -47,8 +47,8 @@ public:
virtual void drawSelected(int y); virtual void drawSelected(int y);
virtual bool edited(); virtual bool edited();
virtual void setValue(string value); virtual void setValue(const string &value);
string value(); const string &value();
}; };
#endif #endif

View File

@ -23,7 +23,7 @@
using namespace std; using namespace std;
MenuSettingImage::MenuSettingImage(GMenu2X *gmenu2x, string name, string description, string *value, string filter) MenuSettingImage::MenuSettingImage(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const string &filter)
: MenuSettingFile(gmenu2x,name,description,value,filter) { : MenuSettingFile(gmenu2x,name,description,value,filter) {
this->gmenu2x = gmenu2x; this->gmenu2x = gmenu2x;
this->filter = filter; this->filter = filter;
@ -39,7 +39,7 @@ void MenuSettingImage::manageInput() {
} }
} }
void MenuSettingImage::setValue(string value) { void MenuSettingImage::setValue(const string &value) {
string skinpath = gmenu2x->getExePath()+"skins/"+gmenu2x->confStr["skin"]; string skinpath = gmenu2x->getExePath()+"skins/"+gmenu2x->confStr["skin"];
bool inSkinDir = value.substr(0,skinpath.length()) == skinpath; bool inSkinDir = value.substr(0,skinpath.length()) == skinpath;
if (!inSkinDir && gmenu2x->confStr["skin"] != "Default") { if (!inSkinDir && gmenu2x->confStr["skin"] != "Default") {
@ -50,7 +50,10 @@ void MenuSettingImage::setValue(string value) {
string tempIcon = value.substr(skinpath.length(), value.length()); string tempIcon = value.substr(skinpath.length(), value.length());
string::size_type pos = tempIcon.find("/"); string::size_type pos = tempIcon.find("/");
if (pos != string::npos) if (pos != string::npos)
value = "skin:"+tempIcon.substr(pos+1,value.length()); *_value = "skin:"+tempIcon.substr(pos+1,value.length());
else
*_value = value;
} else {
*_value = value;
} }
*_value = value;
} }

View File

@ -27,11 +27,11 @@ using std::string;
class MenuSettingImage : public MenuSettingFile { class MenuSettingImage : public MenuSettingFile {
public: public:
MenuSettingImage(GMenu2X *gmenu2x, string name, string description, string *value, string filter=""); MenuSettingImage(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const string &filter="");
virtual ~MenuSettingImage() {}; virtual ~MenuSettingImage() {};
virtual void manageInput(); virtual void manageInput();
virtual void setValue(string value); virtual void setValue(const string &value);
}; };
#endif #endif

View File

@ -24,7 +24,7 @@
using namespace std; using namespace std;
using namespace fastdelegate; using namespace fastdelegate;
MenuSettingInt::MenuSettingInt(GMenu2X *gmenu2x, string name, string description, int *value, int min, int max) MenuSettingInt::MenuSettingInt(GMenu2X *gmenu2x, const string &name, const string &description, int *value, int min, int max)
: MenuSetting(gmenu2x,name,description) { : MenuSetting(gmenu2x,name,description) {
this->gmenu2x = gmenu2x; this->gmenu2x = gmenu2x;
_value = value; _value = value;

View File

@ -39,7 +39,7 @@ private:
void dec(); void dec();
public: public:
MenuSettingInt(GMenu2X *gmenu2x, string name, string description, int *value, int min, int max); MenuSettingInt(GMenu2X *gmenu2x, const string &name, const string &description, int *value, int min, int max);
virtual ~MenuSettingInt() {}; virtual ~MenuSettingInt() {};
virtual void draw(int y); virtual void draw(int y);

View File

@ -23,7 +23,7 @@
using namespace std; using namespace std;
using namespace fastdelegate; using namespace fastdelegate;
MenuSettingMultiString::MenuSettingMultiString(GMenu2X *gmenu2x, string name, string description, string *value, vector<string> *choices) MenuSettingMultiString::MenuSettingMultiString(GMenu2X *gmenu2x, const string &name, const string &description, string *value, vector<string> *choices)
: MenuSetting(gmenu2x,name,description) { : MenuSetting(gmenu2x,name,description) {
this->gmenu2x = gmenu2x; this->gmenu2x = gmenu2x;
this->choices = choices; this->choices = choices;

View File

@ -39,7 +39,7 @@ private:
void setSel(int); void setSel(int);
public: public:
MenuSettingMultiString(GMenu2X *gmenu2x, string name, string description, string *value, vector<string> *choices); MenuSettingMultiString(GMenu2X *gmenu2x, const string &name, const string &description, string *value, vector<string> *choices);
virtual ~MenuSettingMultiString() {}; virtual ~MenuSettingMultiString() {};
virtual void draw(int y); virtual void draw(int y);

View File

@ -23,7 +23,7 @@
using namespace std; using namespace std;
using namespace fastdelegate; using namespace fastdelegate;
MenuSettingRGBA::MenuSettingRGBA(GMenu2X *gmenu2x, string name, string description, RGBAColor *value) MenuSettingRGBA::MenuSettingRGBA(GMenu2X *gmenu2x, const string &name, const string &description, RGBAColor *value)
: MenuSetting(gmenu2x,name,description) { : MenuSetting(gmenu2x,name,description) {
selPart = 0; selPart = 0;
this->gmenu2x = gmenu2x; this->gmenu2x = gmenu2x;

View File

@ -42,7 +42,7 @@ private:
void rightComponent(); void rightComponent();
public: public:
MenuSettingRGBA(GMenu2X *gmenu2x, string name, string description, RGBAColor *value); MenuSettingRGBA(GMenu2X *gmenu2x, const string &name, const string &description, RGBAColor *value);
virtual ~MenuSettingRGBA() {}; virtual ~MenuSettingRGBA() {};
virtual void draw(int y); virtual void draw(int y);

View File

@ -24,7 +24,7 @@
using namespace std; using namespace std;
using namespace fastdelegate; using namespace fastdelegate;
MenuSettingString::MenuSettingString(GMenu2X *gmenu2x, string name, string description, string *value, string diagTitle, string diagIcon) MenuSettingString::MenuSettingString(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const string &diagTitle, const string &diagIcon)
: MenuSetting(gmenu2x,name,description) { : MenuSetting(gmenu2x,name,description) {
this->gmenu2x = gmenu2x; this->gmenu2x = gmenu2x;
_value = value; _value = value;
@ -53,11 +53,11 @@ void MenuSettingString::manageInput() {
if ( gmenu2x->input[ACTION_B] ) edit(); if ( gmenu2x->input[ACTION_B] ) edit();
} }
void MenuSettingString::setValue(string value) { void MenuSettingString::setValue(const string &value) {
*_value = value; *_value = value;
} }
string MenuSettingString::value() { const string &MenuSettingString::value() {
return *_value; return *_value;
} }

View File

@ -36,7 +36,7 @@ private:
void clear(); void clear();
public: public:
MenuSettingString(GMenu2X *gmenu2x, string name, string description, string *value, string diagTitle="", string diagIcon=""); MenuSettingString(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const string &diagTitle="", const string &diagIcon="");
virtual ~MenuSettingString() {}; virtual ~MenuSettingString() {};
virtual void draw(int y); virtual void draw(int y);
@ -46,8 +46,8 @@ public:
virtual void drawSelected(int y); virtual void drawSelected(int y);
virtual bool edited(); virtual bool edited();
void setValue(string value); void setValue(const string &value);
string value(); const string &value();
}; };
#endif #endif

View File

@ -25,7 +25,7 @@
using namespace std; using namespace std;
MessageBox::MessageBox(GMenu2X *gmenu2x, string text, string icon) { MessageBox::MessageBox(GMenu2X *gmenu2x, const string &text, const string &icon) {
this->gmenu2x = gmenu2x; this->gmenu2x = gmenu2x;
this->text = text; this->text = text;
this->icon = icon; this->icon = icon;

View File

@ -38,7 +38,7 @@ private:
GMenu2X *gmenu2x; GMenu2X *gmenu2x;
public: public:
MessageBox(GMenu2X *gmenu2x, string text, string icon=""); MessageBox(GMenu2X *gmenu2x, const string &text, const string &icon="");
vector<string> buttons; vector<string> buttons;
vector<string> buttonLabels; vector<string> buttonLabels;
vector<SDL_Rect> buttonPositions; vector<SDL_Rect> buttonPositions;

View File

@ -33,7 +33,7 @@
using namespace std; using namespace std;
Selector::Selector(GMenu2X *gmenu2x, LinkApp *link, string selectorDir) { Selector::Selector(GMenu2X *gmenu2x, LinkApp *link, const string &selectorDir) {
this->gmenu2x = gmenu2x; this->gmenu2x = gmenu2x;
this->link = link; this->link = link;
loadAliases(); loadAliases();
@ -235,7 +235,7 @@ void Selector::loadAliases() {
} }
} }
string Selector::getAlias(string key) { string Selector::getAlias(const string &key) {
hash_map<string, string>::iterator i = aliases.find(key); hash_map<string, string>::iterator i = aliases.find(key);
if (i == aliases.end()) if (i == aliases.end())
return ""; return "";

View File

@ -41,13 +41,13 @@ private:
hash_map<string, string> aliases; hash_map<string, string> aliases;
void loadAliases(); void loadAliases();
string getAlias(string key); string getAlias(const string &key);
void prepare(FileLister *fl, vector<string> *screens, vector<string> *titles); void prepare(FileLister *fl, vector<string> *screens, vector<string> *titles);
void freeScreenshots(vector<string> *screens); void freeScreenshots(vector<string> *screens);
public: public:
string file, dir; string file, dir;
Selector(GMenu2X *gmenu2x, LinkApp *link, string selectorDir=""); Selector(GMenu2X *gmenu2x, LinkApp *link, const string &selectorDir="");
int exec(int startSelection=0); int exec(int startSelection=0);
}; };

View File

@ -11,7 +11,7 @@ SelectorDetector::SelectorDetector() {
useSelectorBackground = false; useSelectorBackground = false;
} }
SelectorDetector::SelectorDetector(string config) { SelectorDetector::SelectorDetector(const string &config) {
useSelectorBackground = false; useSelectorBackground = false;
readSelectorConfig(config); readSelectorConfig(config);
} }
@ -20,7 +20,7 @@ SelectorDetector::~SelectorDetector() {
//dtor //dtor
} }
bool SelectorDetector::readSelectorConfig(string config) { bool SelectorDetector::readSelectorConfig(const string &config) {
if (fileExists(config)) { if (fileExists(config)) {
ifstream inf(config.c_str(), ios_base::in); ifstream inf(config.c_str(), ios_base::in);
if (inf.is_open()) { if (inf.is_open()) {

View File

@ -37,10 +37,10 @@ class SelectorDetector
{ {
public: public:
SelectorDetector(); SelectorDetector();
SelectorDetector(string config); SelectorDetector(const string &config);
~SelectorDetector(); ~SelectorDetector();
bool readSelectorConfig(string config); bool readSelectorConfig(const string &config);
string getApplication(){return application;} string getApplication(){return application;}
string getFilePath(){return filePath;} string getFilePath(){return filePath;}
@ -51,8 +51,8 @@ class SelectorDetector
string application; string application;
string filePath; string filePath;
string filters; string filters;
//bool isSelectorGPE(string gpe); //bool isSelectorGPE(const string &gpe);
//string getSelectorConfig(string gpe); // Looks in the GPE for the location of the selectorconfig //string getSelectorConfig(const string &gpe); // Looks in the GPE for the location of the selectorconfig
}; };
#endif // SELECTORDETECTOR_H #endif // SELECTORDETECTOR_H

View File

@ -25,7 +25,7 @@
using namespace std; using namespace std;
SettingsDialog::SettingsDialog(GMenu2X *gmenu2x, string text, string icon) { SettingsDialog::SettingsDialog(GMenu2X *gmenu2x, const string &text, const string &icon) {
this->gmenu2x = gmenu2x; this->gmenu2x = gmenu2x;
this->text = text; this->text = text;

View File

@ -40,7 +40,7 @@ private:
GMenu2X *gmenu2x; GMenu2X *gmenu2x;
public: public:
SettingsDialog(GMenu2X *gmenu2x, string text, string icon="skin:sections/settings.png"); SettingsDialog(GMenu2X *gmenu2x, const string &text, const string &icon="skin:sections/settings.png");
~SettingsDialog(); ~SettingsDialog();
bool edited(); bool edited();

View File

@ -46,7 +46,7 @@ SFontPlus::SFontPlus(SDL_Surface* font) {
initFont(font); initFont(font);
} }
SFontPlus::SFontPlus(string font) { SFontPlus::SFontPlus(const string &font) {
surface = NULL; surface = NULL;
initFont(font); initFont(font);
} }
@ -60,7 +60,7 @@ bool SFontPlus::utf8Code(unsigned char c) {
//return c>=194; //return c>=194;
} }
void SFontPlus::initFont(string font, string characters) { void SFontPlus::initFont(const string &font, const string &characters) {
SDL_Surface *buf = IMG_Load(font.c_str()); SDL_Surface *buf = IMG_Load(font.c_str());
if (buf!=NULL) { if (buf!=NULL) {
initFont( SDL_DisplayFormatAlpha(buf), characters ); initFont( SDL_DisplayFormatAlpha(buf), characters );
@ -68,7 +68,7 @@ void SFontPlus::initFont(string font, string characters) {
} }
} }
void SFontPlus::initFont(SDL_Surface *font, string characters) { void SFontPlus::initFont(SDL_Surface *font, const string &characters) {
freeFont(); freeFont();
this->characters = characters; this->characters = characters;
if (font==NULL) return; if (font==NULL) return;
@ -126,7 +126,7 @@ void SFontPlus::freeFont() {
} }
} }
void SFontPlus::write(SDL_Surface *s, string text, int x, int y) { void SFontPlus::write(SDL_Surface *s, const string &text, int x, int y) {
if (text.empty()) return; if (text.empty()) return;
string::size_type pos; string::size_type pos;
@ -161,7 +161,7 @@ void SFontPlus::write(SDL_Surface *s, string text, int x, int y) {
} }
} }
uint SFontPlus::getTextWidth(string text) { uint SFontPlus::getTextWidth(const string &text) {
string::size_type pos; string::size_type pos;
int width = 0; int width = 0;

View File

@ -24,18 +24,18 @@ private:
public: public:
SFontPlus(); SFontPlus();
SFontPlus(SDL_Surface *font); SFontPlus(SDL_Surface *font);
SFontPlus(string font); SFontPlus(const string &font);
~SFontPlus(); ~SFontPlus();
bool utf8Code(unsigned char c); bool utf8Code(unsigned char c);
void initFont(SDL_Surface *font, string characters = SFONTPLUS_CHARSET); void initFont(SDL_Surface *font, const string &characters = SFONTPLUS_CHARSET);
void initFont(string font, string characters = SFONTPLUS_CHARSET); void initFont(const string &font, const string &characters = SFONTPLUS_CHARSET);
void freeFont(); void freeFont();
void write(SDL_Surface *s, string text, int x, int y); void write(SDL_Surface *s, const string &text, int x, int y);
uint getTextWidth(string text); uint getTextWidth(const string &text);
uint getHeight(); uint getHeight();
uint getLineHeight(); uint getLineHeight();
}; };

View File

@ -26,7 +26,7 @@ using namespace std;
#include "surface.h" #include "surface.h"
#include "utilities.h" #include "utilities.h"
RGBAColor strtorgba(string strColor) { RGBAColor strtorgba(const string &strColor) {
RGBAColor c = {0,0,0,255}; RGBAColor c = {0,0,0,255};
c.r = constrain( strtol( strColor.substr(0,2).c_str(), NULL, 16 ), 0, 255 ); c.r = constrain( strtol( strColor.substr(0,2).c_str(), NULL, 16 ), 0, 255 );
c.g = constrain( strtol( strColor.substr(2,2).c_str(), NULL, 16 ), 0, 255 ); c.g = constrain( strtol( strColor.substr(2,2).c_str(), NULL, 16 ), 0, 255 );
@ -40,7 +40,7 @@ Surface::Surface() {
dblbuffer = NULL; dblbuffer = NULL;
} }
Surface::Surface(string img, bool alpha, string skin) { Surface::Surface(const string &img, bool alpha, const string &skin) {
raw = NULL; raw = NULL;
dblbuffer = NULL; dblbuffer = NULL;
load(img, alpha, skin); load(img, alpha, skin);
@ -48,7 +48,7 @@ Surface::Surface(string img, bool alpha, string skin) {
halfH = raw->h/2; halfH = raw->h/2;
} }
Surface::Surface(string img, string skin, bool alpha) { Surface::Surface(const string &img, const string &skin, bool alpha) {
raw = NULL; raw = NULL;
dblbuffer = NULL; dblbuffer = NULL;
load(img, alpha, skin); load(img, alpha, skin);
@ -111,7 +111,7 @@ SDL_PixelFormat *Surface::format() {
return raw->format; return raw->format;
} }
void Surface::load(string img, bool alpha, string skin) { void Surface::load(const string &img, bool alpha, const string &skin) {
free(); free();
string skinpath; string skinpath;
@ -119,10 +119,11 @@ void Surface::load(string img, bool alpha, string skin) {
skinpath = "skins/"+skin+"/"+img; skinpath = "skins/"+skin+"/"+img;
if (!fileExists(skinpath)) if (!fileExists(skinpath))
skinpath = "skins/Default/"+img; skinpath = "skins/Default/"+img;
img = skinpath; } else {
skinpath = img;
} }
SDL_Surface *buf = IMG_Load(img.c_str()); SDL_Surface *buf = IMG_Load(skinpath.c_str());
if (buf!=NULL) { if (buf!=NULL) {
if (alpha) if (alpha)
raw = SDL_DisplayFormatAlpha(buf); raw = SDL_DisplayFormatAlpha(buf);
@ -264,7 +265,7 @@ void Surface::blendAdd(Surface *target, int x, int y) {
*/ */
} }
void Surface::write(ASFont *font, string text, int x, int y, const unsigned short halign, const unsigned short valign) { void Surface::write(ASFont *font, const string &text, int x, int y, const unsigned short halign, const unsigned short valign) {
font->write(this,text,x,y,halign,valign); font->write(this,text,x,y,halign,valign);
} }

View File

@ -32,7 +32,7 @@ struct RGBAColor {
unsigned short r,g,b,a; unsigned short r,g,b,a;
}; };
RGBAColor strtorgba(string strColor); RGBAColor strtorgba(const string &strColor);
/** /**
Wrapper around SDL_Surface Wrapper around SDL_Surface
@ -46,8 +46,8 @@ private:
public: public:
Surface(); Surface();
Surface(string img, string skin="", bool alpha=true); Surface(const string &img, const string &skin="", bool alpha=true);
Surface(string img, bool alpha, string skin=""); Surface(const string &img, bool alpha, const string &skin="");
Surface(SDL_Surface *s, SDL_PixelFormat *fmt = NULL, Uint32 flags = 0); Surface(SDL_Surface *s, SDL_PixelFormat *fmt = NULL, Uint32 flags = 0);
Surface(Surface *s); Surface(Surface *s);
Surface(int w, int h, Uint32 flags = SDL_HWSURFACE|SDL_SRCALPHA); Surface(int w, int h, Uint32 flags = SDL_HWSURFACE|SDL_SRCALPHA);
@ -58,7 +58,7 @@ public:
SDL_Surface *raw; SDL_Surface *raw;
void free(); void free();
void load(string img, bool alpha=true, string skin=""); void load(const string &img, bool alpha=true, const string &skin="");
void lock(); void lock();
void unlock(); void unlock();
void flip(); void flip();
@ -83,7 +83,7 @@ public:
bool blitRight(Surface *destination, int x, int y, int w=0, int h=0, int a=-1); bool blitRight(Surface *destination, int x, int y, int w=0, int h=0, int a=-1);
bool blitRight(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1); bool blitRight(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1);
void write(ASFont *font, string text, int x, int y, const unsigned short halign=0, const unsigned short valign=0); void write(ASFont *font, const string &text, int x, int y, const unsigned short halign=0, const unsigned short valign=0);
int box(Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8); int box(Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8);
int box(Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8); int box(Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8);

View File

@ -22,7 +22,7 @@
using namespace std; using namespace std;
SurfaceCollection::SurfaceCollection(bool defaultAlpha, string skin) { SurfaceCollection::SurfaceCollection(bool defaultAlpha, const string &skin) {
surfaces.set_empty_key(" "); surfaces.set_empty_key(" ");
surfaces.set_deleted_key(""); surfaces.set_deleted_key("");
this->defaultAlpha = defaultAlpha; this->defaultAlpha = defaultAlpha;
@ -31,11 +31,11 @@ SurfaceCollection::SurfaceCollection(bool defaultAlpha, string skin) {
SurfaceCollection::~SurfaceCollection() {} SurfaceCollection::~SurfaceCollection() {}
void SurfaceCollection::setSkin(string skin) { void SurfaceCollection::setSkin(const string &skin) {
this->skin = skin; this->skin = skin;
} }
string SurfaceCollection::getSkinFilePath(string file) { string SurfaceCollection::getSkinFilePath(const string &file) {
string prefix = "/usr/share/gmenu2x/"; string prefix = "/usr/share/gmenu2x/";
if (fileExists("skins/"+skin+"/"+file)) if (fileExists("skins/"+skin+"/"+file))
return "skins/"+skin+"/"+file; return "skins/"+skin+"/"+file;
@ -54,17 +54,17 @@ void SurfaceCollection::debug() {
} }
} }
bool SurfaceCollection::exists(string path) { bool SurfaceCollection::exists(const string &path) {
return surfaces.find(path) != surfaces.end(); return surfaces.find(path) != surfaces.end();
} }
Surface *SurfaceCollection::add(Surface *s, string path) { Surface *SurfaceCollection::add(Surface *s, const string &path) {
if (exists(path)) del(path); if (exists(path)) del(path);
surfaces[path] = s; surfaces[path] = s;
return s; return s;
} }
Surface *SurfaceCollection::add(string path, bool alpha) { Surface *SurfaceCollection::add(const string &path, bool alpha) {
#ifdef DEBUG #ifdef DEBUG
cout << "Adding surface: " << path << endl; cout << "Adding surface: " << path << endl;
#endif #endif
@ -82,7 +82,7 @@ Surface *SurfaceCollection::add(string path, bool alpha) {
return s; return s;
} }
Surface *SurfaceCollection::addSkinRes(string path, bool alpha) { Surface *SurfaceCollection::addSkinRes(const string &path, bool alpha) {
#ifdef DEBUG #ifdef DEBUG
cout << "Adding skin surface: " << path << endl; cout << "Adding skin surface: " << path << endl;
#endif #endif
@ -99,7 +99,7 @@ Surface *SurfaceCollection::addSkinRes(string path, bool alpha) {
return s; return s;
} }
void SurfaceCollection::del(string path) { void SurfaceCollection::del(const string &path) {
SurfaceHash::iterator i = surfaces.find(path); SurfaceHash::iterator i = surfaces.find(path);
if (i != surfaces.end()) { if (i != surfaces.end()) {
free(i->second); free(i->second);
@ -115,13 +115,13 @@ void SurfaceCollection::clear() {
} }
} }
void SurfaceCollection::move(string from, string to) { void SurfaceCollection::move(const string &from, const string &to) {
del(to); del(to);
surfaces[to] = surfaces[from]; surfaces[to] = surfaces[from];
surfaces.erase(from); surfaces.erase(from);
} }
Surface *SurfaceCollection::operator[](string key) { Surface *SurfaceCollection::operator[](const string &key) {
SurfaceHash::iterator i = surfaces.find(key); SurfaceHash::iterator i = surfaces.find(key);
if (i == surfaces.end()) if (i == surfaces.end())
return add(key, defaultAlpha); return add(key, defaultAlpha);
@ -129,7 +129,7 @@ Surface *SurfaceCollection::operator[](string key) {
return i->second; return i->second;
} }
Surface *SurfaceCollection::skinRes(string key) { Surface *SurfaceCollection::skinRes(const string &key) {
if (key.empty()) return NULL; if (key.empty()) return NULL;
SurfaceHash::iterator i = surfaces.find(key); SurfaceHash::iterator i = surfaces.find(key);

View File

@ -39,25 +39,25 @@ private:
string skin; string skin;
public: public:
SurfaceCollection(bool defaultAlpha=true, string skin="default"); SurfaceCollection(bool defaultAlpha=true, const string &skin="default");
~SurfaceCollection(); ~SurfaceCollection();
void setSkin(string skin); void setSkin(const string &skin);
string getSkinFilePath(string file); string getSkinFilePath(const string &file);
bool defaultAlpha; bool defaultAlpha;
void debug(); void debug();
Surface *add(Surface *s, string path); Surface *add(Surface *s, const string &path);
Surface *add(string path, bool alpha=true); Surface *add(const string &path, bool alpha=true);
Surface *addSkinRes(string path, bool alpha=true); Surface *addSkinRes(const string &path, bool alpha=true);
void del(string path); void del(const string &path);
void clear(); void clear();
void move(string from, string to); void move(const string &from, const string &to);
bool exists(string path); bool exists(const string &path);
Surface *operator[](string); Surface *operator[](const string &);
Surface *skinRes(string); Surface *skinRes(const string &);
}; };
#endif #endif

View File

@ -22,7 +22,7 @@
using namespace std; using namespace std;
TextDialog::TextDialog(GMenu2X *gmenu2x, string title, string description, string icon, vector<string> *text) { TextDialog::TextDialog(GMenu2X *gmenu2x, const string &title, const string &description, const string &icon, vector<string> *text) {
this->gmenu2x = gmenu2x; this->gmenu2x = gmenu2x;
this->text = text; this->text = text;
this->title = title; this->title = title;

View File

@ -37,7 +37,7 @@ protected:
void drawText(vector<string> *text, uint firstRow, uint rowsPerPage); void drawText(vector<string> *text, uint firstRow, uint rowsPerPage);
public: public:
TextDialog(GMenu2X *gmenu2x, string title, string description, string icon, vector<string> *text); TextDialog(GMenu2X *gmenu2x, const string &title, const string &description, const string &icon, vector<string> *text);
void exec(); void exec();
}; };

View File

@ -23,7 +23,7 @@
using namespace std; using namespace std;
TextManualDialog::TextManualDialog(GMenu2X *gmenu2x, string title, string icon, vector<string> *text) TextManualDialog::TextManualDialog(GMenu2X *gmenu2x, const string &title, const string &icon, vector<string> *text)
: TextDialog(gmenu2x,title,"",icon,text) { : TextDialog(gmenu2x,title,"",icon,text) {
this->gmenu2x = gmenu2x; this->gmenu2x = gmenu2x;

View File

@ -38,7 +38,7 @@ private:
vector<ManualPage> pages; vector<ManualPage> pages;
public: public:
TextManualDialog(GMenu2X *gmenu2x, string title, string icon, vector<string> *text); TextManualDialog(GMenu2X *gmenu2x, const string &title, const string &icon, vector<string> *text);
void exec(); void exec();
}; };

View File

@ -26,7 +26,7 @@
using namespace std; using namespace std;
Translator::Translator(string lang) { Translator::Translator(const string &lang) {
_lang = ""; _lang = "";
if (!lang.empty()) if (!lang.empty())
setLang(lang); setLang(lang);
@ -34,11 +34,11 @@ Translator::Translator(string lang) {
Translator::~Translator() {} Translator::~Translator() {}
bool Translator::exists(string term) { bool Translator::exists(const string &term) {
return translations.find(term) != translations.end(); return translations.find(term) != translations.end();
} }
void Translator::setLang(string lang) { void Translator::setLang(const string &lang) {
translations.clear(); translations.clear();
string line; string line;
@ -57,7 +57,7 @@ void Translator::setLang(string lang) {
} }
} }
string Translator::translate(string term,const char *replacestr,...) { string Translator::translate(const string &term,const char *replacestr,...) {
string result = term; string result = term;
if (!_lang.empty()) { if (!_lang.empty()) {
@ -87,7 +87,7 @@ string Translator::translate(string term,const char *replacestr,...) {
return result; return result;
} }
string Translator::operator[](string term) { string Translator::operator[](const string &term) {
return translate(term); return translate(term);
} }

View File

@ -33,14 +33,14 @@ private:
hash_map<string, string> translations; hash_map<string, string> translations;
public: public:
Translator(string lang=""); Translator(const string &lang="");
~Translator(); ~Translator();
string lang(); string lang();
void setLang(string lang); void setLang(const string &lang);
bool exists(string term); bool exists(const string &term);
string translate(string term,const char *replacestr=NULL,...); string translate(const string &term,const char *replacestr=NULL,...);
string operator[](string term); string operator[](const string &term);
}; };
#endif #endif

View File

@ -28,7 +28,7 @@
using namespace std; using namespace std;
bool case_less::operator()(string const &left, string const &right) const { bool case_less::operator()(const string &left, const string &right) const {
return strcasecmp(left.c_str(), right.c_str()) < 0; return strcasecmp(left.c_str(), right.c_str()) < 0;
} }
@ -43,18 +43,18 @@ string trim(const string& s) {
return string(s, b, e - b + 1); return string(s, b, e - b + 1);
} }
void string_copy(string s, char **cs) { void string_copy(const string &s, char **cs) {
*cs = (char*)malloc(s.length()); *cs = (char*)malloc(s.length());
strcpy(*cs, s.c_str()); strcpy(*cs, s.c_str());
} }
char * string_copy(string s) { char * string_copy(const string &s) {
char *cs = NULL; char *cs = NULL;
string_copy(s, &cs); string_copy(s, &cs);
return cs; return cs;
} }
bool fileExists(string file) { bool fileExists(const string &file) {
fstream fin; fstream fin;
fin.open(file.c_str() ,ios::in); fin.open(file.c_str() ,ios::in);
bool exists = fin.is_open(); bool exists = fin.is_open();
@ -115,10 +115,10 @@ int evalIntConf (int *val, int def, int imin, int imax) {
return *val; return *val;
} }
string evalStrConf (string val, string def) { const string &evalStrConf (const string &val, const string &def) {
return val.empty() ? def : val; return val.empty() ? def : val;
} }
string evalStrConf (string *val, string def) { const string &evalStrConf (string *val, const string &def) {
*val = evalStrConf(*val, def); *val = evalStrConf(*val, def);
return *val; return *val;
} }
@ -158,7 +158,7 @@ bool split (vector<string> &vec, const string &str, const string &delim, bool de
return true; return true;
} }
string strreplace (string orig, string search, string replace) { string strreplace (string orig, const string &search, const string &replace) {
string::size_type pos = orig.find( search, 0 ); string::size_type pos = orig.find( search, 0 );
while (pos != string::npos) { while (pos != string::npos) {
orig.replace(pos,search.length(),replace); orig.replace(pos,search.length(),replace);

View File

@ -49,17 +49,17 @@ struct eqstr {
class case_less { class case_less {
public: public:
bool operator()(string const &left, string const &right) const; bool operator()(const string &left, const string &right) const;
}; };
string trim(const string& s); string trim(const string& s);
string strreplace (string orig, string search, string replace); string strreplace (string orig, const string &search, const string &replace);
string cmdclean (string cmdline); string cmdclean (string cmdline);
char *string_copy(string); char *string_copy(const string &);
void string_copy(string, char **); void string_copy(const string &, char **);
bool fileExists(string file); bool fileExists(const string &file);
bool rmtree(string path); bool rmtree(string path);
int max (int a, int b); int max (int a, int b);
@ -68,8 +68,8 @@ int constrain (int x, int imin, int imax);
int evalIntConf (int val, int def, int imin, int imax); int evalIntConf (int val, int def, int imin, int imax);
int evalIntConf (int *val, int def, int imin, int imax); int evalIntConf (int *val, int def, int imin, int imax);
string evalStrConf (string val, string def); const string &evalStrConf (const string &val, const string &def);
string evalStrConf (string *val, string def); const string &evalStrConf (string *val, const string &def);
bool split (vector<string> &vec, const string &str, const string &delim, bool destructive=true); bool split (vector<string> &vec, const string &str, const string &delim, bool destructive=true);