Section of a QString. More...
#include <StringSection.h>
Public Member Functions | |
void | appendTo (QString &str) const |
const QChar * | begin () const |
bool | beginWith (const QString &o) const |
bool | beginWith (const StringSection &o) const |
int | compare (const QChar *o) const |
int | compare (const StringSection &o) const |
int | compare (const QString &o) const |
bool | contains (const StringSection target) const |
bool | contains (QChar target) const |
const QChar * | data () const |
const QChar * | end () const |
bool | endWith (const QString &o) const |
bool | endWith (const StringSection &o) const |
const QChar * | find (QChar c) const |
int | find (const StringSection target, bool reverse) const |
bool | isEmpty () const |
bool | isValid () const |
StringSection | left (int n) const |
StringSection | mid (int position, int n) const |
StringSection | nextField (const QChar *&ptr, const QString &sep=defaultSeparators, bool skipEmpty=true) const |
bool | nextLine (const QChar *&ptr, const QString &sep=defaultSeparators) const |
bool | nextNumber (int &n, const QChar *&ptr, const QString &sep=defaultSeparators, bool skipEmpty=true) const |
bool | nextNumber (double &n, const QChar *&ptr, const QString &sep=defaultSeparators, bool skipEmpty=true) const |
bool | nextNumber (Complex &n, const QChar *&ptr, const QString &sep=defaultSeparators, bool skipEmpty=true) const |
bool | operator!= (const QChar *o) const |
bool | operator!= (const StringSection &o) const |
bool | operator!= (const QString &o) const |
void | operator++ () |
void | operator+= (int l) |
void | operator-- () |
bool | operator< (const QChar *o) const |
bool | operator< (const StringSection &o) const |
bool | operator< (const QString &o) const |
bool | operator<= (const QChar *o) const |
bool | operator<= (const StringSection &o) const |
bool | operator<= (const QString &o) const |
StringSection & | operator= (const StringSection &o) |
bool | operator== (const QChar *o) const |
bool | operator== (const StringSection &o) const |
bool | operator== (const QString &o) const |
bool | operator> (const QChar *o) const |
bool | operator> (const StringSection &o) const |
bool | operator> (const QString &o) const |
bool | operator>= (const QChar *o) const |
bool | operator>= (const StringSection &o) const |
bool | operator>= (const QString &o) const |
QChar | operator[] (int i) const |
StringSection | readLine (const QChar *&ptr) const |
StringSection | right (int n) const |
void | set (const QString &s) |
void | set (const QChar *s, int size) |
void | setEnd (const QChar *e) |
void | setInvalid () |
void | setSize (int size) |
void | shrink (int nChar) |
int | size () const |
StringSection () | |
StringSection (const QString &s) | |
StringSection (const QChar *s) | |
StringSection (const QChar *s, int len) | |
StringSection (const QChar *s1, const QChar *s2) | |
StringSection (const StringSection &o) | |
bool | to (bool, bool *ok=0) const |
QString | to (QString) const |
int | to (int, bool *ok=0) const |
uint | to (uint, bool *ok=0) const |
qlonglong | to (qlonglong, bool *ok=0) const |
double | to (double, bool *ok=0) const |
Complex | to (const Complex &, bool *ok=0) const |
bool | toBool (bool *ok=0) const |
Complex | toComplex () const |
Complex | toComplex (bool *ok) const |
double | toDouble (bool *ok=0) const |
int | toInt (bool *ok=0, int base=10) const |
qlonglong | toLongLong (bool *ok=0, int base=10) const |
QString | toString () const |
uint | toUInt (bool *ok=0, int base=10) const |
StringSection & | trimmed () |
~StringSection () | |
Static Public Member Functions | |
static int | compare (const QChar *str1, const QChar *str2, int n) |
static int | size (const QChar *str) |
Static Public Attributes | |
static const QString | defaultSeparators = "\t " |
static const StringSection | null |
Section of a QString.
Usefull for parser
QGpCoreTools::StringSection::StringSection | ( | ) | [inline] |
Referenced by left(), mid(), nextField(), and right().
{ _str=0; _size=0; }
QGpCoreTools::StringSection::StringSection | ( | const QString & | s | ) | [inline] |
{ _str=s.data(); _size=s.size(); }
QGpCoreTools::StringSection::StringSection | ( | const QChar * | s | ) | [inline] |
QGpCoreTools::StringSection::StringSection | ( | const QChar * | s, |
int | len | ||
) | [inline] |
{ _str=s; _size=len; }
QGpCoreTools::StringSection::StringSection | ( | const QChar * | s1, |
const QChar * | s2 | ||
) | [inline] |
QGpCoreTools::StringSection::StringSection | ( | const StringSection & | o | ) | [inline] |
{
*this=o;
}
QGpCoreTools::StringSection::~StringSection | ( | ) | [inline] |
{}
void QGpCoreTools::StringSection::appendTo | ( | QString & | str | ) | const [inline] |
Referenced by QGpCoreTools::XMLClass::saveSpecChar(), and QGpCoreTools::ExpressionString::setPattern().
const QChar* QGpCoreTools::StringSection::begin | ( | ) | const [inline] |
Referenced by QGpCoreTools::LineParser::toString().
{return _str;}
bool QGpCoreTools::StringSection::beginWith | ( | const QString & | o | ) | const [inline] |
References compare().
Referenced by QGpCoreTools::DateTimeFromString::ap_parsed(), QGpCoreTools::DateTimeFromString::AP_parsed(), QGpCoreTools::DateTimeFromString::ddd_parsed(), QGpCoreTools::DateTimeFromString::dddd_parsed(), QGpCoreTools::DateTimeFromString::MMM_parsed(), QGpCoreTools::DateTimeFromString::MMMM_parsed(), and QGpCoreTools::DateTimeFromString::quote_parsed().
{ if(_size < o.size()) return false; return compare(o.data(), _str, o.size())==0; }
bool QGpCoreTools::StringSection::beginWith | ( | const StringSection & | o | ) | const [inline] |
int QGpCoreTools::StringSection::compare | ( | const QChar * | o | ) | const [inline] |
Referenced by beginWith(), compare(), endWith(), operator!=(), and operator==().
{ StringSection os(o); return compare(os); }
int QGpCoreTools::StringSection::compare | ( | const StringSection & | o | ) | const |
int QGpCoreTools::StringSection::compare | ( | const QString & | o | ) | const [inline] |
References compare().
{ StringSection os(o); return compare(os); }
int QGpCoreTools::StringSection::compare | ( | const QChar * | str1, |
const QChar * | str2, | ||
int | n | ||
) | [static] |
bool QGpCoreTools::StringSection::contains | ( | const StringSection | target | ) | const [inline] |
{return find(target, false)>-1;}
bool QGpCoreTools::StringSection::contains | ( | QChar | target | ) | const [inline] |
{return find(StringSection(&target, 1), false)>-1;}
const QChar* QGpCoreTools::StringSection::data | ( | ) | const [inline] |
Referenced by QGpCoreTools::LineParser::endsAt(), find(), QGpCoreTools::qHash(), QGpCoreTools::XMLClass::saveSpecChar(), and QGpCoreTools::LineParser::startsAt().
{return _str;}
const QChar* QGpCoreTools::StringSection::end | ( | ) | const [inline] |
Referenced by QGpCoreTools::LineParser::toString().
{return _str+_size;}
bool QGpCoreTools::StringSection::endWith | ( | const QString & | o | ) | const [inline] |
bool QGpCoreTools::StringSection::endWith | ( | const StringSection & | o | ) | const [inline] |
const QChar * QGpCoreTools::StringSection::find | ( | QChar | c | ) | const |
{ const QChar * ptr=_str; const QChar * ptrE=_str + _size; while(ptr < ptrE) { if( *ptr==c) break; ptr++; } return ptr; }
int QGpCoreTools::StringSection::find | ( | const StringSection | target, |
bool | reverse | ||
) | const |
References data(), isValid(), size(), and TRACE.
{ TRACE; if( !isValid()) return -1; const QChar * ptrS=_str; const QChar * ptrE=_str + _size; int nTarget=target.size(), i, n; const QChar * targetPtr=target.data(); QChar initChar; if(reverse) { targetPtr += nTarget - 1; initChar=*targetPtr; ptrE--; while(ptrE >= ptrS) { if(initChar==*ptrE) { n=ptrS - ptrE; if(n < -nTarget) n=-nTarget; for(i=-1; targetPtr[i]==ptrE[i] && i > n; i-- ) {} if(targetPtr[i]==0) return ptrE -_str - nTarget; } ptrE--; } } else { initChar=*targetPtr; while(ptrS < ptrE) { if(initChar==*ptrS) { n=ptrE - ptrS; if(n > nTarget) n=nTarget; for(i=1; targetPtr[i]==ptrS[i] && i < n; i++ ) {} if(targetPtr[i]==0) return ptrS -_str; } ptrS++; } } return -1; }
bool QGpCoreTools::StringSection::isEmpty | ( | ) | const [inline] |
Referenced by QGpCoreWave::RefractionDippingModel::fromStream(), QGpCoreWave::Seismic1DModel::fromStream(), QGpCoreTools::XMLParser::parse(), and SciFigs::Axis::setStringLabels().
{return _size==0;}
bool QGpCoreTools::StringSection::isValid | ( | ) | const [inline] |
Referenced by createBands(), createDots(), createManyCurves(), QGpCoreTools::LineParser::endsAt(), find(), QGpCoreWave::Resistivity1DModel::fromStream(), QGpCoreWave::RefractionDippingModel::fromStream(), QGpCoreWave::Seismic1DModel::fromStream(), Distance::fromString(), SciFigs::AbstractNameLine::fromString(), GeopsyCore::GuralpRecords::fromString(), GeopsyCore::MiniSeedRecords::fromString(), SciFigs::AbstractLine::fromString(), QGpCoreTools::StatisticalPoint< numberType >::fromString(), QGpCoreTools::Point1D::fromString(), QGpCoreTools::NamedPoint::fromString(), QGpCoreTools::PointND::fromString(), QGpCoreTools::Point2D::fromString(), QGpCoreTools::Complex::fromString(), QGpCoreTools::Point::fromString(), DinverCore::ModelSet::importModelsFromAscii(), GeopsyCore::SubSignalPool::importTable(), nextField(), nextLine(), nextNumber(), QGpCoreTools::operator>>(), CurveMaxEntry::readLine(), SPACMaxEntry::readLine(), TFAMaxEntry::readLine(), FKMaxEntry::readLine(), readLine(), SpacReader::setOptions(), QGpCoreTools::LineParser::startsAt(), QGpCoreTools::LineParser::toBool(), QGpCoreTools::LineParser::toString(), trimmed(), QGpCoreTools::Version::Version(), GeopsyCore::SignalGroup::xml_setProperty(), QGpCompatibility::CompatModalFrequency::xml_setProperty(), QGpGuiTools::ColorPalette::xml_setProperty(), and SciFigs::CircleViewer::xml_setProperty().
{return _str;}
StringSection QGpCoreTools::StringSection::left | ( | int | n | ) | const [inline] |
References StringSection().
Referenced by QGpCoreTools::DateTimeFromString::ap_parsed(), QGpCoreTools::DateTimeFromString::AP_parsed(), QGpCoreTools::DateTimeFromString::d_parsed(), QGpCoreTools::DateTimeFromString::dd_parsed(), QGpCoreTools::DateTimeFromString::ddd_parsed(), QGpCoreTools::DateTimeFromString::dddd_parsed(), QGpCoreTools::DateTimeFromString::h_parsed(), QGpCoreTools::DateTimeFromString::H_parsed(), QGpCoreTools::DateTimeFromString::hh_parsed(), QGpCoreTools::DateTimeFromString::HH_parsed(), QGpCoreTools::DateTimeFromString::M_parsed(), QGpCoreTools::DateTimeFromString::m_parsed(), QGpCoreTools::DateTimeFromString::MM_parsed(), QGpCoreTools::DateTimeFromString::mm_parsed(), QGpCoreTools::DateTimeFromString::MMM_parsed(), QGpCoreTools::DateTimeFromString::MMMM_parsed(), QGpCoreTools::DateTimeFromString::other_parsed(), QGpCoreTools::DateTimeFromString::s_parsed(), QGpCoreTools::DateTimeFromString::ss_parsed(), QGpCoreTools::DateTimeFromString::ssz_parsed(), QGpCoreTools::DateTimeFromString::sz_parsed(), QGpCoreTools::DateTimeFromString::yy_parsed(), QGpCoreTools::DateTimeFromString::yyyy_parsed(), QGpCoreTools::DateTimeFromString::z_parsed(), and QGpCoreTools::DateTimeFromString::zzz_parsed().
{ if(n>_size) n=_size; return StringSection(_str, n); }
StringSection QGpCoreTools::StringSection::mid | ( | int | position, |
int | n | ||
) | const [inline] |
References null, and StringSection().
{ if(position>=_size) return StringSection::null; int ns=_size-position; if(n<ns) ns=n; return StringSection(_str+position, ns); }
StringSection QGpCoreTools::StringSection::nextField | ( | const QChar *& | ptr, |
const QString & | sep = defaultSeparators , |
||
bool | skipEmpty = true |
||
) | const |
Returns the next field of this string starting at ptr. If sep does not contain '\n' and '\r' and if a '\n' or '\r' is encountered, an invalid string is returned and ptr points to the first '\n' or '\r'. On the contrary, to jump over line breaks, include '\n' and '\r' in sep and switch skipEmpty to true.
const QString sep="= \t\n\r"; int i; StringSection f; const QChar * ptr=0; for(i=0;i<n;i++) { if(!content.nextLine(ptr)) break; f=content.nextField(ptr, sep); if(f.isValid()) x1=f.toDouble(); else break; f=content.nextField(ptr, sep); if(f.isValid()) x2=f.toDouble(); else break; } if(i<n) fprintf(stderr,"Error");
References isValid(), setEnd(), StringSection(), and TRACE.
Referenced by createBands(), createDots(), createManyCurves(), QGpCoreWave::Resistivity1DModel::fromStream(), QGpCoreWave::RefractionDippingModel::fromStream(), QGpCoreWave::Seismic1DModel::fromStream(), Distance::fromString(), SciFigs::AbstractNameLine::fromString(), GeopsyCore::GuralpRecords::fromString(), GeopsyCore::MiniSeedRecords::fromString(), QGpCoreTools::StatisticalPoint< numberType >::fromString(), SciFigs::AbstractLine::fromString(), QGpCoreTools::NamedPoint::fromString(), QGpCoreTools::PointND::fromString(), QGpCoreTools::Point2D::fromString(), QGpCoreTools::Complex::fromString(), QGpCoreTools::Point::fromString(), DinverCore::ModelSet::importModelsFromAscii(), GeopsyCore::SubSignalPool::importTable(), nextNumber(), QGpCoreTools::operator>>(), Sample::read(), CurveMaxEntry::readLine(), SPACMaxEntry::readLine(), TFAMaxEntry::readLine(), FKMaxEntry::readLine(), SpacReader::setOptions(), QGpCoreTools::Version::Version(), GeopsyCore::SignalGroup::xml_setProperty(), QGpCompatibility::CompatModalFrequency::xml_setProperty(), and QGpGuiTools::ColorPalette::xml_setProperty().
{ TRACE; if(!isValid()) return StringSection(); const QChar * ptrE=_str+_size; if(!ptr) ptr=_str; if(skipEmpty) { while(ptr < ptrE) { if(sep.contains(*ptr)) { ptr++; } else if(*ptr=='\r' || *ptr=='\n') { ptr++; return StringSection(); } else { break; } } } if(ptr < ptrE) { StringSection field(ptr, 0); while(ptr < ptrE) { if(sep.contains(*ptr)) { field.setEnd(ptr); ptr++; return field; } else if(*ptr=='\r' || *ptr=='\n') { break; } ptr++; } // Reached the end of the line or of the string field.setEnd(ptr); return field; } else return StringSection(); }
bool QGpCoreTools::StringSection::nextLine | ( | const QChar *& | ptr, |
const QString & | sep = defaultSeparators |
||
) | const |
Skip all continuous '\n' and '\r' pointed by ptr. If ptr is null, it is set to the beginning of this string. Returns false if the end of string is reached. sep is not null blank fields are also skipped.
References isValid(), and TRACE.
{ TRACE; if(!isValid()) return false; const QChar * ptrE=_str+_size; if(!ptr) ptr=_str; if(sep.isEmpty()) { while(ptr<ptrE) { if(*ptr!='\n' && *ptr!='\r') { return true; } ptr++; } } else { while(ptr<ptrE) { if(*ptr!='\n' && *ptr!='\r' && !sep.contains(*ptr)) { return true; } ptr++; } } return false; }
bool QGpCoreTools::StringSection::nextNumber | ( | int & | n, |
const QChar *& | ptr, | ||
const QString & | sep = defaultSeparators , |
||
bool | skipEmpty = true |
||
) | const |
References isValid(), nextField(), toInt(), and TRACE.
Referenced by QGpCoreTools::StatisticalPoint< numberType >::fromString(), and QGpCoreTools::MatrixData< T >::fromString().
{ TRACE; StringSection s=nextField(ptr, sep, skipEmpty); if(s.isValid()) { n=s.toInt(); } else return false; return true; }
bool QGpCoreTools::StringSection::nextNumber | ( | double & | n, |
const QChar *& | ptr, | ||
const QString & | sep = defaultSeparators , |
||
bool | skipEmpty = true |
||
) | const |
References isValid(), nextField(), toDouble(), and TRACE.
{ TRACE; StringSection s=nextField(ptr, sep, skipEmpty); if(s.isValid()) { n=s.toDouble(); } else return false; return true; }
bool QGpCoreTools::StringSection::nextNumber | ( | Complex & | n, |
const QChar *& | ptr, | ||
const QString & | sep = defaultSeparators , |
||
bool | skipEmpty = true |
||
) | const |
References isValid(), nextField(), QGpCoreTools::Complex::setIm(), QGpCoreTools::Complex::setRe(), toDouble(), and TRACE.
{ TRACE; StringSection s; s=nextField(ptr, sep, skipEmpty); if(s.isValid()) { n.setRe(s.toDouble()); } else return false; s=nextField(ptr, sep, skipEmpty); if(s.isValid()) { n.setIm(s.toDouble()); } else return false; return true; }
bool QGpCoreTools::StringSection::operator!= | ( | const QChar * | o | ) | const [inline] |
bool QGpCoreTools::StringSection::operator!= | ( | const StringSection & | o | ) | const [inline] |
bool QGpCoreTools::StringSection::operator!= | ( | const QString & | o | ) | const [inline] |
void QGpCoreTools::StringSection::operator++ | ( | ) | [inline] |
{_str++;if(_size > 0) _size--;}
void QGpCoreTools::StringSection::operator+= | ( | int | l | ) | [inline] |
{_str += l;if((int) _size >= l) _size -= l; else _size=0;}
void QGpCoreTools::StringSection::operator-- | ( | ) | [inline] |
{_str--;_size++;}
bool QGpCoreTools::StringSection::operator< | ( | const QChar * | o | ) | const [inline] |
{return compare(o) < 0;}
bool QGpCoreTools::StringSection::operator< | ( | const StringSection & | o | ) | const [inline] |
{return compare(o) < 0;}
bool QGpCoreTools::StringSection::operator< | ( | const QString & | o | ) | const [inline] |
{return compare(o) < 0;}
bool QGpCoreTools::StringSection::operator<= | ( | const QChar * | o | ) | const [inline] |
{return compare(o) <= 0;}
bool QGpCoreTools::StringSection::operator<= | ( | const StringSection & | o | ) | const [inline] |
{return compare(o) <= 0;}
bool QGpCoreTools::StringSection::operator<= | ( | const QString & | o | ) | const [inline] |
{return compare(o) <= 0;}
StringSection & QGpCoreTools::StringSection::operator= | ( | const StringSection & | o | ) | [inline] |
{ _str=o._str; _size=o._size; return *this; }
bool QGpCoreTools::StringSection::operator== | ( | const QChar * | o | ) | const [inline] |
bool QGpCoreTools::StringSection::operator== | ( | const StringSection & | o | ) | const [inline] |
bool QGpCoreTools::StringSection::operator== | ( | const QString & | o | ) | const [inline] |
bool QGpCoreTools::StringSection::operator> | ( | const QChar * | o | ) | const [inline] |
{return compare(o) > 0;}
bool QGpCoreTools::StringSection::operator> | ( | const StringSection & | o | ) | const [inline] |
{return compare(o) > 0;}
bool QGpCoreTools::StringSection::operator> | ( | const QString & | o | ) | const [inline] |
{return compare(o) > 0;}
bool QGpCoreTools::StringSection::operator>= | ( | const QChar * | o | ) | const [inline] |
{return compare(o) >= 0;}
bool QGpCoreTools::StringSection::operator>= | ( | const StringSection & | o | ) | const [inline] |
{return compare(o) >= 0;}
bool QGpCoreTools::StringSection::operator>= | ( | const QString & | o | ) | const [inline] |
{return compare(o) >= 0;}
QChar QGpCoreTools::StringSection::operator[] | ( | int | i | ) | const [inline] |
{return _str[ i ];}
StringSection QGpCoreTools::StringSection::readLine | ( | const QChar *& | ptr | ) | const |
Returns the line starting at ptr as a StringSection excluding termination characters. If ptr is null, it is set to the beginning of this string. An invalid StringSection is returned if the end of this string is reached.
References isValid(), null, setEnd(), and TRACE.
Referenced by QGpCoreTools::operator>>(), and SciFigs::CircleViewer::xml_setProperty().
{ TRACE; if(!isValid()) return StringSection::null; const QChar * ptrE=_str+_size; if(ptr==ptrE) { return StringSection::null; } if(!ptr) ptr=_str; StringSection l(ptr, 0); while(ptr<ptrE) { if(*ptr=='\n' || *ptr=='\r') { l.setEnd(ptr); // Jump ptr across empty lines while(ptr<ptrE) { if(*ptr!='\n' && *ptr!='\r') { break; } ptr++; } return l; } ptr++; } return l; }
StringSection QGpCoreTools::StringSection::right | ( | int | n | ) | const [inline] |
References StringSection().
{ if(n>_size) n=_size; return StringSection(_str+_size-n, n); }
void QGpCoreTools::StringSection::set | ( | const QString & | s | ) | [inline] |
Referenced by QGpCoreTools::DateTimeFromString::DateTimeFromString(), QGpCoreWave::Resistivity1DModel::fromStream(), QGpCoreWave::RefractionDippingModel::fromStream(), QGpCoreWave::Seismic1DModel::fromStream(), GeopsyCore::SubSignalPool::importTable(), QGpCoreTools::LineParser::LineParser(), QGpCoreTools::XMLParser::parse(), QGpCoreTools::XMLClass::saveSpecChar(), QGpCoreTools::LineParser::setString(), and SciFigs::Axis::setStringLabels().
{_str=s.data(); _size=s.size();}
void QGpCoreTools::StringSection::set | ( | const QChar * | s, |
int | size | ||
) | [inline] |
{_str=s; _size=size;}
void QGpCoreTools::StringSection::setEnd | ( | const QChar * | e | ) | [inline] |
Referenced by nextField(), QGpCoreTools::XMLParser::parse(), QGpCoreTools::DateTimeParser::parse(), readLine(), QGpCoreTools::XMLClass::saveSpecChar(), SciFigs::Axis::setStringLabels(), and StringSection().
{_size=e-_str; if(_size< 0) _size=0;}
void QGpCoreTools::StringSection::setInvalid | ( | ) | [inline] |
{_str=0; _size=0;}
void QGpCoreTools::StringSection::setSize | ( | int | size | ) | [inline] |
{_size=size;}
void QGpCoreTools::StringSection::shrink | ( | int | nChar | ) | [inline] |
{if(nChar>=_size) _size=0; else _size-=nChar;}
int QGpCoreTools::StringSection::size | ( | ) | const [inline] |
Referenced by beginWith(), QGpCoreTools::LineParser::endsAt(), find(), operator!=(), operator==(), QGpCoreTools::qHash(), QGpCoreTools::DateTimeFromString::quote_parsed(), StringSection(), GeopsySLink::SeedLinkServer::xml_setAttributes(), GeopsySLink::SeedLinkStation::xml_setAttributes(), GeopsySLink::SeedLinkStream::xml_setAttributes(), GeopsyCore::MiniSeedSequence::xml_setAttributes(), and GeopsyCore::TimeRangeParameters::xml_setAttributes().
{return _size;}
int QGpCoreTools::StringSection::size | ( | const QChar * | str | ) | [static] |
bool QGpCoreTools::StringSection::to | ( | bool | , |
bool * | ok = 0 |
||
) | const [inline] |
{return toBool(ok);}
QString QGpCoreTools::StringSection::to | ( | QString | ) | const [inline] |
{return toString();}
int QGpCoreTools::StringSection::to | ( | int | , |
bool * | ok = 0 |
||
) | const [inline] |
{return toInt(ok);}
uint QGpCoreTools::StringSection::to | ( | uint | , |
bool * | ok = 0 |
||
) | const [inline] |
{return toUInt(ok);}
qlonglong QGpCoreTools::StringSection::to | ( | qlonglong | , |
bool * | ok = 0 |
||
) | const [inline] |
{return toLongLong(ok);}
double QGpCoreTools::StringSection::to | ( | double | , |
bool * | ok = 0 |
||
) | const [inline] |
{return toDouble(ok);}
Complex QGpCoreTools::StringSection::to | ( | const Complex & | , |
bool * | ok = 0 |
||
) | const [inline] |
{return toComplex(ok);}
bool QGpCoreTools::StringSection::toBool | ( | bool * | ok = 0 | ) | const |
Converts string to boolean. ok is set to false if string is not 'false' or 'true'. ok is untouched if if no error occur.
Referenced by CurveMaxEntry::readLine(), and QGpCoreTools::LineParser::toBool().
{ if(_size>=1) { switch(_str[0].unicode()) { case 't': if(*this=="true") { return true; } break; case 'f': if(*this=="false") { return false; } break; default: break; } } if(ok) *ok=false; return true; }
Complex QGpCoreTools::StringSection::toComplex | ( | ) | const [inline] |
References QGpCoreTools::Complex::fromString().
{ Complex c; c.fromString(*this); return c; }
Complex QGpCoreTools::StringSection::toComplex | ( | bool * | ok | ) | const [inline] |
References QGpCoreTools::Complex::fromString().
{ Complex c; bool tok=c.fromString(*this); if(ok) *ok=tok; return c; }
double QGpCoreTools::StringSection::toDouble | ( | bool * | ok = 0 | ) | const |
Converts string to a double. ok is set to false if string is not a double. ok is untouched if if no error occur.
References toString().
Referenced by createBands(), createDots(), createManyCurves(), QGpCoreWave::RefractionDippingModel::fromStream(), Distance::fromString(), SciFigs::AbstractNameLine::fromString(), QGpCoreTools::StatisticalPoint< numberType >::fromString(), SciFigs::AbstractLine::fromString(), QGpCoreTools::Point1D::fromString(), QGpCoreTools::NamedPoint::fromString(), QGpCoreTools::PointND::fromString(), QGpCoreTools::Point2D::fromString(), QGpCoreTools::Complex::fromString(), QGpCoreTools::Point::fromString(), DinverCore::ModelSet::importModelsFromAscii(), nextNumber(), QGpCoreTools::operator>>(), Sample::read(), SPACMaxEntry::readLine(), TFAMaxEntry::readLine(), CurveMaxEntry::readLine(), FKMaxEntry::readLine(), SpacReader::setOptions(), QGpCoreTools::DateTimeFromString::ssz_parsed(), QGpCoreTools::DateTimeFromString::sz_parsed(), QGpCoreTools::LineParser::toDouble(), QGpCompatibility::CompatModalFrequency::xml_setProperty(), and QGpGuiTools::ColorPalette::xml_setProperty().
int QGpCoreTools::StringSection::toInt | ( | bool * | ok = 0 , |
int | base = 10 |
||
) | const |
Converts string to integer. ok is set to false if string is not an integer. ok is untouched if if no error occur.
References toString().
Referenced by QGpCoreTools::DateTimeFromString::d_parsed(), QGpCoreTools::DateTimeFromString::dd_parsed(), QGpCoreWave::Resistivity1DModel::fromStream(), QGpCoreWave::RefractionDippingModel::fromStream(), QGpCoreWave::Seismic1DModel::fromStream(), GeopsyCore::GuralpRecords::fromString(), GeopsyCore::MiniSeedRecords::fromString(), QGpCoreTools::DateTimeFromString::h_parsed(), QGpCoreTools::DateTimeFromString::H_parsed(), QGpCoreTools::DateTimeFromString::hh_parsed(), QGpCoreTools::DateTimeFromString::HH_parsed(), QGpCoreTools::DateTimeFromString::M_parsed(), QGpCoreTools::DateTimeFromString::m_parsed(), QGpCoreTools::DateTimeFromString::MM_parsed(), QGpCoreTools::DateTimeFromString::mm_parsed(), nextNumber(), SPACMaxEntry::readLine(), TFAMaxEntry::readLine(), FKMaxEntry::readLine(), QGpCoreTools::DateTimeFromString::s_parsed(), QGpCoreTools::DateTimeFromString::ss_parsed(), QGpCoreTools::DateTimeFromString::ssz_parsed(), QGpCoreTools::DateTimeFromString::sz_parsed(), QGpCoreTools::LineParser::toInt(), QGpCoreTools::Version::Version(), GeopsyCore::SignalGroup::xml_setProperty(), QGpCoreTools::DateTimeFromString::yy_parsed(), QGpCoreTools::DateTimeFromString::yyyy_parsed(), QGpCoreTools::DateTimeFromString::z_parsed(), and QGpCoreTools::DateTimeFromString::zzz_parsed().
qlonglong QGpCoreTools::StringSection::toLongLong | ( | bool * | ok = 0 , |
int | base = 10 |
||
) | const |
Converts string to long long. ok is set to false if string is not a long long. ok is untouched if if no error occur.
References toString().
Referenced by QGpCoreTools::LineParser::toLongLong().
QString QGpCoreTools::StringSection::toString | ( | ) | const [inline] |
Referenced by QGpCoreTools::DateTimeFromString::ap_parsed(), QGpCoreTools::DateTimeFromString::AP_parsed(), QGpCoreTools::DateTimeFromString::d_parsed(), QGpCoreTools::DateTimeFromString::dd_parsed(), QGpCoreTools::DateTimeFromString::ddd_parsed(), QGpCoreTools::DateTimeFromString::dddd_parsed(), QGpCoreWave::RefractionDippingModel::fromStream(), QGpCoreWave::Seismic1DModel::fromStream(), Distance::fromString(), SciFigs::AbstractNameLine::fromString(), QGpCoreTools::NamedPoint::fromString(), QGpCoreTools::DateTimeFromString::h_parsed(), QGpCoreTools::DateTimeFromString::H_parsed(), QGpCoreTools::DateTimeFromString::hh_parsed(), QGpCoreTools::DateTimeFromString::HH_parsed(), GeopsyCore::SubSignalPool::importTable(), QGpCoreTools::DateTimeFromString::M_parsed(), QGpCoreTools::DateTimeFromString::m_parsed(), QGpCoreTools::DateTimeFromString::MM_parsed(), QGpCoreTools::DateTimeFromString::mm_parsed(), QGpCoreTools::DateTimeFromString::MMM_parsed(), QGpCoreTools::DateTimeFromString::MMMM_parsed(), QGpCoreTools::DateTimeFromString::other_parsed(), QGpCoreTools::XMLParser::parse(), QGpCoreTools::DateTimeFromString::quote_parsed(), QGpCoreTools::DateTimeToString::quote_parsed(), QGpCoreTools::DateTimeFromString::s_parsed(), SciFigs::Axis::setStringLabels(), QGpCoreTools::DateTimeFromString::ss_parsed(), QGpCoreTools::DateTimeFromString::ssz_parsed(), QGpCoreTools::DateTimeFromString::sz_parsed(), toDouble(), toInt(), toLongLong(), QGpCoreTools::LineParser::toString(), toUInt(), QGpCoreTools::Version::Version(), GeopsyGui::TimeWindow::xml_setAttributes(), GeopsyCore::TimeRangeParameters::xml_setAttributes(), QGpGuiTools::ColorPalette::xml_setProperty(), SciFigs::CircleViewer::xml_setProperty(), QGpCoreTools::DateTimeFromString::yy_parsed(), QGpCoreTools::DateTimeFromString::yyyy_parsed(), QGpCoreTools::DateTimeFromString::z_parsed(), and QGpCoreTools::DateTimeFromString::zzz_parsed().
uint QGpCoreTools::StringSection::toUInt | ( | bool * | ok = 0 , |
int | base = 10 |
||
) | const |
Converts string to unsinged integer. ok is set to false if string is not an unsinged integer. ok is untouched if if no error occur.
References toString().
Referenced by QGpCoreTools::LineParser::toUInt().
Removes white space at the end and at the beginning.
References isValid(), and TRACE.
Referenced by QGpCoreWave::Resistivity1DModel::fromStream(), QGpCoreWave::RefractionDippingModel::fromStream(), QGpCoreWave::Seismic1DModel::fromStream(), and QGpCoreTools::operator>>().
const QString QGpCoreTools::StringSection::defaultSeparators = "\t " [static] |
Default separators inside a line: tab and space
Referenced by QGpCoreTools::LineParser::LineParser().
const StringSection QGpCoreTools::StringSection::null [static] |
Default static null string
Referenced by QGpCoreTools::LineParser::count(), mid(), and readLine().