tahoma2d/toonz/sources/include/tconvert.h

95 lines
1.8 KiB
C
Raw Normal View History

2016-03-19 06:57:51 +13:00
#ifndef TCONVERT_INCLUDED
#define TCONVERT_INCLUDED
#include "tcommon.h"
class TFilePath;
//
// Nota: il file tconvert.cpp esiste gia' in rop.
// l'implementazione di queste funzioni si trova in tstring.cpp
//
#undef DVAPI
#ifdef TNZCORE_EXPORTS //TNZCORE_DLL
#define DVAPI DV_EXPORT_API
#else
#define DVAPI DV_IMPORT_API
#endif
DVAPI bool isInt(std::string s);
DVAPI bool isDouble(std::string s);
2016-03-19 06:57:51 +13:00
DVAPI std::string toString(int v);
DVAPI std::string toString(unsigned long v);
DVAPI std::string toString(unsigned long long v);
DVAPI std::string toString(double v, int prec = -1);
DVAPI std::string toString(std::wstring s);
DVAPI std::string toString(const TFilePath &fp);
DVAPI std::string toString(void *p);
2016-03-19 06:57:51 +13:00
DVAPI int toInt(std::string s);
DVAPI double toDouble(std::string s);
2016-03-19 06:57:51 +13:00
DVAPI bool isInt(std::wstring s);
DVAPI bool isDouble(std::wstring s);
2016-03-19 06:57:51 +13:00
DVAPI std::wstring toWideString(std::string s);
DVAPI std::wstring toWideString(int v);
DVAPI std::wstring toWideString(double v, int prec = -1);
2016-03-19 06:57:51 +13:00
DVAPI int toInt(std::wstring s);
DVAPI double toDouble(std::wstring s);
2016-03-19 06:57:51 +13:00
inline bool fromStr(int &v, std::string s)
2016-03-19 06:57:51 +13:00
{
if (isInt(s)) {
v = toInt(s);
return true;
} else
return false;
}
inline bool fromStr(double &v, std::string s)
2016-03-19 06:57:51 +13:00
{
if (isDouble(s)) {
v = toDouble(s);
return true;
} else
return false;
}
inline bool fromStr(std::string &out, std::string s)
2016-03-19 06:57:51 +13:00
{
out = s;
return true;
}
DVAPI std::string toUpper(std::string a);
DVAPI std::string toLower(std::string a);
2016-03-19 06:57:51 +13:00
DVAPI std::wstring toUpper(std::wstring a);
DVAPI std::wstring toLower(std::wstring a);
2016-03-19 06:57:51 +13:00
#ifndef TNZCORE_LIGHT
2016-03-27 13:30:32 +13:00
#include <QString>
2016-03-19 06:57:51 +13:00
inline bool fromStr(int &v, QString s)
{
bool ret;
v = s.toInt(&ret);
return ret;
}
inline bool fromStr(double &v, QString s)
{
bool ret;
v = s.toDouble(&ret);
return ret;
}
#endif
#endif