Doomseeker
   
  • Doomseeker
  • Wadseeker
  • Download
  • Tracker
  • Git
  • Docs
  • Main Page
  • Classes
  • Files
  • File List
  • File Members

src/core/strings.h

00001 //------------------------------------------------------------------------------
00002 // strings.h
00003 //------------------------------------------------------------------------------
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00018 // 02110-1301, USA.
00019 //
00020 //------------------------------------------------------------------------------
00021 // Copyright (C) 2010 "Zalewa" <zalewapl@gmail.com>
00022 //------------------------------------------------------------------------------
00023 #ifndef __STRINGS_H_
00024 #define __STRINGS_H_
00025 
00026 #include "global.h"
00027 
00028 class QString;
00029 
00030 // \c = '\034'
00031 #define ESCAPE_COLOR_CHAR       '\034'
00032 
00033 class MAIN_EXPORT Strings
00034 {
00035         public:
00040                 static QString  colorizeString(const QString &str, int def=4);
00041 
00059                 static QString                  combinePaths(QString pathFront, QString pathEnd);
00060 
00066                 static QString                  createRandomAlphaNumericString(unsigned numChars);
00067                 static QString                  createRandomAlphaNumericStringWithNewLines(unsigned numCharsPerLine, unsigned numLines);
00068 
00072                 static const QString    &escape(QString &str);
00073 
00080                 static QString                  formatDataAmount(qint64 bytes);
00081 
00091                 static QString                  formatDataSpeed(float speedInBytesPerSecond);
00092 
00104                 static QString                  formatTime(float seconds);
00105 
00106                 static bool                             isCharOnCharList(char c, const QString& charList);
00107 
00115                 static QString                  normalizePath(QString path);
00116                 
00140                 static QByteArray readUntilByte(QDataStream& stream, unsigned char stopByte);
00141 
00151                 static void                             translateServerAddress(const QString& addressString, QString& hostname, unsigned short& port, const QString& defaultAddress);
00152 
00153                 static const QString    &unescape(QString &str);
00154 
00162                 static bool                             isUrlSafe(const QString& url);
00163 
00164                 static QString                  timestamp(const QString& format);
00165                 static QString&                 trim(QString& str, const QString& charList) { return trimr(triml(str, charList), charList); }
00166                 static QString&                 trimr(QString& str, const QString& charList);
00167                 static QString&                 triml(QString& str, const QString& charList);
00168 
00180                 static QString                  wrapUrlsWithHtmlATags(const QString& str);
00181 
00182         protected:
00183                 enum DataUnit
00184                 {
00185                         Byte            = 0,
00186                         Kilobyte        = 1,
00187                         Megabyte        = 2,
00188                         Gigabyte        = 3
00189                 };
00190 
00191                 static const unsigned   RANDOM_CHAR_POOL_SIZE = 36;
00192                 static const char               RANDOM_CHAR_POOL[RANDOM_CHAR_POOL_SIZE];
00193 
00194 
00195                 static float                    scaleDataUnit(float bytes, DataUnit& outUnit);
00196 };
00197 
00198 #endif
   
Doomseeker © 2009-2024 The Doomseeker Team