2016-05-17 03:04:11 +12:00
|
|
|
#pragma once
|
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
|
2016-06-15 18:43:10 +12:00
|
|
|
#ifdef TNZCORE_EXPORTS // TNZCORE_DLL
|
2016-03-19 06:57:51 +13:00
|
|
|
#define DVAPI DV_EXPORT_API
|
|
|
|
#else
|
|
|
|
#define DVAPI DV_IMPORT_API
|
|
|
|
#endif
|
|
|
|
|
2016-04-18 15:13:38 +12:00
|
|
|
DVAPI bool isInt(std::string s);
|
|
|
|
DVAPI bool isDouble(std::string s);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-07 19:06:00 +12:00
|
|
|
DVAPI std::string to_string(double v, int prec);
|
|
|
|
DVAPI std::string to_string(std::wstring s);
|
|
|
|
DVAPI std::string to_string(const TFilePath &fp);
|
2016-06-15 18:43:10 +12:00
|
|
|
DVAPI std::string to_string(void *p);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-04-18 15:13:38 +12:00
|
|
|
DVAPI bool isInt(std::wstring s);
|
|
|
|
DVAPI bool isDouble(std::wstring s);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-07 19:06:00 +12:00
|
|
|
DVAPI std::wstring to_wstring(std::string s);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
inline bool fromStr(int &v, std::string s) {
|
|
|
|
if (isInt(s)) {
|
|
|
|
v = std::stoi(s);
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
inline bool fromStr(double &v, std::string s) {
|
|
|
|
if (isDouble(s)) {
|
|
|
|
v = std::stod(s);
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
inline bool fromStr(std::string &out, std::string s) {
|
|
|
|
out = s;
|
|
|
|
return true;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
2016-04-18 15:13:38 +12:00
|
|
|
DVAPI std::string toUpper(std::string a);
|
|
|
|
DVAPI std::string toLower(std::string a);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-04-18 15:13:38 +12: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
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
inline bool fromStr(int &v, QString s) {
|
|
|
|
bool ret;
|
|
|
|
v = s.toInt(&ret);
|
|
|
|
return ret;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
inline bool fromStr(double &v, QString s) {
|
|
|
|
bool ret;
|
|
|
|
v = s.toDouble(&ret);
|
|
|
|
return ret;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|