kspread

valueparser.h
1/* This file is part of the KDE project
2 Copyright 2004 Tomas Mecir <mecirt@gmail.com>
3 Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KSPREAD_VALUEPARSER
22#define KSPREAD_VALUEPARSER
23
24#include <tqdatetime.h>
25
26#include "kspread_global.h"
27
28class TDELocale;
29
30namespace KSpread
31{
32class Cell;
33class Value;
34
41 public:
43 ValueParser (TDELocale *locale);
44
45 TDELocale* locale();
46
48 void parse (const TQString& str, Cell *cell);
49
51 Value parse (const TQString &str);
52
53 Value tryParseBool (const TQString& str, bool *ok = 0);
54 Value tryParseNumber (const TQString& str, bool *ok = 0);
55 Value tryParseDate (const TQString& str, bool *ok = 0);
56 Value tryParseTime (const TQString& str, bool *ok = 0);
57 protected:
58
59 TDELocale* parserLocale;
60
61 // Try to parse the text as a bool/number/date/time/etc.
62 // Helpers for parse.
63 bool tryParseBool (const TQString& str, Cell *cell);
64 bool tryParseNumber (const TQString& str, Cell *cell);
65 bool tryParseDate (const TQString& str, Cell *cell);
66 bool tryParseTime (const TQString& str, Cell *cell);
67
69 TQDateTime readTime (const TQString & intstr, bool withSeconds, bool *ok,
70 bool & duration);
71
73 double readNumber(const TQString &_str, bool * ok, bool * isInt);
75 int readInt (const TQString &str, uint &pos);
76 FormatType fmtType;
77};
78
79
80} //namespace KSpread
81
82
83#endif //KSPREAD_VALUEPARSER
84
For every cell in the spread sheet there is a Cell object.
The ValueParser parses a text input from the user, generating Value in the desired format.
Definition valueparser.h:40
TQDateTime readTime(const TQString &intstr, bool withSeconds, bool *ok, bool &duration)
converts a string to a date/time value
void parse(const TQString &str, Cell *cell)
try to parse the text in a given cell and set value accordingly
double readNumber(const TQString &_str, bool *ok, bool *isInt)
a helper function to read numbers and distinguish integers and FPs
int readInt(const TQString &str, uint &pos)
a helper function to read integers
Provides a wrapper for cell value.
The KSpread namespace.
Definition commands.h:39