36 #ifdef __ASTRING_H_HAVE_IMPL__ 37 #undef __ASTRING_H_HAVE_IMPL__ 40 #ifdef CIFTILIB_USE_QT 41 #define __ASTRING_H_HAVE_IMPL__ 45 typedef QString AString;
46 #define ASTRING_TO_CSTR(mystr) ((mystr).toLocal8Bit().constData()) 47 #define ASTRING_UTF8_RAW(mystr) ((mystr).toUtf8().constData()) 48 inline std::string AString_to_std_string(
const AString& mystr)
50 QByteArray temparray = mystr.toLocal8Bit();
51 return std::string(temparray.constData(), temparray.size());
53 inline AString AString_from_latin1(
const char* data,
const int& size)
55 return QString::fromLatin1(data, size);
57 inline AString AString_substr(
const AString& mystr,
const int& first,
const int& count = -1)
59 return mystr.mid(first, count);
62 AString AString_number(
const T& num)
64 return QString::number(num);
67 AString AString_number_fixed(
const T& num,
const int& numDecimals)
69 return QString::number(num,
'f', numDecimals);
72 #endif //CIFTILIB_USE_QT 74 #ifdef CIFTILIB_USE_XMLPP 75 #define __ASTRING_H_HAVE_IMPL__ 76 #include "glibmm/convert.h" 77 #include "glibmm/ustring.h" 81 typedef Glib::ustring AString;
82 #define ASTRING_TO_CSTR(mystr) (Glib::locale_from_utf8((mystr)).c_str()) 83 #define ASTRING_UTF8_RAW(mystr) ((mystr).data()) 84 inline std::string AString_to_std_string(
const AString& mystr)
86 return Glib::locale_from_utf8(mystr);
88 inline AString AString_from_latin1(
const char* data,
const int& size)
90 return Glib::convert(std::string(data, size),
"UTF-8",
"ISO-8859-1");
92 inline AString AString_substr(
const AString& mystr,
const Glib::ustring::size_type& first,
const Glib::ustring::size_type& count = std::string::npos)
94 return mystr.substr(first, count);
97 AString AString_number(
const T& num)
99 return Glib::ustring::format(num);
101 template <
typename T>
102 AString AString_number_fixed(
const T& num,
const int& numDecimals)
104 return Glib::ustring::format(std::fixed, std::setprecision(numDecimals), num);
107 #endif //CIFTILIB_USE_XMLPP 109 #ifndef __ASTRING_H_HAVE_IMPL__ 110 #error "you must define either CIFTILIB_USE_QT or CIFTILIB_USE_XMLPP to select what unicode string implementation to use" 116 std::vector<AString> AString_split(
const AString& input,
const char& delim);
117 std::vector<AString> AString_split_whitespace(
const AString& input);
118 int64_t AString_toInt(
const AString& input,
bool& ok);
119 float AString_toFloat(
const AString& input,
bool& ok);
122 #endif //__ASTRING_H__ namespace for all CiftiLib functionality
Definition: CiftiBrainModelsMap.h:41