24 #ifndef _HUGIN_UTILS_UTILS_H
25 #define _HUGIN_UTILS_UTILS_H
35 #include <vigra/imageinfo.hxx>
49 #define DEBUG_HEADER hugin_utils::GetCurrentTimeString() <<" (" << __FILE__ << ":" << __LINE__ << ") " << __func__ << "(): "
51 #define DEBUG_HEADER hugin_utils::GetCurrentTimeString() <<" (" << __FILE__ << ":" << __LINE__ << ") " << __FUNCTION__ << "(): "
53 #define DEBUG_HEADER hugin_utils::GetCurrentTimeString() <<" (" << __FILE__ << ":" << __LINE__ << ") " << __func__ << "(): "
59 #define DEBUG_TRACE(msg) { std::cerr << "TRACE " << DEBUG_HEADER << msg << std::endl; }
61 #define DEBUG_DEBUG(msg) { std::cerr << "DEBUG " << DEBUG_HEADER << msg << std::endl; }
63 #define DEBUG_INFO(msg) { std::cerr << "INFO " << DEBUG_HEADER << msg << std::endl; }
65 #define DEBUG_NOTICE(msg) { std::cerr << "NOTICE " << DEBUG_HEADER << msg << std::endl; }
67 #define DEBUG_TRACE(msg)
68 #define DEBUG_DEBUG(msg)
69 #define DEBUG_INFO(msg)
70 #define DEBUG_NOTICE(msg)
74 #define DEBUG_WARN(msg) { std::cerr << "WARN: " << DEBUG_HEADER << msg << std::endl; }
76 #define DEBUG_ERROR(msg) { std::cerr << "ERROR: " << DEBUG_HEADER << msg << std::endl; }
78 #define DEBUG_FATAL(msg) { std::cerr << "FATAL: " << DEBUG_HEADER << "(): " << msg << std::endl; }
80 #define DEBUG_ASSERT(cond) assert(cond)
83 #define UTILS_THROW(class, msg) { std::stringstream o; o << msg; throw(class(o.str().c_str())); };
113 template <
typename STR>
118 char * old_locale = setlocale(LC_NUMERIC,NULL);
119 old_locale = strdup(old_locale);
120 setlocale(LC_NUMERIC,
"C");
124 for (
typename STR::iterator it = str.begin(); it != str.end(); ++it) {
130 const char * p = str.c_str();
135 setlocale(LC_NUMERIC,old_locale);
140 DEBUG_DEBUG(
"conversion failed: " << str <<
" to:" << dest);
174 IMPEX std::vector<std::string>
SplitString(
const std::string& s,
const std::string& sep);
177 IMPEX void ReplaceAll(std::string& s,
const std::string& oldChar,
char newChar);
184 const str & replacements)
188 size_t len = replacements.size();
189 for (
size_t i = 0; i < len; i++) {
190 str source(replacements.substr(i,1));
191 str dest(quotechar + source);
194 idx = ret.find(source,idx);
195 if (idx != str::npos) {
196 ret.replace(idx, 1, dest);
200 }
while (idx != str::npos);
206 double &r,
double &g,
double &b);
222 IMPEX std::string
GetOutputFilename(
const std::string& out,
const std::string& in,
const std::string& suffix);
242 IMPEX std::string
GetICCDesc(
const vigra::ImageImportInfo::ICCProfile& iccProfile);
253 #endif // _HUGIN_UTILS_UTILS_H
std::string GetICCDesc(const vigra::ImageImportInfo::ICCProfile &iccProfile)
returns description of given icc profile
str QuoteStringInternal(const str &arg, const str "echar, const str &replacements)
bool wrapupGPU()
cleanup GPU settings
bool FileExists(const std::string &filename)
checks if file exists
std::string StrTrim(const std::string &str)
remove trailing and leading white spaces and tabs
std::string GetCurrentTimeString()
current time as a string
std::string GetOutputFilename(const std::string &out, const std::string &in, const std::string &suffix)
construct output filename, if ouput is known return this value otherwise use the input filename and a...
void EnforceExtension(std::string &filename, const std::string &defaultExtension)
check if filename contains extension, if not add default extension
std::string doubleToString(double d, int digits)
convert a double to a string, suitable for display within a GUI.
bool stringToUInt(const std::string &s, unsigned int &val)
convert string to unsigned integer value, returns true, if sucessful
std::string GetDataDir()
returns the full path to the data directory
std::string getPathPrefix(const std::string &filename)
Get the path to a filename.
std::string GetAbsoluteFilename(const std::string &filename)
returns the full absolute filename
bool IsFileTypeSupported(const std::string &filename)
return true, if file type by extension is supported by vigra
std::string getExtension(const std::string &basename2)
Get extension of a filename.
std::string stripExtension(const std::string &basename2)
remove extension of a filename
bool stringToInt(const std::string &s, int &val)
convert string to integer value, returns true, if sucessful
bool stringToDouble(const STR &str_, double &dest)
convert a string to a double, ignore localisation.
bool initGPU(int *argcp, char **argv)
Try to initalise GLUT and GLEW, and create an OpenGL context for GPU stitching.
bool StringContainsCaseInsensitive(const std::string &s1, const std::string &s2)
check if s1 contains s2 using case insensitive comparison
void ReplaceAll(std::string &s, const std::string &oldChar, char newChar)
replace all characters oldChar in s with newChar
std::vector< std::string > GetRawExtensions()
return vector of known extensions of raw files, all lower case
std::string GetUserAppDataDir()
returns the directory for user specific Hugin settings, e.g.
void ControlPointErrorColour(const double cperr, double &r, double &g, double &b)
std::string GetHuginVersion()
return a string with version numbers
bool IsRawExtension(const std::string testExt)
return true if extension belongs to a raw file
std::vector< std::string > SplitString(const std::string &s, const std::string &sep)
split string s at given sep, returns vector of strings
std::string stripPath(const std::string &filename)
remove the path of a filename (mainly useful for gui display of filenames)