source: SMSSender/lib/datatypes/src/snumber.h @ 236:4ae05876cecb

Last change on this file since 236:4ae05876cecb was 236:4ae05876cecb, checked in by Sämy Zehnder <saemy.zehnder@…>, 8 years ago
  • Added missing visibility macros in some class definitions.
  • Subclassing some interfaces from QObject since they had only inline functions and therefore were not made visible in the shared library by g++ on windows (why?!).
  • Using de_DE instead of de_CH if no locale is defined yet.
File size: 2.0 KB
Line 
1/*
2 smssender - A frontend for fast and easy SMS sending over different gateways.
3 Copyright (C) 2007-2012, gorrión. See http://smssender.gorrion.ch
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program 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
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18#ifndef SNUMBER_H_
19#define SNUMBER_H_
20
21#include <QMetaType>
22#include <QString>
23
24#include "datatypes_global.h"
25
26#include "sdatatypes.h"
27#include "smacros.h"
28#include "sshared.h"
29
30class SNumberData;
31
32class DATATYPES_SHARED_EXPORT SNumber {
33    S_SHARED(SNumber, public)
34    S_QHASH_FRIEND(SNumber)
35
36public:
37    static const QString IsoFormat;
38    static const QString IsoFormatShort;
39    static const QString GuessFormat;
40
41public:
42    SNumber(const QString& numberStr, const QString& format = SNumber::GuessFormat);
43    ~SNumber();
44
45    short   countryCode() const;
46    short   areaCode() const;
47    QString userNumber() const;
48
49    bool    setNumber(const QString& numberStr, const QString& format = SNumber::GuessFormat);
50
51    void    clear();
52    bool    isEmpty() const;
53    bool    isValid() const;
54
55    QString toString(const QString& format = SNumber::IsoFormat) const;
56    bool    fromString(const QString& string, const QString& format = SNumber::GuessFormat);
57
58private:
59    void setCountryCode(short countryCode);
60    void setAreaCode(short areaCode);
61    void setUserNumber(const QString& userNumberStr);
62
63    bool isStringPositiveNumber(const QString& str);
64
65    short toShort(const QString& str, bool* ok);
66};
67Q_DECLARE_METATYPE(SNumber)
68DATATYPES_SHARED_EXPORT S_QHASH(SNumber)
69
70#endif /* SNUMBER_H_ */
Note: See TracBrowser for help on using the repository browser.