Chris@629: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
Chris@629: 
Chris@629: /*
Chris@629:     Sonic Visualiser
Chris@629:     An audio file viewer and annotation editor.
Chris@629:     Centre for Digital Music, Queen Mary, University of London.
Chris@629:     
Chris@629:     This program is free software; you can redistribute it and/or
Chris@629:     modify it under the terms of the GNU General Public License as
Chris@629:     published by the Free Software Foundation; either version 2 of the
Chris@629:     License, or (at your option) any later version.  See the file
Chris@629:     COPYING included with this distribution for more information.
Chris@629: */
Chris@629: 
Chris@629: /*
Chris@629:    This is a modified version of a source file from the 
Chris@629:    Rosegarden MIDI and audio sequencer and notation editor.
Chris@629:    This file copyright 2000-2010 Chris Cannam.
Chris@629: */
Chris@629: 
Chris@629: #ifndef _STRING_BITS_H_
Chris@629: #define _STRING_BITS_H_
Chris@629: 
Chris@629: #include <QString>
Chris@629: #include <QStringList>
Chris@629: #include <QChar>
Chris@629: 
Chris@629: class StringBits
Chris@629: {
Chris@629: public:
Chris@629:     /**
Chris@629:      * Convert a string to a double using basic "C"-locale syntax,
Chris@629:      * i.e. always using '.' as a decimal point.  We use this as a
Chris@629:      * fallback when parsing files from an unknown source, if
Chris@629:      * locale-specific conversion fails.  Does not support e notation.
Chris@629:      * If ok is non-NULL, *ok will be set to true if conversion
Chris@629:      * succeeds or false otherwise.
Chris@629:      */
Chris@629:     static double stringToDoubleLocaleFree(QString s, bool *ok = 0);
Chris@629: 
Chris@629:     /**
Chris@629:      * Split a string at the given separator character, allowing
Chris@629:      * quoted sections that contain the separator.  If the separator
Chris@629:      * is ' ', any (amount of) whitespace will be considered as a
Chris@629:      * single separator.  If the separator is another whitespace
Chris@629:      * character such as '\t', it will be used literally.
Chris@629:      */
Chris@629:     static QStringList splitQuoted(QString s, QChar separator);
Chris@629: 
Chris@629:     /**
Chris@629:      * Split a string at the given separator character.  If quoted is
Chris@629:      * true, do so by calling splitQuoted (above).  If quoted is
Chris@629:      * false, use QString::split; if separator is ' ', use
Chris@629:      * SkipEmptyParts behaviour, otherwise use KeepEmptyParts (this is
Chris@629:      * analogous to the behaviour of splitQuoted).
Chris@629:      */
Chris@629:     static QStringList split(QString s, QChar separator, bool quoted);
Chris@629: };
Chris@629: 
Chris@629: #endif