#include <StringBits.h>

Public Types

enum  EscapeMode { EscapeAny, EscapeBackslash, EscapeDoubling, EscapeNone }
 

Static Public Member Functions

static double stringToDoubleLocaleFree (QString s, bool *ok=0)
 Convert a string to a double using basic "C"-locale syntax, i.e. More...
 
static QStringList splitQuoted (QString s, QChar separator, EscapeMode escapeMode=EscapeAny)
 Split a string at the given separator character, allowing quoted sections that contain the separator. More...
 
static QStringList split (QString s, QChar separator, bool quoted)
 Split a string at the given separator character. More...
 
static QString joinDelimited (QVector< QString > row, QString delimiter)
 Join a vector of strings into a single string, with the delimiter as the joining string. More...
 
static bool isValidUtf8 (const std::string &bytes, bool isTruncated)
 Return true if the given byte array contains a valid UTF-8 sequence, false if not. More...
 

Detailed Description

Definition at line 28 of file StringBits.h.

Member Enumeration Documentation

Enumerator
EscapeAny 
EscapeBackslash 
EscapeDoubling 
EscapeNone 

Definition at line 41 of file StringBits.h.

Member Function Documentation

double StringBits::stringToDoubleLocaleFree ( QString  s,
bool *  ok = 0 
)
static

Convert a string to a double using basic "C"-locale syntax, i.e.

always using '.' as a decimal point. We use this as a fallback when parsing files from an unknown source, if locale-specific conversion fails. Does not support e notation. If ok is non-NULL, *ok will be set to true if conversion succeeds or false otherwise.

Definition at line 28 of file StringBits.cpp.

Referenced by CSVFileReader::convertTimeValue(), and CSVFormat::guessQualities().

QStringList StringBits::splitQuoted ( QString  s,
QChar  separator,
EscapeMode  escapeMode = EscapeAny 
)
static

Split a string at the given separator character, allowing quoted sections that contain the separator.

If the separator is ' ', any (amount of) whitespace will be considered as a single separator. If the separator is another whitespace character such as '', it will be used literally.

Definition at line 75 of file StringBits.cpp.

QStringList StringBits::split ( QString  s,
QChar  separator,
bool  quoted 
)
static

Split a string at the given separator character.

If quoted is true, do so by calling splitQuoted (above) in EscapeAny escape mode. If quoted is false, use QString::split; if separator is ' ', use SkipEmptyParts behaviour, otherwise use KeepEmptyParts (this is analogous to the behaviour of splitQuoted).

Definition at line 160 of file StringBits.cpp.

Referenced by CSVFormat::guessQualities(), CSVFormat::guessSeparator(), and CSVFileReader::load().

QString StringBits::joinDelimited ( QVector< QString >  row,
QString  delimiter 
)
static

Join a vector of strings into a single string, with the delimiter as the joining string.

If a string contains the delimiter already, quote it with double-quotes, replacing any existing double-quotes within it by a pair of double-quotes, as specified in RFC 4180 Common Format and MIME Type for Comma-Separated Values (CSV) Files.

Definition at line 172 of file StringBits.cpp.

Referenced by CSVStreamWriter::writeInChunks(), and CSVFileWriter::writeSelection().

bool StringBits::isValidUtf8 ( const std::string &  bytes,
bool  isTruncated 
)
static

Return true if the given byte array contains a valid UTF-8 sequence, false if not.

If isTruncated is true, the byte array will be treated as the prefix of a longer byte sequence, and any errors resulting from a multibyte code ending prematurely at the end of the array will be ignored.

Definition at line 189 of file StringBits.cpp.

Referenced by TextTest::isApparentTextDocument().


The documentation for this class was generated from the following files: