36#ifdef __ASTRING_H_HAVE_IMPL__
37#undef __ASTRING_H_HAVE_IMPL__
41#define __ASTRING_H_HAVE_IMPL__
45 struct AString :
public QString
47 AString() : QString() {}
52 AString(
const T& rhs) : QString()
54 *(
static_cast<QString*
>(
this)) = rhs;
57 AString(
const std::string& rhs) : QString()
59 (*this) = fromStdString(rhs);
62#define ASTRING_TO_CSTR(mystr) ((mystr).toLocal8Bit().constData())
63#define ASTRING_UTF8_RAW(mystr) ((mystr).toUtf8().constData())
64 inline std::string AString_to_std_string(
const AString& mystr)
66 QByteArray temparray = mystr.toLocal8Bit();
67 return std::string(temparray.constData(), temparray.size());
69 inline AString AString_from_latin1(
const char* data,
const int& size)
71 return QString::fromLatin1(data, size);
73 inline AString AString_substr(
const AString& mystr,
const int& first,
const int& count = -1)
75 return mystr.mid(first, count);
77 inline bool AString_endsWith(
const AString& test,
const AString& pattern)
79 return test.endsWith(pattern);
82 AString AString_number(
const T& num)
84 return QString::number(num);
87 AString AString_number_fixed(
const T& num,
const int& numDecimals)
89 return QString::number(num,
'f', numDecimals);
94#ifdef CIFTILIB_USE_XMLPP
95#define __ASTRING_H_HAVE_IMPL__
96#include "glibmm/convert.h"
97#include "glibmm/ustring.h"
101 typedef Glib::ustring AString;
102#define ASTRING_TO_CSTR(mystr) (Glib::locale_from_utf8((mystr)).c_str())
103#define ASTRING_UTF8_RAW(mystr) ((mystr).data())
104 inline std::string AString_to_std_string(
const AString& mystr)
106 return Glib::locale_from_utf8(mystr);
108 inline AString AString_from_latin1(
const char* data,
const int& size)
110 return Glib::convert(std::string(data, size),
"UTF-8",
"ISO-8859-1");
112 inline AString AString_substr(
const AString& mystr,
const Glib::ustring::size_type& first,
const Glib::ustring::size_type& count = std::string::npos)
114 return mystr.substr(first, count);
116 inline bool AString_endsWith(
const AString& test,
const AString& pattern)
118 return test.substr(test.size() - pattern.size()) == pattern;
120 template <
typename T>
121 AString AString_number(
const T& num)
123 return Glib::ustring::format(num);
125 template <
typename T>
126 AString AString_number_fixed(
const T& num,
const int& numDecimals)
128 return Glib::ustring::format(std::fixed, std::setprecision(numDecimals), num);
133#ifndef __ASTRING_H_HAVE_IMPL__
134#error "you must define either CIFTILIB_USE_QT or CIFTILIB_USE_XMLPP to select what unicode string implementation to use"
140 std::vector<AString> AString_split(
const AString& input,
const char& delim);
141 std::vector<AString> AString_split_whitespace(
const AString& input);
142 int64_t AString_toInt(
const AString& input,
bool& ok);
143 float AString_toFloat(
const AString& input,
bool& ok);
namespace for all CiftiLib functionality
Definition CiftiBrainModelsMap.h:42