Commit 2559f5bc authored by IOhannes m zmölnig's avatar IOhannes m zmölnig
Browse files

"const std::string" -> "const std::string&"

if the string is const, we can as well pass it by reference...

these changes should be API compatible, but might break ABI
parent ebc50987
......@@ -171,7 +171,7 @@ void CPPExtern :: error(const char*fmt,...) const
typedef int (*close_t)(int fd);
std::string CPPExtern::findFile(const std::string f, const std::string e) const {
std::string CPPExtern::findFile(const std::string&f, const std::string&e) const {
std::string result;
gem::RTE::RTE*rte=gem::RTE::RTE::getRuntimeEnvironment();
if(rte) {
......@@ -180,7 +180,7 @@ std::string CPPExtern::findFile(const std::string f, const std::string e) const
return result;
}
std::string CPPExtern::findFile(const std::string file) const {
std::string CPPExtern::findFile(const std::string&file) const {
return findFile(file, "");
}
......
......@@ -146,8 +146,8 @@ class GEM_EXTERN CPPExtern
// wraps open_via_path() and canvas_makefilename()
// the full filename is returned
// if the file does not exist, it is constructed
std::string findFile(const std::string filename, const std::string ext) const;
std::string findFile(const std::string filename) const;
std::string findFile(const std::string&filename, const std::string&ext) const;
std::string findFile(const std::string&filename) const;
private:
mutable bool m_endpost; /* internal state for startpost/post/endpost */
......
......@@ -97,7 +97,7 @@ class GEM_EXTERN TextBase : public GemBase
//////////
// The font to use
virtual void fontNameMess(const std::string filename);
virtual void fontNameMess(const std::string&filename);
//////////
// set line distance
......
......@@ -147,7 +147,7 @@ void TextBase :: setPrecision(float prec)
// fontNameMess
//
////////////////////////////////////////////////////////
void TextBase :: fontNameMess(const std::string filename){
void TextBase :: fontNameMess(const std::string&filename){
m_valid = 0;
const char *bufptr=NULL;
int fd=-1;
......
......@@ -94,7 +94,7 @@ public:
return fullname_;
}
static GemDylibHandle*open(const std::string filename) {
static GemDylibHandle*open(const std::string&filename) {
GemDylibHandle*handle=new GemDylibHandle();
if(filename.empty()) {
......@@ -170,7 +170,7 @@ public:
return NULL;
}
static GemDylibHandle*open(const CPPExtern*obj, const std::string filename, const std::string extension) {
static GemDylibHandle*open(const CPPExtern*obj, const std::string&filename, const std::string&extension) {
//const t_canvas*canvas=(obj)?(const_cast<CPPExtern*>(obj)->getCanvas()):0;
const char*ext=extension.c_str();
......@@ -221,7 +221,7 @@ const std::string GemDylibHandle::defaultExtension =
;
GemDylib::GemDylib(const CPPExtern*obj, const std::string filename, const std::string extension)
GemDylib::GemDylib(const CPPExtern*obj, const std::string&filename, const std::string&extension)
: m_handle(0) {
m_handle=GemDylibHandle::open(obj, filename, extension);
if(NULL==m_handle) {
......@@ -237,7 +237,7 @@ GemDylib::GemDylib(const CPPExtern*obj, const std::string filename, const std::s
s_dylibs.push_back(this);
}
GemDylib::GemDylib(const std::string filename, const std::string extension)
GemDylib::GemDylib(const std::string&filename, const std::string&extension)
: m_handle(0) {
m_handle=GemDylibHandle::open(filename+extension);
if(NULL==m_handle)
......@@ -287,7 +287,7 @@ GemDylib& GemDylib::operator=(const GemDylib&org) {
}
GemDylib::function_t GemDylib::proc(const std::string procname) {
GemDylib::function_t GemDylib::proc(const std::string&procname) {
function_t result=NULL;
// if(NULL==procname)return NULL;
#ifdef DL_OPEN
......@@ -305,7 +305,7 @@ GemDylib::function_t GemDylib::proc(const std::string procname) {
return result;
}
bool GemDylib::run(const std::string procname) {
bool GemDylib::run(const std::string&procname) {
function_t runproc=proc(procname);
if(runproc) {
(runproc)();
......@@ -314,7 +314,7 @@ bool GemDylib::run(const std::string procname) {
return false;
}
bool GemDylib::LoadLib(const std::string basefilename, const std::string extension, const std::string procname) {
bool GemDylib::LoadLib(const std::string&basefilename, const std::string&extension, const std::string&procname) {
try {
GemDylib*dylib=new GemDylib(basefilename, extension);
if(NULL!=dylib) {
......
......@@ -26,11 +26,11 @@ class GEM_EXTERN GemDylib {
public:
GemDylib(const CPPExtern*obj,
const std::string libname,
const std::string extension=std::string("")
const std::string&libname,
const std::string&extension=std::string("")
); // throws GemException
GemDylib(const std::string libname,
const std::string extension=std::string("")
GemDylib(const std::string&libname,
const std::string&extension=std::string("")
); // throws GemException
GemDylib(const GemDylib&);
......@@ -43,10 +43,10 @@ class GEM_EXTERN GemDylib {
// if void<procname>(void) exists in dylib, run it and return "true"
// else return false;
bool run(const std::string procname);
bool run(const std::string&procname);
// if <procname> exists in dylib, return it, else return NULL
function_t proc(const std::string procname);
function_t proc(const std::string&procname);
public:
/**
......@@ -54,9 +54,9 @@ class GEM_EXTERN GemDylib {
* if "extension" is NULL, a platform-specific default is used
* on success "true" is returned, else "false
*/
static bool LoadLib(const std::string procname,
const std::string baselibname,
const std::string fileext=std::string(""));
static bool LoadLib(const std::string&procname,
const std::string&baselibname,
const std::string&fileext=std::string(""));
static const std::string getDefaultExtension(void);
......
......@@ -24,7 +24,7 @@ GemException::GemException(const char *error)
: ErrorString(error)
{}
GemException::GemException(const std::string error)
GemException::GemException(const std::string&error)
: ErrorString(error)
{}
......
......@@ -41,13 +41,13 @@ class GEM_EXTERN GemException
public:
GemException(void);
GemException(const char*error);
GemException(const std::string error);
GemException(const std::string&error);
virtual ~GemException(void);
virtual const char *what(void) const;
virtual void report(const char*origin=0) const;
private:
const std::string ErrorString;
const std::string&ErrorString;
};
namespace gem {
......
......@@ -48,7 +48,7 @@ namespace gem {
* the loaded image is stored in 'img'
* 'props' holds a list of additional image properties discovered during loading
*/
static bool sync(const std::string filename,
static bool sync(const std::string&filename,
imageStruct&img,
Properties&props);
......@@ -97,7 +97,7 @@ namespace gem {
*/
static bool async(callback cb,
void*userdata,
const std::string filename,
const std::string&filename,
id_t&ID
);
......@@ -113,7 +113,7 @@ namespace gem {
*/
static bool sync(callback cb,
void*userdata,
const std::string filename,
const std::string&filename,
id_t&ID);
/*
......
......@@ -135,7 +135,7 @@ namespace gem { namespace image {
const load::id_t load::IMMEDIATE= 0;
const load::id_t load::INVALID =~0;
bool load::sync(const std::string filename,
bool load::sync(const std::string&filename,
imageStruct&result,
gem::Properties&props) {
if(!PixImageThreadLoader::s_imageloader)
......@@ -150,7 +150,7 @@ namespace gem { namespace image {
bool load::async(load::callback cb,
void*userdata,
const std::string filename,
const std::string&filename,
id_t&ID) {
if(NULL==cb) {
ID=INVALID;
......@@ -169,7 +169,7 @@ namespace gem { namespace image {
bool load::sync(load::callback cb,
void*userdata,
const std::string filename,
const std::string&filename,
id_t&ID) {
if(NULL==cb) {
ID=INVALID;
......
......@@ -126,7 +126,7 @@ namespace gem {
return result;
}
enum Properties::PropertyType Properties::type(std::string key) const {
enum Properties::PropertyType Properties::type(const std::string&key) const {
std::map<std::string, enum Properties::PropertyType>::iterator it=pimpl->typemap.find(key);
if(pimpl->typemap.end() == it)
return UNSET;
......@@ -134,7 +134,7 @@ namespace gem {
return it->second;
}
void Properties::erase(std::string key) {
void Properties::erase(const std::string&key) {
pimpl->typemap.erase(key);
pimpl->valuemap.erase(key);
}
......
......@@ -63,7 +63,7 @@ namespace gem
* if the key was in the property-map, return the type of the property
* if no key of the given value exists, return <code>PropertyType::UNSET</code>
*/
virtual enum PropertyType type(const std::string) const;
virtual enum PropertyType type(const std::string&) const;
/* set a property
* e.g.: double w=640; prop.set("width", w);
......@@ -92,7 +92,7 @@ namespace gem
/*
* delete a given key from the Properties
*/
virtual void erase(const std::string);
virtual void erase(const std::string&);
/*
* delete all keys from the Properties
*/
......
......@@ -209,7 +209,7 @@ struct PIMPL {
}
void setEnv(std::string key, const std::string env) {
void setEnv(std::string key, const std::string&env) {
if(env.empty())return;
if(key.empty())return;
......@@ -266,35 +266,35 @@ void gem::Settings::save() {
t_atom*gem::Settings::get(const std::string s) {
t_atom*gem::Settings::get(const std::string&s) {
if(NULL==settings) init();
return settings->get(s.c_str());
}
void gem::Settings::set(const std::string s, t_atom*v) {
settings->set(s.c_str(), v);
void gem::Settings::set(const std::string&key, t_atom*v) {
settings->set(key.c_str(), v);
}
void gem::Settings::get(const std::string key, int&value) {
void gem::Settings::get(const std::string&key, int&value) {
t_atom*a=get(key);
if(a && A_FLOAT==a->a_type) {
value=atom_getint(a);
}
}
void gem::Settings::get(const std::string key, float&value) {
void gem::Settings::get(const std::string&key, float&value) {
t_atom*a=get(key);
if(a && A_FLOAT==a->a_type) {
value=atom_getfloat(a);
}
}
void gem::Settings::get(const std::string key, double&value) {
void gem::Settings::get(const std::string&key, double&value) {
t_atom*a=get(key);
if(a && A_FLOAT==a->a_type) {
value=atom_getfloat(a);
}
}
void gem::Settings::get(const std::string key, std::string&value) {
void gem::Settings::get(const std::string&key, std::string&value) {
t_atom*a=get(key);
if(a) {
value=atom_getsymbol(a)->s_name;
......
......@@ -22,13 +22,13 @@ namespace gem { namespace Settings {
void print(void);
void save(void);
t_atom*get(const std::string key);
void set(const std::string key, t_atom*value=NULL);
t_atom*get(const std::string&key);
void set(const std::string&key, t_atom*value=NULL);
void get(const std::string key, int&value);
void get(const std::string key, float&value);
void get(const std::string key, double&value);
void get(const std::string key, std::string&value);
void get(const std::string&key, int&value);
void get(const std::string&key, float&value);
void get(const std::string&key, double&value);
void get(const std::string&key, std::string&value);
std::vector<std::string> keys();
}; };
......
......@@ -985,7 +985,7 @@ static void*freeframe_loader_new(t_symbol*s, int argc, t_atom*argv) {
}
return 0;
}
bool pix_freeframe :: loader(const t_canvas*canvas, const std::string classname, const std::string path) {
bool pix_freeframe :: loader(const t_canvas*canvas, const std::string&classname, const std::string&path) {
if(strncmp("pix_", classname.c_str(), offset_pix_))
return false;
std::string pluginname = classname.substr(offset_pix_);
......
......@@ -95,7 +95,7 @@ class GEM_EXTERN pix_freeframe : public GemPixObj
static void openCallback(void *data, t_symbol*s);
public:
static bool loader(const t_canvas *canvas, const std::string classname, const std::string path);
static bool loader(const t_canvas *canvas, const std::string&classname, const std::string&path);
};
#endif // for header file
......@@ -539,7 +539,7 @@ static void*frei0r_loader_new(t_symbol*s, int argc, t_atom*argv) {
}
return 0;
}
bool pix_frei0r :: loader(const t_canvas*canvas, const std::string classname, const std::string path) {
bool pix_frei0r :: loader(const t_canvas*canvas, const std::string&classname, const std::string&path) {
if(strncmp("pix_", classname.c_str(), offset_pix_)) {
return false;
}
......
......@@ -77,7 +77,7 @@ class GEM_EXTERN pix_frei0r : public GemPixObj
static void openCallback(void *data, t_symbol*s);
public:
static bool loader(const t_canvas *canvas, const std::string classname, const std::string path);
static bool loader(const t_canvas *canvas, const std::string&classname, const std::string&path);
};
#endif // for header file
......@@ -20,13 +20,13 @@
* CPPEXTERN_MSG (classPtr, "foo", gimmeMess); // A_GIMME
* CPPEXTERN_MSG0(classPtr, "doit", bangMess); // no args
* CPPEXTERN_MSG1(classPtr, "name", nameMess, t_symbol*); // 1 arg (A_SYMBOL)
* CPPEXTERN_MSG1(classPtr, "title", titleMess, std::string); // 1 arg (A_SYMBOL)
* CPPEXTERN_MSG1(classPtr, "title", titleMess, const std::string&); // 1 arg (A_SYMBOL)
* CPPEXTERN_MSG3(classPtr, "values", tripletMess, t_float, t_float, t_float); // 3 args (A_FLOAT)
* }
* void myclass::gimmeMess (t_symbol*s, int argc, t_atom*argv) {;}
* void myclass::bangMess (void) {;}
* void myclass::nameMess (t_symbol*s) {;}
* void myclass::titleMess (std::string s) {;}
* void myclass::titleMess (const std::string&s) {;}
* void myclass::tripletMess(t_float a, t_float b, t_float c) {;}
*/
#ifndef _INCLUDE__GEM_RTE_MESSAGECALLBACKS_H_
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment