Getting token based on delimiter
[platform/framework/native/appfw.git] / src / base / utility / FBaseUtil_ScannerImpl.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file        FBaseUtil_ScannerImpl.h
19  * @brief       This is the header file for the _ScannerImpl class.
20  *
21  * This header file contains declarations and definitions of the _ScannerImpl class. 
22  *
23  */
24
25 #ifndef _FBASE_UTIL_SCANNER_IMPL_H_
26 #define _FBASE_UTIL_SCANNER_IMPL_H_
27
28 #include <FBaseString.h>
29 #include <FBaseUtilRegularExpression.h>
30
31 namespace Tizen { namespace Base { namespace Utility
32 {
33
34 class _OSP_EXPORT_ _ScannerImpl
35         : public Tizen::Base::Object
36 {
37 public:
38         _ScannerImpl(void);
39         _ScannerImpl(const _ScannerImpl& scanner);
40         _ScannerImpl& operator =(const _ScannerImpl& scanner);
41         virtual ~_ScannerImpl(void);
42
43         result Construct(const String& str);
44         result Construct(const String& filePath, const String& encodingScheme);
45
46         result FindInLine(const String& str, String& MatchedStr); 
47         result FindInLine(const RegularExpression& pattern, String& MatchedStr); 
48         
49         result GetNextSignedChar(signed char& nextSignedChar);
50         result GetNextSignedChar(signed char& nextSignedChar, int radix);
51         result GetNextInt(int& nextInt);
52         result GetNextInt(int& nextInt, int radix);
53         result GetNextShort(short& nextShort);
54         result GetNextShort(short& nextShort, int radix);
55         result GetNextLongLong(long long& nextLongLong);
56         result GetNextLongLong(long long& nextLongLong, int radix);
57         result GetNextFloat(float& nextFloat);
58         result GetNextDouble(double& nextDouble);
59         result GetNextBool(bool& nextBool);
60         result GetNextLine(String& nextLine);
61         result GetNextToken(String& nextStr);
62         result GetNextToken(const String& pattern, String& nextStr);
63         result GetNextToken(const RegularExpression& pattern, String& nextStr);
64
65         int GetRadix(void);
66         String GetDelimiter(void);
67
68         bool HasNextToken(void);
69         bool HasNextToken(const String& pattern);
70         bool HasNextToken(const RegularExpression& pattern);
71         bool IsNextTokenConvertibleToSignedChar(void); 
72         bool IsNextTokenConvertibleToSignedChar(int radix);
73         bool IsNextTokenConvertibleToInt(void);
74         bool IsNextTokenConvertibleToInt(int radix);
75         bool IsNextTokenConvertibleToShort(void);
76         bool IsNextTokenConvertibleToShort(int radix);
77         bool IsNextTokenConvertibleToLongLong(void);
78         bool IsNextTokenConvertibleToFloat(void);
79         bool IsNextTokenConvertibleToDouble(void);
80         bool IsNextTokenConvertibleToBool(void);
81         bool HasNextLine(void);
82
83         void SetRadix(int radix);
84         void SetDelimiter(const String& delimiter);
85         void SetDelimiter(const RegularExpression& pattern);
86
87         void Skip(const String& str);
88         void Skip(const RegularExpression& pattern);
89         result GetNextToken(const String& pattern, String& ret, int& matTokenLen);
90         result GetNextMatchingString(const String& pattern, String& ret, int& length);
91
92 private :
93         result GetNextTokenWithoutPattern(String& ret, int& length);
94
95 public:
96         int __radix;
97         String __delimiter;
98         const wchar_t* __pParseStr;
99         bool __isAllocatedOnHeap;
100         int __position;
101
102         friend class Scanner;
103 }; // _ScannerImpl
104
105 }}}   // Osp::Base::Utility
106
107 #endif // _FBASE_UTIL_SCANNER_IMPL_H_