kspread

valueparser.h

00001 /* This file is part of the KDE project
00002    Copyright 2004 Tomas Mecir <mecirt@gmail.com>
00003    Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library 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 GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef KSPREAD_VALUEPARSER
00022 #define KSPREAD_VALUEPARSER
00023 
00024 #include <qdatetime.h>
00025 
00026 #include "kspread_global.h"
00027 
00028 class KLocale;
00029 
00030 namespace KSpread
00031 {
00032 class Cell;
00033 class Value;
00034 
00040 class ValueParser {
00041  public:
00043   ValueParser (KLocale *locale);
00044   
00045   KLocale* locale();
00046   
00048   void parse (const QString& str, Cell *cell);
00049 
00051   Value parse (const QString &str);
00052   
00053   Value tryParseBool (const QString& str, bool *ok = 0);
00054   Value tryParseNumber (const QString& str, bool *ok = 0);
00055   Value tryParseDate (const QString& str, bool *ok = 0);
00056   Value tryParseTime (const QString& str, bool *ok = 0);
00057  protected:
00058  
00059   KLocale* parserLocale;
00060 
00061   // Try to parse the text as a bool/number/date/time/etc.
00062   // Helpers for parse.
00063   bool tryParseBool (const QString& str, Cell *cell);
00064   bool tryParseNumber (const QString& str, Cell *cell);
00065   bool tryParseDate (const QString& str, Cell *cell);
00066   bool tryParseTime (const QString& str, Cell *cell);
00067   
00069   QDateTime readTime (const QString & intstr, bool withSeconds, bool *ok,
00070       bool & duration);
00071 
00073   double readNumber(const QString &_str, bool * ok, bool * isInt);
00075   int readInt (const QString &str, uint &pos);
00076   FormatType fmtType;
00077 };
00078 
00079 
00080 }  //namespace KSpread
00081 
00082 
00083 #endif  //KSPREAD_VALUEPARSER
00084 
KDE Home | KDE Accessibility Home | Description of Access Keys