mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-22 11:46:14 +02:00
pass strings by reference where possible
This commit is contained in:
parent
a794a1c01a
commit
40a26e1a9c
@ -18,7 +18,7 @@ ASFont::ASFont(Surface* font) {
|
||||
halfLineHeight = getLineHeight()/2;
|
||||
}
|
||||
|
||||
ASFont::ASFont(string font) {
|
||||
ASFont::ASFont(const string &font) {
|
||||
this->font.initFont(font);
|
||||
halfHeight = getHeight()/2;
|
||||
halfLineHeight = getLineHeight()/2;
|
||||
|
@ -24,7 +24,7 @@ class ASFont {
|
||||
public:
|
||||
ASFont(SDL_Surface* font);
|
||||
ASFont(Surface* font);
|
||||
ASFont(string font);
|
||||
ASFont(const string &font);
|
||||
~ASFont();
|
||||
|
||||
bool utf8Code(unsigned char c);
|
||||
|
@ -33,7 +33,7 @@
|
||||
using namespace std;
|
||||
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->text = text;
|
||||
selRow = 0;
|
||||
|
@ -56,7 +56,7 @@ private:
|
||||
|
||||
public:
|
||||
string path;
|
||||
DirDialog(GMenu2X *gmenu2x, string text, string dir="");
|
||||
DirDialog(GMenu2X *gmenu2x, const string &text, const string &dir="");
|
||||
|
||||
bool exec();
|
||||
};
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
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->text = text;
|
||||
this->filter = filter;
|
||||
@ -176,7 +176,7 @@ bool FileDialog::exec() {
|
||||
return result;
|
||||
}
|
||||
|
||||
void FileDialog::setPath(string path) {
|
||||
void FileDialog::setPath(const string &path) {
|
||||
path_v = path;
|
||||
fl.setPath(path);
|
||||
selected = 0;
|
||||
|
@ -51,11 +51,11 @@ protected:
|
||||
|
||||
public:
|
||||
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 string path() { return path_v; };
|
||||
virtual void setPath(string path);
|
||||
virtual const string &path() { return path_v; };
|
||||
virtual void setPath(const string &path);
|
||||
|
||||
inline virtual void beforeFileList();
|
||||
inline virtual void onChangeDir();
|
||||
|
@ -30,26 +30,27 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
FileLister::FileLister(string startPath, bool showDirectories, bool showFiles) {
|
||||
FileLister::FileLister(const string &startPath, bool showDirectories, bool showFiles) {
|
||||
this->showDirectories = showDirectories;
|
||||
this->showFiles = showFiles;
|
||||
setPath(startPath,false);
|
||||
}
|
||||
|
||||
string FileLister::getPath() {
|
||||
const string &FileLister::getPath() {
|
||||
return path;
|
||||
}
|
||||
void FileLister::setPath(string path, bool doBrowse) {
|
||||
if (path[path.length()-1]!='/') path += "/";
|
||||
void FileLister::setPath(const string &path, bool doBrowse) {
|
||||
this->path = path;
|
||||
if (this->path[path.length()-1]!='/')
|
||||
this->path += "/";
|
||||
if (doBrowse)
|
||||
browse();
|
||||
}
|
||||
|
||||
string FileLister::getFilter() {
|
||||
const string &FileLister::getFilter() {
|
||||
return filter;
|
||||
}
|
||||
void FileLister::setFilter(string filter) {
|
||||
void FileLister::setFilter(const string &filter) {
|
||||
this->filter = filter;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ private:
|
||||
bool showDirectories, showFiles;
|
||||
|
||||
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();
|
||||
|
||||
vector<string> directories, files, exclude;
|
||||
@ -45,10 +45,10 @@ public:
|
||||
bool isFile(uint);
|
||||
bool isDirectory(uint);
|
||||
|
||||
string getPath();
|
||||
void setPath(string path, bool doBrowse=true);
|
||||
string getFilter();
|
||||
void setFilter(string filter);
|
||||
const string &getPath();
|
||||
void setPath(const string &path, bool doBrowse=true);
|
||||
const string &getFilter();
|
||||
void setFilter(const string &filter);
|
||||
};
|
||||
|
||||
#endif /*FILELISTER_H_*/
|
||||
|
@ -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";
|
||||
ofstream inf(conffile.c_str());
|
||||
if (inf.is_open()) {
|
||||
@ -1122,7 +1122,7 @@ void GMenu2X::toggleTvOut() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void GMenu2X::setSkin(string skin, bool setWallpaper) {
|
||||
void GMenu2X::setSkin(const string &skin, bool setWallpaper) {
|
||||
confStr["skin"] = skin;
|
||||
|
||||
//Clear previous skin settings
|
||||
@ -1847,7 +1847,7 @@ int GMenu2X::getVolumeScaler() {
|
||||
return currentscalefactor;
|
||||
}
|
||||
|
||||
string GMenu2X::getExePath() {
|
||||
const string &GMenu2X::getExePath() {
|
||||
if (path.empty()) {
|
||||
char 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;
|
||||
}
|
||||
|
||||
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;
|
||||
SDL_Rect re = {x, y-7, 0, 16};
|
||||
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;
|
||||
}
|
||||
|
||||
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 (sc.skinRes("imgs/buttons/"+btn+".png") != NULL) {
|
||||
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"]);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
Surface *i = NULL;
|
||||
@ -1940,12 +1940,12 @@ void GMenu2X::drawTitleIcon(string icon, bool skinRes, Surface *s) {
|
||||
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;
|
||||
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;
|
||||
s->write(font,subtitle,40, skinConfInt["topBarHeight"]/4*3, SFontHAlignLeft, SFontVAlignMiddle);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ private:
|
||||
*/
|
||||
unsigned short getBatteryLevel();
|
||||
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.
|
||||
*/
|
||||
@ -146,7 +146,7 @@ public:
|
||||
@see path
|
||||
@return String containing the parent directory
|
||||
*/
|
||||
string getExePath();
|
||||
const string &getExePath();
|
||||
|
||||
InputManager input;
|
||||
Touchscreen ts;
|
||||
@ -158,7 +158,7 @@ public:
|
||||
|
||||
//Configuration settings
|
||||
bool useSelectionPng;
|
||||
void setSkin(string skin, bool setWallpaper = true);
|
||||
void setSkin(const string &skin, bool setWallpaper = true);
|
||||
//firmware type and version
|
||||
string fwType, fwVersion;
|
||||
//gp2x type
|
||||
@ -212,7 +212,7 @@ public:
|
||||
void writeConfig();
|
||||
void writeConfigOpen2x();
|
||||
void writeSkinConfig();
|
||||
void writeTmp(int selelem=-1, string selectordir="");
|
||||
void writeTmp(int selelem=-1, const string &selectordir="");
|
||||
|
||||
void ledOn();
|
||||
void ledOff();
|
||||
@ -226,13 +226,13 @@ public:
|
||||
|
||||
void initBG();
|
||||
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 drawButtonRight(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, 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 drawTitleIcon(string icon, bool skinRes=true, Surface *s=NULL);
|
||||
void writeTitle(string title, Surface *s=NULL);
|
||||
void writeSubTitle(string subtitle, Surface *s=NULL);
|
||||
void drawTitleIcon(const string &icon, bool skinRes=true, Surface *s=NULL);
|
||||
void writeTitle(const string &title, Surface *s=NULL);
|
||||
void writeSubTitle(const string &subtitle, Surface *s=NULL);
|
||||
void drawTopBar(Surface *s=NULL);
|
||||
void drawBottomBar(Surface *s=NULL);
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
using namespace std;
|
||||
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->icon = icon;
|
||||
labelPosition = IconButton::DISP_RIGHT;
|
||||
@ -93,11 +93,11 @@ void IconButton::recalcSize() {
|
||||
setSize(w, h);
|
||||
}
|
||||
|
||||
string IconButton::getLabel() {
|
||||
const string &IconButton::getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
void IconButton::setLabel(string label) {
|
||||
void IconButton::setLabel(const string &label) {
|
||||
this->label = label;
|
||||
}
|
||||
|
||||
@ -107,11 +107,11 @@ void IconButton::setLabelPosition(int pos, int margin) {
|
||||
recalcSize();
|
||||
}
|
||||
|
||||
string IconButton::getIcon() {
|
||||
const string &IconButton::getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
void IconButton::setIcon(string icon) {
|
||||
void IconButton::setIcon(const string &icon) {
|
||||
this->icon = icon;
|
||||
recalcSize();
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
static const int DISP_TOP = 2;
|
||||
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 void paint();
|
||||
@ -30,12 +30,12 @@ public:
|
||||
|
||||
void setPosition(int x, int y);
|
||||
|
||||
string getLabel();
|
||||
void setLabel(string label);
|
||||
const string &getLabel();
|
||||
void setLabel(const string &label);
|
||||
void setLabelPosition(int pos, int margin);
|
||||
|
||||
string getIcon();
|
||||
void setIcon(string icon);
|
||||
const string &getIcon();
|
||||
void setIcon(const string &icon);
|
||||
|
||||
void setAction(ButtonAction action);
|
||||
};
|
||||
|
@ -31,20 +31,19 @@
|
||||
|
||||
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->text = text;
|
||||
this->filter = filter;
|
||||
this->file = "";
|
||||
setPath("/card");
|
||||
title = "Image Browser";
|
||||
if (!file.empty()) {
|
||||
file = strreplace(file,"skin:",gmenu2x->getExePath()+"skins/"+gmenu2x->confStr["skin"]+"/");
|
||||
string::size_type pos = file.rfind("/");
|
||||
this->file = strreplace(file,"skin:",gmenu2x->getExePath()+"skins/"+gmenu2x->confStr["skin"]+"/");
|
||||
string::size_type pos = this->file.rfind("/");
|
||||
if (pos != string::npos) {
|
||||
setPath( file.substr(0, pos) );
|
||||
setPath( this->file.substr(0, pos) );
|
||||
cout << "ib: " << path() << endl;
|
||||
this->file = file.substr(pos+1,file.length());
|
||||
this->file = this->file.substr(pos+1,file.length());
|
||||
}
|
||||
}
|
||||
selRow = 0;
|
||||
|
@ -31,7 +31,7 @@ class ImageDialog : public FileDialog {
|
||||
protected:
|
||||
SurfaceCollection previews;
|
||||
public:
|
||||
ImageDialog(GMenu2X *gmenu2x, string text, string filter="", string file="");
|
||||
ImageDialog(GMenu2X *gmenu2x, const string &text, const string &filter="", const string &file="");
|
||||
virtual ~ImageDialog();
|
||||
inline virtual void beforeFileList();
|
||||
inline virtual void onChangeDir();
|
||||
|
@ -26,7 +26,7 @@
|
||||
using namespace std;
|
||||
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;
|
||||
if (title=="") {
|
||||
this->title = text;
|
||||
|
@ -67,7 +67,7 @@ private:
|
||||
void setKeyboard(int);
|
||||
|
||||
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;
|
||||
bool exec();
|
||||
|
@ -34,7 +34,7 @@ InputManager::~InputManager() {
|
||||
SDL_JoystickClose(joysticks[x]);
|
||||
}
|
||||
|
||||
void InputManager::init(string conffile) {
|
||||
void InputManager::init(const string &conffile) {
|
||||
SDL_JoystickEventState(SDL_IGNORE);
|
||||
|
||||
int numJoy = SDL_NumJoysticks();
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
|
||||
InputManager();
|
||||
~InputManager();
|
||||
void init(string conffile = "input.conf");
|
||||
void init(const string &conffile = "input.conf");
|
||||
|
||||
vector <SDL_Joystick*> joysticks;
|
||||
vector<bool> actions;
|
||||
|
30
src/link.cpp
30
src/link.cpp
@ -57,59 +57,63 @@ void Link::updateSurfaces()
|
||||
iconSurface = gmenu2x->sc[getIconPath()];
|
||||
}
|
||||
|
||||
string Link::getTitle() {
|
||||
const string &Link::getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
void Link::setTitle(string title) {
|
||||
void Link::setTitle(const string &title) {
|
||||
this->title = title;
|
||||
edited = true;
|
||||
}
|
||||
|
||||
string Link::getDescription() {
|
||||
const string &Link::getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
void Link::setDescription(string description) {
|
||||
void Link::setDescription(const string &description) {
|
||||
this->description = description;
|
||||
edited = true;
|
||||
}
|
||||
|
||||
string Link::getIcon() {
|
||||
const string &Link::getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
void Link::setIcon(string icon) {
|
||||
void Link::setIcon(const string &icon) {
|
||||
string skinpath = gmenu2x->getExePath()+"skins/"+gmenu2x->confStr["skin"];
|
||||
|
||||
if (icon.substr(0,skinpath.length()) == skinpath) {
|
||||
string tempIcon = icon.substr(skinpath.length(), icon.length());
|
||||
string::size_type pos = tempIcon.find("/");
|
||||
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)) {
|
||||
iconPath = strreplace(icon,"skin:",gmenu2x->getExePath()+"skins/Default/");
|
||||
iconPath = strreplace(this->icon,"skin:",gmenu2x->getExePath()+"skins/Default/");
|
||||
if (!fileExists(iconPath)) searchIcon();
|
||||
}
|
||||
|
||||
this->icon = icon;
|
||||
edited = true;
|
||||
updateSurfaces();
|
||||
}
|
||||
|
||||
string Link::searchIcon() {
|
||||
const string &Link::searchIcon() {
|
||||
iconPath = gmenu2x->sc.getSkinFilePath("icons/generic.png");
|
||||
return iconPath;
|
||||
}
|
||||
|
||||
string Link::getIconPath() {
|
||||
const string &Link::getIconPath() {
|
||||
if (iconPath.empty()) searchIcon();
|
||||
return iconPath;
|
||||
}
|
||||
|
||||
void Link::setIconPath(string icon) {
|
||||
void Link::setIconPath(const string &icon) {
|
||||
if (fileExists(icon))
|
||||
iconPath = icon;
|
||||
else
|
||||
|
18
src/link.h
18
src/link.h
@ -59,15 +59,15 @@ public:
|
||||
void setSize(int w, int h);
|
||||
void setPosition(int x, int y);
|
||||
|
||||
string getTitle();
|
||||
void setTitle(string title);
|
||||
string getDescription();
|
||||
void setDescription(string description);
|
||||
string getIcon();
|
||||
void setIcon(string icon);
|
||||
virtual string searchIcon();
|
||||
string getIconPath();
|
||||
void setIconPath(string icon);
|
||||
const string &getTitle();
|
||||
void setTitle(const string &title);
|
||||
const string &getDescription();
|
||||
void setDescription(const string &description);
|
||||
const string &getIcon();
|
||||
void setIcon(const string &icon);
|
||||
virtual const string &searchIcon();
|
||||
const string &getIconPath();
|
||||
void setIconPath(const string &icon);
|
||||
|
||||
virtual void run();
|
||||
};
|
||||
|
@ -109,7 +109,7 @@ LinkApp::LinkApp(GMenu2X *gmenu2x, const char* linkfile)
|
||||
edited = false;
|
||||
}
|
||||
|
||||
string LinkApp::searchIcon() {
|
||||
const string &LinkApp::searchIcon() {
|
||||
string execicon = exec;
|
||||
string::size_type pos = exec.rfind(".");
|
||||
if (pos != string::npos) execicon = exec.substr(0,pos);
|
||||
@ -133,7 +133,7 @@ int LinkApp::clock() {
|
||||
return iclock;
|
||||
}
|
||||
|
||||
string LinkApp::clockStr(int maxClock) {
|
||||
const string &LinkApp::clockStr(int maxClock) {
|
||||
if (iclock>maxClock) setClock(maxClock);
|
||||
return sclock;
|
||||
}
|
||||
@ -152,7 +152,7 @@ int LinkApp::volume() {
|
||||
return ivolume;
|
||||
}
|
||||
|
||||
string LinkApp::volumeStr() {
|
||||
const string &LinkApp::volumeStr() {
|
||||
return svolume;
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ int LinkApp::backlight()
|
||||
return ibacklight;
|
||||
}
|
||||
|
||||
string LinkApp::backlightStr()
|
||||
const string &LinkApp::backlightStr()
|
||||
{
|
||||
return sbacklight;
|
||||
}
|
||||
@ -194,7 +194,7 @@ int LinkApp::gamma() {
|
||||
return igamma;
|
||||
}
|
||||
|
||||
string LinkApp::gammaStr() {
|
||||
const string &LinkApp::gammaStr() {
|
||||
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
|
||||
Selector sel(gmenu2x, this, selectorDir);
|
||||
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();
|
||||
save();
|
||||
#ifndef TARGET_GP2X
|
||||
@ -405,23 +405,27 @@ void LinkApp::launch(string selectedFile, string selectedDir) {
|
||||
//selectedFile
|
||||
if (selectedFile!="") {
|
||||
string selectedFileExtension;
|
||||
string selectedFileName;
|
||||
string dir;
|
||||
string::size_type i = selectedFile.rfind(".");
|
||||
if (i != string::npos) {
|
||||
selectedFileExtension = selectedFile.substr(i,selectedFile.length());
|
||||
selectedFile = selectedFile.substr(0,i);
|
||||
selectedFileName = selectedFile.substr(0,i);
|
||||
}
|
||||
|
||||
if (selectedDir=="")
|
||||
selectedDir = getSelectorDir();
|
||||
dir = getSelectorDir();
|
||||
else
|
||||
dir = selectedDir;
|
||||
if (params=="") {
|
||||
params = cmdclean(selectedDir+selectedFile+selectedFileExtension);
|
||||
params = cmdclean(dir+selectedFile);
|
||||
} else {
|
||||
string origParams = params;
|
||||
params = strreplace(params,"[selFullPath]",cmdclean(selectedDir+selectedFile+selectedFileExtension));
|
||||
params = strreplace(params,"[selPath]",cmdclean(selectedDir));
|
||||
params = strreplace(params,"[selFile]",cmdclean(selectedFile));
|
||||
params = strreplace(params,"[selFullPath]",cmdclean(dir+selectedFile));
|
||||
params = strreplace(params,"[selPath]",cmdclean(dir));
|
||||
params = strreplace(params,"[selFile]",cmdclean(selectedFileName));
|
||||
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());
|
||||
}
|
||||
|
||||
string LinkApp::getExec() {
|
||||
const string &LinkApp::getExec() {
|
||||
return exec;
|
||||
}
|
||||
|
||||
void LinkApp::setExec(string exec) {
|
||||
void LinkApp::setExec(const string &exec) {
|
||||
this->exec = exec;
|
||||
edited = true;
|
||||
}
|
||||
|
||||
string LinkApp::getParams() {
|
||||
const string &LinkApp::getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
void LinkApp::setParams(string params) {
|
||||
void LinkApp::setParams(const string ¶ms) {
|
||||
this->params = params;
|
||||
edited = true;
|
||||
}
|
||||
|
||||
string LinkApp::getWorkdir() {
|
||||
const string &LinkApp::getWorkdir() {
|
||||
return workdir;
|
||||
}
|
||||
|
||||
void LinkApp::setWorkdir(string workdir) {
|
||||
void LinkApp::setWorkdir(const string &workdir) {
|
||||
this->workdir = workdir;
|
||||
edited = true;
|
||||
}
|
||||
|
||||
string LinkApp::getManual() {
|
||||
const string &LinkApp::getManual() {
|
||||
return manual;
|
||||
}
|
||||
|
||||
void LinkApp::setManual(string manual) {
|
||||
void LinkApp::setManual(const string &manual) {
|
||||
this->manual = manual;
|
||||
edited = true;
|
||||
}
|
||||
|
||||
string LinkApp::getSelectorDir() {
|
||||
const string &LinkApp::getSelectorDir() {
|
||||
return selectordir;
|
||||
}
|
||||
|
||||
void LinkApp::setSelectorDir(string selectordir) {
|
||||
if (selectordir!="" && selectordir[selectordir.length()-1]!='/') selectordir += "/";
|
||||
void LinkApp::setSelectorDir(const string &selectordir) {
|
||||
this->selectordir = selectordir;
|
||||
if (this->selectordir!="" && this->selectordir[this->selectordir.length()-1]!='/') this->selectordir += "/";
|
||||
edited = true;
|
||||
}
|
||||
|
||||
@ -544,29 +548,29 @@ void LinkApp::setUseRamTimings(bool value) {
|
||||
edited = true;
|
||||
}
|
||||
|
||||
string LinkApp::getSelectorFilter() {
|
||||
const string &LinkApp::getSelectorFilter() {
|
||||
return selectorfilter;
|
||||
}
|
||||
|
||||
void LinkApp::setSelectorFilter(string selectorfilter) {
|
||||
void LinkApp::setSelectorFilter(const string &selectorfilter) {
|
||||
this->selectorfilter = selectorfilter;
|
||||
edited = true;
|
||||
}
|
||||
|
||||
string LinkApp::getSelectorScreens() {
|
||||
const string &LinkApp::getSelectorScreens() {
|
||||
return selectorscreens;
|
||||
}
|
||||
|
||||
void LinkApp::setSelectorScreens(string selectorscreens) {
|
||||
void LinkApp::setSelectorScreens(const string &selectorscreens) {
|
||||
this->selectorscreens = selectorscreens;
|
||||
edited = true;
|
||||
}
|
||||
|
||||
string LinkApp::getAliasFile() {
|
||||
const string &LinkApp::getAliasFile() {
|
||||
return aliasfile;
|
||||
}
|
||||
|
||||
void LinkApp::setAliasFile(string aliasfile) {
|
||||
void LinkApp::setAliasFile(const string &aliasfile) {
|
||||
if (fileExists(aliasfile)) {
|
||||
this->aliasfile = aliasfile;
|
||||
edited = true;
|
||||
|
@ -52,46 +52,46 @@ private:
|
||||
|
||||
public:
|
||||
LinkApp(GMenu2X *gmenu2x, const char* linkfile);
|
||||
virtual string searchIcon();
|
||||
virtual const string &searchIcon();
|
||||
|
||||
string getExec();
|
||||
void setExec(string exec);
|
||||
string getParams();
|
||||
void setParams(string params);
|
||||
string getWorkdir();
|
||||
void setWorkdir(string workdir);
|
||||
string getManual();
|
||||
void setManual(string manual);
|
||||
string getSelectorDir();
|
||||
void setSelectorDir(string selectordir);
|
||||
const string &getExec();
|
||||
void setExec(const string &exec);
|
||||
const string &getParams();
|
||||
void setParams(const string ¶ms);
|
||||
const string &getWorkdir();
|
||||
void setWorkdir(const string &workdir);
|
||||
const string &getManual();
|
||||
void setManual(const string &manual);
|
||||
const string &getSelectorDir();
|
||||
void setSelectorDir(const string &selectordir);
|
||||
bool getSelectorBrowser();
|
||||
void setSelectorBrowser(bool value);
|
||||
bool getUseRamTimings();
|
||||
void setUseRamTimings(bool value);
|
||||
string getSelectorScreens();
|
||||
void setSelectorScreens(string selectorscreens);
|
||||
string getSelectorFilter();
|
||||
void setSelectorFilter(string selectorfilter);
|
||||
string getAliasFile();
|
||||
void setAliasFile(string aliasfile);
|
||||
const string &getSelectorScreens();
|
||||
void setSelectorScreens(const string &selectorscreens);
|
||||
const string &getSelectorFilter();
|
||||
void setSelectorFilter(const string &selectorfilter);
|
||||
const string &getAliasFile();
|
||||
void setAliasFile(const string &aliasfile);
|
||||
|
||||
string file;
|
||||
|
||||
int clock();
|
||||
string clockStr(int maxClock);
|
||||
const string &clockStr(int maxClock);
|
||||
void setClock(int mhz);
|
||||
|
||||
int volume();
|
||||
string volumeStr();
|
||||
const string &volumeStr();
|
||||
void setVolume(int vol);
|
||||
|
||||
//G
|
||||
int gamma();
|
||||
string gammaStr();
|
||||
const string &gammaStr();
|
||||
void setGamma(int gamma);
|
||||
|
||||
int backlight();
|
||||
string backlightStr();
|
||||
const string &backlightStr();
|
||||
void setBacklight(int val);
|
||||
// /G
|
||||
|
||||
@ -101,8 +101,8 @@ public:
|
||||
bool save();
|
||||
void run();
|
||||
void showManual();
|
||||
void selector(int startSelection=0, string selectorDir="");
|
||||
void launch(string selectedFile="", string selectedDir="");
|
||||
void selector(int startSelection=0, const string &selectorDir="");
|
||||
void launch(const string &selectedFile="", const string &selectedDir="");
|
||||
bool targetExists();
|
||||
};
|
||||
|
||||
|
@ -13,7 +13,7 @@ ListViewItem * ListView::add(ListViewItem *item) {
|
||||
return item;
|
||||
}
|
||||
|
||||
ListViewItem * ListView::add(string text) {
|
||||
ListViewItem * ListView::add(const string &text) {
|
||||
ListViewItem *item = new ListViewItem(this,text);
|
||||
return add(item);
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
GMenu2X *gmenu2x;
|
||||
|
||||
ListViewItem *add(ListViewItem *item);
|
||||
ListViewItem *add(string text);
|
||||
ListViewItem *add(const string &text);
|
||||
void del(ListViewItem *item);
|
||||
void del(int itemIndex);
|
||||
void clear();
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "listview.h"
|
||||
#include "listviewitem.h"
|
||||
|
||||
ListViewItem::ListViewItem(ListView * parent, string text) {
|
||||
ListViewItem::ListViewItem(ListView * parent, const string &text) {
|
||||
this->parent = parent;
|
||||
rect.h = 16;
|
||||
rect.w = parent->getWidth();
|
||||
|
@ -32,7 +32,7 @@ protected:
|
||||
SDL_Rect rect;
|
||||
|
||||
public:
|
||||
ListViewItem(ListView *parent, string text);
|
||||
ListViewItem(ListView *parent, const string &text);
|
||||
virtual ~ListViewItem();
|
||||
|
||||
string text;
|
||||
|
@ -133,7 +133,7 @@ int Menu::selSectionIndex() {
|
||||
return iSection;
|
||||
}
|
||||
|
||||
string Menu::selSection() {
|
||||
const string &Menu::selSection() {
|
||||
return sections[iSection];
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ string Menu::sectionPath(int section) {
|
||||
/*====================================
|
||||
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;
|
||||
|
||||
LinkAction *linkact = new LinkAction(gmenu2x,action);
|
||||
@ -183,7 +183,6 @@ bool Menu::addLink(string path, string file, string section) {
|
||||
if (!addSection(section))
|
||||
return false;
|
||||
}
|
||||
if (path[path.length()-1]!='/') path += "/";
|
||||
|
||||
//if the extension is not equal to gpu or dge then enable the wrapepr by default
|
||||
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;
|
||||
#endif
|
||||
|
||||
if (path[path.length()-1]!='/') path += "/";
|
||||
//search for a manual
|
||||
pos = file.rfind(".");
|
||||
string exename = path+file.substr(0,pos);
|
||||
@ -306,7 +306,7 @@ bool Menu::addLink(string path, string file, string section) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Menu::addSection(string sectionName) {
|
||||
bool Menu::addSection(const string §ionName) {
|
||||
string sectiondir = "sections/"+sectionName;
|
||||
if (mkdir(sectiondir.c_str(),0777)==0) {
|
||||
sections.push_back(sectionName);
|
||||
|
@ -54,16 +54,16 @@ public:
|
||||
linklist *sectionLinks(int i = -1);
|
||||
|
||||
int selSectionIndex();
|
||||
string selSection();
|
||||
const string &selSection();
|
||||
void decSectionIndex();
|
||||
void incSectionIndex();
|
||||
void setSectionIndex(int i);
|
||||
uint firstDispSection();
|
||||
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 addSection(string sectionName);
|
||||
bool addSection(const string §ionName);
|
||||
void deleteSelectedLink();
|
||||
void deleteSelectedSection();
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
***************************************************************************/
|
||||
#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->name = name;
|
||||
this->description = description;
|
||||
|
@ -38,7 +38,7 @@ private:
|
||||
GMenu2X *gmenu2x;
|
||||
|
||||
public:
|
||||
MenuSetting(GMenu2X *gmenu2x, string name, string description);
|
||||
MenuSetting(GMenu2X *gmenu2x, const string &name, const string &description);
|
||||
virtual ~MenuSetting() {};
|
||||
|
||||
virtual void draw(int y);
|
||||
|
@ -24,7 +24,7 @@
|
||||
using namespace std;
|
||||
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) {
|
||||
this->gmenu2x = gmenu2x;
|
||||
_ivalue = value;
|
||||
@ -36,7 +36,7 @@ MenuSettingBool::MenuSettingBool(GMenu2X *gmenu2x, string name, string descripti
|
||||
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) {
|
||||
this->gmenu2x = gmenu2x;
|
||||
_value = value;
|
||||
|
@ -38,8 +38,8 @@ private:
|
||||
void toggle();
|
||||
|
||||
public:
|
||||
MenuSettingBool(GMenu2X *gmenu2x, string name, string description, bool *value);
|
||||
MenuSettingBool(GMenu2X *gmenu2x, string name, string description, int *value);
|
||||
MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, bool *value);
|
||||
MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, int *value);
|
||||
virtual ~MenuSettingBool() {};
|
||||
|
||||
virtual void draw(int y);
|
||||
|
@ -24,7 +24,7 @@
|
||||
using namespace std;
|
||||
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) {
|
||||
this->gmenu2x = gmenu2x;
|
||||
_value = value;
|
||||
@ -61,11 +61,11 @@ void MenuSettingDir::select() {
|
||||
if (dd.exec()) setValue( dd.path );
|
||||
}
|
||||
|
||||
void MenuSettingDir::setValue(string value) {
|
||||
void MenuSettingDir::setValue(const string &value) {
|
||||
*_value = value;
|
||||
}
|
||||
|
||||
string MenuSettingDir::value() {
|
||||
const string &MenuSettingDir::value() {
|
||||
return *_value;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ private:
|
||||
void clear();
|
||||
|
||||
public:
|
||||
MenuSettingDir(GMenu2X *gmenu2x, string name, string description, string *value);
|
||||
MenuSettingDir(GMenu2X *gmenu2x, const string &name, const string &description, string *value);
|
||||
virtual ~MenuSettingDir() {};
|
||||
|
||||
virtual void draw(int y);
|
||||
@ -46,8 +46,8 @@ public:
|
||||
virtual void drawSelected(int y);
|
||||
virtual bool edited();
|
||||
|
||||
void setValue(string value);
|
||||
string value();
|
||||
void setValue(const string &value);
|
||||
const string &value();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -24,7 +24,7 @@
|
||||
using namespace std;
|
||||
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) {
|
||||
this->gmenu2x = gmenu2x;
|
||||
this->filter = filter;
|
||||
@ -62,11 +62,11 @@ void MenuSettingFile::select() {
|
||||
if (fd.exec()) setValue( fd.path()+"/"+fd.file );
|
||||
}
|
||||
|
||||
void MenuSettingFile::setValue(string value) {
|
||||
void MenuSettingFile::setValue(const string &value) {
|
||||
*_value = value;
|
||||
}
|
||||
|
||||
string MenuSettingFile::value() {
|
||||
const string &MenuSettingFile::value() {
|
||||
return *_value;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ protected:
|
||||
void clear();
|
||||
|
||||
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 void draw(int y);
|
||||
@ -47,8 +47,8 @@ public:
|
||||
virtual void drawSelected(int y);
|
||||
virtual bool edited();
|
||||
|
||||
virtual void setValue(string value);
|
||||
string value();
|
||||
virtual void setValue(const string &value);
|
||||
const string &value();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
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) {
|
||||
this->gmenu2x = gmenu2x;
|
||||
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"];
|
||||
bool inSkinDir = value.substr(0,skinpath.length()) == skinpath;
|
||||
if (!inSkinDir && gmenu2x->confStr["skin"] != "Default") {
|
||||
@ -50,7 +50,10 @@ void MenuSettingImage::setValue(string value) {
|
||||
string tempIcon = value.substr(skinpath.length(), value.length());
|
||||
string::size_type pos = tempIcon.find("/");
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -27,11 +27,11 @@ using std::string;
|
||||
|
||||
class MenuSettingImage : public MenuSettingFile {
|
||||
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 void manageInput();
|
||||
virtual void setValue(string value);
|
||||
virtual void setValue(const string &value);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -24,7 +24,7 @@
|
||||
using namespace std;
|
||||
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) {
|
||||
this->gmenu2x = gmenu2x;
|
||||
_value = value;
|
||||
|
@ -39,7 +39,7 @@ private:
|
||||
void dec();
|
||||
|
||||
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 void draw(int y);
|
||||
|
@ -23,7 +23,7 @@
|
||||
using namespace std;
|
||||
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) {
|
||||
this->gmenu2x = gmenu2x;
|
||||
this->choices = choices;
|
||||
|
@ -39,7 +39,7 @@ private:
|
||||
void setSel(int);
|
||||
|
||||
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 void draw(int y);
|
||||
|
@ -23,7 +23,7 @@
|
||||
using namespace std;
|
||||
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) {
|
||||
selPart = 0;
|
||||
this->gmenu2x = gmenu2x;
|
||||
|
@ -42,7 +42,7 @@ private:
|
||||
void rightComponent();
|
||||
|
||||
public:
|
||||
MenuSettingRGBA(GMenu2X *gmenu2x, string name, string description, RGBAColor *value);
|
||||
MenuSettingRGBA(GMenu2X *gmenu2x, const string &name, const string &description, RGBAColor *value);
|
||||
virtual ~MenuSettingRGBA() {};
|
||||
|
||||
virtual void draw(int y);
|
||||
|
@ -24,7 +24,7 @@
|
||||
using namespace std;
|
||||
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) {
|
||||
this->gmenu2x = gmenu2x;
|
||||
_value = value;
|
||||
@ -53,11 +53,11 @@ void MenuSettingString::manageInput() {
|
||||
if ( gmenu2x->input[ACTION_B] ) edit();
|
||||
}
|
||||
|
||||
void MenuSettingString::setValue(string value) {
|
||||
void MenuSettingString::setValue(const string &value) {
|
||||
*_value = value;
|
||||
}
|
||||
|
||||
string MenuSettingString::value() {
|
||||
const string &MenuSettingString::value() {
|
||||
return *_value;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ private:
|
||||
void clear();
|
||||
|
||||
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 void draw(int y);
|
||||
@ -46,8 +46,8 @@ public:
|
||||
virtual void drawSelected(int y);
|
||||
virtual bool edited();
|
||||
|
||||
void setValue(string value);
|
||||
string value();
|
||||
void setValue(const string &value);
|
||||
const string &value();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
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->text = text;
|
||||
this->icon = icon;
|
||||
|
@ -38,7 +38,7 @@ private:
|
||||
GMenu2X *gmenu2x;
|
||||
|
||||
public:
|
||||
MessageBox(GMenu2X *gmenu2x, string text, string icon="");
|
||||
MessageBox(GMenu2X *gmenu2x, const string &text, const string &icon="");
|
||||
vector<string> buttons;
|
||||
vector<string> buttonLabels;
|
||||
vector<SDL_Rect> buttonPositions;
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
Selector::Selector(GMenu2X *gmenu2x, LinkApp *link, string selectorDir) {
|
||||
Selector::Selector(GMenu2X *gmenu2x, LinkApp *link, const string &selectorDir) {
|
||||
this->gmenu2x = gmenu2x;
|
||||
this->link = link;
|
||||
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);
|
||||
if (i == aliases.end())
|
||||
return "";
|
||||
|
@ -41,13 +41,13 @@ private:
|
||||
|
||||
hash_map<string, string> aliases;
|
||||
void loadAliases();
|
||||
string getAlias(string key);
|
||||
string getAlias(const string &key);
|
||||
void prepare(FileLister *fl, vector<string> *screens, vector<string> *titles);
|
||||
void freeScreenshots(vector<string> *screens);
|
||||
|
||||
public:
|
||||
string file, dir;
|
||||
Selector(GMenu2X *gmenu2x, LinkApp *link, string selectorDir="");
|
||||
Selector(GMenu2X *gmenu2x, LinkApp *link, const string &selectorDir="");
|
||||
|
||||
int exec(int startSelection=0);
|
||||
};
|
||||
|
@ -11,7 +11,7 @@ SelectorDetector::SelectorDetector() {
|
||||
useSelectorBackground = false;
|
||||
}
|
||||
|
||||
SelectorDetector::SelectorDetector(string config) {
|
||||
SelectorDetector::SelectorDetector(const string &config) {
|
||||
useSelectorBackground = false;
|
||||
readSelectorConfig(config);
|
||||
}
|
||||
@ -20,7 +20,7 @@ SelectorDetector::~SelectorDetector() {
|
||||
//dtor
|
||||
}
|
||||
|
||||
bool SelectorDetector::readSelectorConfig(string config) {
|
||||
bool SelectorDetector::readSelectorConfig(const string &config) {
|
||||
if (fileExists(config)) {
|
||||
ifstream inf(config.c_str(), ios_base::in);
|
||||
if (inf.is_open()) {
|
||||
|
@ -37,10 +37,10 @@ class SelectorDetector
|
||||
{
|
||||
public:
|
||||
SelectorDetector();
|
||||
SelectorDetector(string config);
|
||||
SelectorDetector(const string &config);
|
||||
~SelectorDetector();
|
||||
|
||||
bool readSelectorConfig(string config);
|
||||
bool readSelectorConfig(const string &config);
|
||||
|
||||
string getApplication(){return application;}
|
||||
string getFilePath(){return filePath;}
|
||||
@ -51,8 +51,8 @@ class SelectorDetector
|
||||
string application;
|
||||
string filePath;
|
||||
string filters;
|
||||
//bool isSelectorGPE(string gpe);
|
||||
//string getSelectorConfig(string gpe); // Looks in the GPE for the location of the selectorconfig
|
||||
//bool isSelectorGPE(const string &gpe);
|
||||
//string getSelectorConfig(const string &gpe); // Looks in the GPE for the location of the selectorconfig
|
||||
};
|
||||
|
||||
#endif // SELECTORDETECTOR_H
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
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->text = text;
|
||||
|
||||
|
@ -40,7 +40,7 @@ private:
|
||||
GMenu2X *gmenu2x;
|
||||
|
||||
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();
|
||||
|
||||
bool edited();
|
||||
|
@ -46,7 +46,7 @@ SFontPlus::SFontPlus(SDL_Surface* font) {
|
||||
initFont(font);
|
||||
}
|
||||
|
||||
SFontPlus::SFontPlus(string font) {
|
||||
SFontPlus::SFontPlus(const string &font) {
|
||||
surface = NULL;
|
||||
initFont(font);
|
||||
}
|
||||
@ -60,7 +60,7 @@ bool SFontPlus::utf8Code(unsigned char c) {
|
||||
//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());
|
||||
if (buf!=NULL) {
|
||||
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();
|
||||
this->characters = characters;
|
||||
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;
|
||||
|
||||
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;
|
||||
int width = 0;
|
||||
|
||||
|
@ -24,18 +24,18 @@ private:
|
||||
public:
|
||||
SFontPlus();
|
||||
SFontPlus(SDL_Surface *font);
|
||||
SFontPlus(string font);
|
||||
SFontPlus(const string &font);
|
||||
~SFontPlus();
|
||||
|
||||
bool utf8Code(unsigned char c);
|
||||
|
||||
void initFont(SDL_Surface *font, string characters = SFONTPLUS_CHARSET);
|
||||
void initFont(string font, string characters = SFONTPLUS_CHARSET);
|
||||
void initFont(SDL_Surface *font, const string &characters = SFONTPLUS_CHARSET);
|
||||
void initFont(const string &font, const string &characters = SFONTPLUS_CHARSET);
|
||||
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 getLineHeight();
|
||||
};
|
||||
|
@ -26,7 +26,7 @@ using namespace std;
|
||||
#include "surface.h"
|
||||
#include "utilities.h"
|
||||
|
||||
RGBAColor strtorgba(string strColor) {
|
||||
RGBAColor strtorgba(const string &strColor) {
|
||||
RGBAColor c = {0,0,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 );
|
||||
@ -40,7 +40,7 @@ Surface::Surface() {
|
||||
dblbuffer = NULL;
|
||||
}
|
||||
|
||||
Surface::Surface(string img, bool alpha, string skin) {
|
||||
Surface::Surface(const string &img, bool alpha, const string &skin) {
|
||||
raw = NULL;
|
||||
dblbuffer = NULL;
|
||||
load(img, alpha, skin);
|
||||
@ -48,7 +48,7 @@ Surface::Surface(string img, bool alpha, string skin) {
|
||||
halfH = raw->h/2;
|
||||
}
|
||||
|
||||
Surface::Surface(string img, string skin, bool alpha) {
|
||||
Surface::Surface(const string &img, const string &skin, bool alpha) {
|
||||
raw = NULL;
|
||||
dblbuffer = NULL;
|
||||
load(img, alpha, skin);
|
||||
@ -111,7 +111,7 @@ SDL_PixelFormat *Surface::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();
|
||||
|
||||
string skinpath;
|
||||
@ -119,10 +119,11 @@ void Surface::load(string img, bool alpha, string skin) {
|
||||
skinpath = "skins/"+skin+"/"+img;
|
||||
if (!fileExists(skinpath))
|
||||
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 (alpha)
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ struct RGBAColor {
|
||||
unsigned short r,g,b,a;
|
||||
};
|
||||
|
||||
RGBAColor strtorgba(string strColor);
|
||||
RGBAColor strtorgba(const string &strColor);
|
||||
|
||||
/**
|
||||
Wrapper around SDL_Surface
|
||||
@ -46,8 +46,8 @@ private:
|
||||
|
||||
public:
|
||||
Surface();
|
||||
Surface(string img, string skin="", bool alpha=true);
|
||||
Surface(string img, bool alpha, string skin="");
|
||||
Surface(const string &img, const string &skin="", bool alpha=true);
|
||||
Surface(const string &img, bool alpha, const string &skin="");
|
||||
Surface(SDL_Surface *s, SDL_PixelFormat *fmt = NULL, Uint32 flags = 0);
|
||||
Surface(Surface *s);
|
||||
Surface(int w, int h, Uint32 flags = SDL_HWSURFACE|SDL_SRCALPHA);
|
||||
@ -58,7 +58,7 @@ public:
|
||||
SDL_Surface *raw;
|
||||
|
||||
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 unlock();
|
||||
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(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);
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
SurfaceCollection::SurfaceCollection(bool defaultAlpha, string skin) {
|
||||
SurfaceCollection::SurfaceCollection(bool defaultAlpha, const string &skin) {
|
||||
surfaces.set_empty_key(" ");
|
||||
surfaces.set_deleted_key("");
|
||||
this->defaultAlpha = defaultAlpha;
|
||||
@ -31,11 +31,11 @@ SurfaceCollection::SurfaceCollection(bool defaultAlpha, string skin) {
|
||||
|
||||
SurfaceCollection::~SurfaceCollection() {}
|
||||
|
||||
void SurfaceCollection::setSkin(string skin) {
|
||||
void SurfaceCollection::setSkin(const string &skin) {
|
||||
this->skin = skin;
|
||||
}
|
||||
|
||||
string SurfaceCollection::getSkinFilePath(string file) {
|
||||
string SurfaceCollection::getSkinFilePath(const string &file) {
|
||||
string prefix = "/usr/share/gmenu2x/";
|
||||
if (fileExists("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();
|
||||
}
|
||||
|
||||
Surface *SurfaceCollection::add(Surface *s, string path) {
|
||||
Surface *SurfaceCollection::add(Surface *s, const string &path) {
|
||||
if (exists(path)) del(path);
|
||||
surfaces[path] = s;
|
||||
return s;
|
||||
}
|
||||
|
||||
Surface *SurfaceCollection::add(string path, bool alpha) {
|
||||
Surface *SurfaceCollection::add(const string &path, bool alpha) {
|
||||
#ifdef DEBUG
|
||||
cout << "Adding surface: " << path << endl;
|
||||
#endif
|
||||
@ -82,7 +82,7 @@ Surface *SurfaceCollection::add(string path, bool alpha) {
|
||||
return s;
|
||||
}
|
||||
|
||||
Surface *SurfaceCollection::addSkinRes(string path, bool alpha) {
|
||||
Surface *SurfaceCollection::addSkinRes(const string &path, bool alpha) {
|
||||
#ifdef DEBUG
|
||||
cout << "Adding skin surface: " << path << endl;
|
||||
#endif
|
||||
@ -99,7 +99,7 @@ Surface *SurfaceCollection::addSkinRes(string path, bool alpha) {
|
||||
return s;
|
||||
}
|
||||
|
||||
void SurfaceCollection::del(string path) {
|
||||
void SurfaceCollection::del(const string &path) {
|
||||
SurfaceHash::iterator i = surfaces.find(path);
|
||||
if (i != surfaces.end()) {
|
||||
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);
|
||||
surfaces[to] = surfaces[from];
|
||||
surfaces.erase(from);
|
||||
}
|
||||
|
||||
Surface *SurfaceCollection::operator[](string key) {
|
||||
Surface *SurfaceCollection::operator[](const string &key) {
|
||||
SurfaceHash::iterator i = surfaces.find(key);
|
||||
if (i == surfaces.end())
|
||||
return add(key, defaultAlpha);
|
||||
@ -129,7 +129,7 @@ Surface *SurfaceCollection::operator[](string key) {
|
||||
return i->second;
|
||||
}
|
||||
|
||||
Surface *SurfaceCollection::skinRes(string key) {
|
||||
Surface *SurfaceCollection::skinRes(const string &key) {
|
||||
if (key.empty()) return NULL;
|
||||
|
||||
SurfaceHash::iterator i = surfaces.find(key);
|
||||
|
@ -39,25 +39,25 @@ private:
|
||||
string skin;
|
||||
|
||||
public:
|
||||
SurfaceCollection(bool defaultAlpha=true, string skin="default");
|
||||
SurfaceCollection(bool defaultAlpha=true, const string &skin="default");
|
||||
~SurfaceCollection();
|
||||
|
||||
void setSkin(string skin);
|
||||
string getSkinFilePath(string file);
|
||||
void setSkin(const string &skin);
|
||||
string getSkinFilePath(const string &file);
|
||||
|
||||
bool defaultAlpha;
|
||||
void debug();
|
||||
|
||||
Surface *add(Surface *s, string path);
|
||||
Surface *add(string path, bool alpha=true);
|
||||
Surface *addSkinRes(string path, bool alpha=true);
|
||||
void del(string path);
|
||||
Surface *add(Surface *s, const string &path);
|
||||
Surface *add(const string &path, bool alpha=true);
|
||||
Surface *addSkinRes(const string &path, bool alpha=true);
|
||||
void del(const string &path);
|
||||
void clear();
|
||||
void move(string from, string to);
|
||||
bool exists(string path);
|
||||
void move(const string &from, const string &to);
|
||||
bool exists(const string &path);
|
||||
|
||||
Surface *operator[](string);
|
||||
Surface *skinRes(string);
|
||||
Surface *operator[](const string &);
|
||||
Surface *skinRes(const string &);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
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->text = text;
|
||||
this->title = title;
|
||||
|
@ -37,7 +37,7 @@ protected:
|
||||
void drawText(vector<string> *text, uint firstRow, uint rowsPerPage);
|
||||
|
||||
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();
|
||||
};
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
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) {
|
||||
this->gmenu2x = gmenu2x;
|
||||
|
||||
|
@ -38,7 +38,7 @@ private:
|
||||
vector<ManualPage> pages;
|
||||
|
||||
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();
|
||||
};
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
Translator::Translator(string lang) {
|
||||
Translator::Translator(const string &lang) {
|
||||
_lang = "";
|
||||
if (!lang.empty())
|
||||
setLang(lang);
|
||||
@ -34,11 +34,11 @@ Translator::Translator(string lang) {
|
||||
|
||||
Translator::~Translator() {}
|
||||
|
||||
bool Translator::exists(string term) {
|
||||
bool Translator::exists(const string &term) {
|
||||
return translations.find(term) != translations.end();
|
||||
}
|
||||
|
||||
void Translator::setLang(string lang) {
|
||||
void Translator::setLang(const string &lang) {
|
||||
translations.clear();
|
||||
|
||||
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;
|
||||
|
||||
if (!_lang.empty()) {
|
||||
@ -87,7 +87,7 @@ string Translator::translate(string term,const char *replacestr,...) {
|
||||
return result;
|
||||
}
|
||||
|
||||
string Translator::operator[](string term) {
|
||||
string Translator::operator[](const string &term) {
|
||||
return translate(term);
|
||||
}
|
||||
|
||||
|
@ -33,14 +33,14 @@ private:
|
||||
hash_map<string, string> translations;
|
||||
|
||||
public:
|
||||
Translator(string lang="");
|
||||
Translator(const string &lang="");
|
||||
~Translator();
|
||||
|
||||
string lang();
|
||||
void setLang(string lang);
|
||||
bool exists(string term);
|
||||
string translate(string term,const char *replacestr=NULL,...);
|
||||
string operator[](string term);
|
||||
void setLang(const string &lang);
|
||||
bool exists(const string &term);
|
||||
string translate(const string &term,const char *replacestr=NULL,...);
|
||||
string operator[](const string &term);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -43,18 +43,18 @@ string trim(const string& s) {
|
||||
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());
|
||||
strcpy(*cs, s.c_str());
|
||||
}
|
||||
|
||||
char * string_copy(string s) {
|
||||
char * string_copy(const string &s) {
|
||||
char *cs = NULL;
|
||||
string_copy(s, &cs);
|
||||
return cs;
|
||||
}
|
||||
|
||||
bool fileExists(string file) {
|
||||
bool fileExists(const string &file) {
|
||||
fstream fin;
|
||||
fin.open(file.c_str() ,ios::in);
|
||||
bool exists = fin.is_open();
|
||||
@ -115,10 +115,10 @@ int evalIntConf (int *val, int def, int imin, int imax) {
|
||||
return *val;
|
||||
}
|
||||
|
||||
string evalStrConf (string val, string def) {
|
||||
const string &evalStrConf (const string &val, const string &def) {
|
||||
return val.empty() ? def : val;
|
||||
}
|
||||
string evalStrConf (string *val, string def) {
|
||||
const string &evalStrConf (string *val, const string &def) {
|
||||
*val = evalStrConf(*val, def);
|
||||
return *val;
|
||||
}
|
||||
@ -158,7 +158,7 @@ bool split (vector<string> &vec, const string &str, const string &delim, bool de
|
||||
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 );
|
||||
while (pos != string::npos) {
|
||||
orig.replace(pos,search.length(),replace);
|
||||
|
@ -49,17 +49,17 @@ struct eqstr {
|
||||
|
||||
class case_less {
|
||||
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 strreplace (string orig, string search, string replace);
|
||||
string strreplace (string orig, const string &search, const string &replace);
|
||||
string cmdclean (string cmdline);
|
||||
|
||||
char *string_copy(string);
|
||||
void string_copy(string, char **);
|
||||
char *string_copy(const string &);
|
||||
void string_copy(const string &, char **);
|
||||
|
||||
bool fileExists(string file);
|
||||
bool fileExists(const string &file);
|
||||
bool rmtree(string path);
|
||||
|
||||
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);
|
||||
string evalStrConf (string val, string def);
|
||||
string evalStrConf (string *val, string def);
|
||||
const string &evalStrConf (const string &val, const string &def);
|
||||
const string &evalStrConf (string *val, const string &def);
|
||||
|
||||
bool split (vector<string> &vec, const string &str, const string &delim, bool destructive=true);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user