6 #include <FBaseCharacter.h>
8 #include <FBaseInteger.h>
9 #include <FBaseShort.h>
10 #include <FBaseLong.h>
11 #include <FBaseLongLong.h>
12 #include <FBaseFloat.h>
13 #include <FBaseDouble.h>
14 #include <FBaseResult.h>
15 #include "FBaseUtil_ScannerImpl.h"
16 #include "FBaseUtilRegularExpression.h"
17 #include <FBaseColArrayList.h>
18 #include <FBaseSysLog.h>
19 #include "FBaseUtil_RegularExpressionImpl.h"
20 #include "FBase_StringConverter.h"
21 #include "FBaseUtil_IcuConverter.h"
22 #include "FBase_NativeError.h"
24 #define ANY_PATTERN L"\\s*[^\\s]*"
25 #define DEFAULT_DELIMITER_PATTERN L"\\s*"
26 //#define DEFAULT_LINE_SEPARATOR_PATTERN L".*(\r\n|[\u000A\n\r\u2028\u2029\u0085])|.+$"
27 #define COMPLETE_LINE_PATTERN L".*(\r\n|[\u000A\n\r\u2028\u2029\u0085])|.+$"
28 #define DEFAULT_LINE_SEPARATOR_PATTERN L"[\u000A\n\r\u2028\u2029\u0085]*"
31 #define DEFAULT_GROUP_SEPARATOR L","
32 #define DEFAULT_DECIMAL_SEPARATOR L"."
33 #define DEFAULT_NEGATIVE_PREFIX L"-"
35 using namespace Tizen::Base::Collection;
36 using namespace Tizen::Base::Utility;
37 using namespace Tizen::Base;
39 namespace Tizen { namespace Base { namespace Utility
41 _ScannerImpl::_ScannerImpl(void)
43 __delimiter(DEFAULT_DELIMITER_PATTERN),
45 __isAllocatedOnHeap(false),
51 _ScannerImpl::~_ScannerImpl()
53 if(__isAllocatedOnHeap == true)
60 result _ScannerImpl::Construct(const String& str)
63 __pParseStr = str.GetPointer();
67 result _ScannerImpl::Construct(const String& filePath, const String& encodingScheme)
71 char* pFilePath = null;
73 _ICUConverter converter;
80 pFilePath = _StringConverter::CopyToCharArrayN(filePath);
81 SysTryReturnResult(NID_BASE_UTIL, pFilePath != null, GetLastResult(), "File path length < 0 or E_OUT_OF_MEMORY");
83 res = converter.OpenConverter(encodingScheme);
85 SysTryCatch(NID_BASE_UTIL, res == true, , r, "[%s] Encoding scheme not supported", GetErrorMessage(r));
87 pFile = fopen(pFilePath, "r");
88 SysTryCatch(NID_BASE_UTIL, pFile != null, r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
89 "[%s] Failed to open the file.", GetErrorMessage(__ConvertNativeErrorToResult(errno)));
91 retVal = stat(pFilePath, &st);
92 SysTryCatch(NID_BASE_UTIL, retVal != 0, r = E_IO, E_IO,
93 "[%s] Failed to get information about the file.", GetErrorMessage(__ConvertNativeErrorToResult(errno)));
95 fileSize = st.st_size + 1; // +1 for null-terminated string
97 buffer = static_cast<char*>(calloc(fileSize, sizeof(char)));
98 SysTryCatch(NID_BASE_UTIL, buffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]");
99 readCnt = fread(buffer, 1, fileSize - 1, pFile);
101 if (readCnt < fileSize)
103 int ret = ferror(pFile);
104 SysTryCatch(NID_BASE_UTIL, ret != 0, r = E_IO, E_IO, "[%s] Failed to perform read operation.", GetErrorMessage(E_IO));
107 __pParseStr = converter.ConvertToUcharN(buffer, fileSize);
108 SysTryCatch(NID_BASE_UTIL, __pParseStr != null, r = E_IO, E_IO , "[%s] charcater conversion failed.", GetErrorMessage(E_IO));
109 __isAllocatedOnHeap = true;
127 bool _ScannerImpl::HasNextToken(void)
129 String pattern(ANY_PATTERN);
130 return HasNextToken(pattern);
133 bool _ScannerImpl::HasNextToken(const RegularExpression& pattern)
135 String patStr(pattern.GetPattern());
136 return HasNextToken(patStr);
139 bool _ScannerImpl::HasNextToken(const String& pattern)
141 result r = E_SUCCESS;
145 r = GetNextToken(pattern, token, length);
146 SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_DATA_NOT_FOUND, "[%s] Can not get the next token", GetErrorMessage(E_DATA_NOT_FOUND));
152 result _ScannerImpl::GetNextToken(String& nextStr)
154 result r = E_SUCCESS;
155 String pattern(ANY_PATTERN);
158 r = GetNextToken(pattern, nextStr, length);
159 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_DATA_NOT_ENOUGH, "Can not get the next token");
161 __position = __position + length;
166 result _ScannerImpl::GetNextToken(const RegularExpression& pattern, String& nextStr)
168 String patStr(pattern.GetPattern());
169 return GetNextToken(patStr, nextStr);
172 result _ScannerImpl::GetNextToken(const String& pattern, String& nextStr)
174 result r = E_SUCCESS;
179 String anyPattern(ANY_PATTERN);
181 r = GetNextToken(anyPattern, str1, length);
182 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS || r == E_DATA_NOT_ENOUGH, E_DATA_NOT_ENOUGH, "Input has no remaining tokens");
184 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_DATA_NOT_FOUND, "The next token does not match to the pattern");
186 r = GetNextToken(pattern, str2, length);
187 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS || r == E_DATA_NOT_ENOUGH, E_DATA_NOT_ENOUGH, "Input has no remaining tokens");
189 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_DATA_NOT_FOUND, "The next token does not match to the pattern");
194 __position = __position + length;
200 result _ScannerImpl::GetNextSignedChar(signed char& nextSignedChar)
202 return GetNextSignedChar(nextSignedChar, __radix);
205 result _ScannerImpl::GetNextSignedChar(signed char& nextSignedChar, int radix)
207 result r = E_SUCCESS;
211 String pattern(ANY_PATTERN);
213 r = GetNextToken(pattern, out, length);
214 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS || r == E_DATA_NOT_ENOUGH, E_DATA_NOT_ENOUGH, "Input has no remaining tokens");
216 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to signed char");
217 /* if(out.GetLength() > 1)
219 return E_OPERATION_FAILED;
222 r = Int8::Parse(out, radix, ch);
223 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to signed char");
225 nextSignedChar = static_cast<signed char>(ch);
226 __position = __position + length;
231 bool _ScannerImpl::IsNextTokenConvertibleToSignedChar(void)
233 return IsNextTokenConvertibleToSignedChar(__radix);
236 bool _ScannerImpl::IsNextTokenConvertibleToSignedChar(int radix)
238 result r = E_SUCCESS;
241 String pattern(ANY_PATTERN);
244 r = GetNextToken(pattern, out, length);
245 SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_NUM_FORMAT, "[%s] Can not get the next token as signed char", GetErrorMessage(E_NUM_FORMAT));
247 /* if(out.GetLength() > 1)
249 return E_OPERATION_FAILED;
252 r = Int8::Parse(out, radix, ch);
253 SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_NUM_FORMAT, "[%s] Can not parse the token to signed char", GetErrorMessage(E_NUM_FORMAT));
258 result _ScannerImpl::GetNextInt(int& nextInt)
260 return GetNextInt(nextInt, __radix);
263 result _ScannerImpl::GetNextInt(int& nextInt, int radix)
265 result r = E_SUCCESS;
268 String pattern(ANY_PATTERN);
270 r = GetNextToken(pattern, out, length);
271 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS || r == E_DATA_NOT_ENOUGH, E_DATA_NOT_ENOUGH, "Input has no remaining tokens");
273 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to integer");
275 out.Replace(DEFAULT_GROUP_SEPARATOR, L"");
276 r = Integer::Parse(out, radix, nextInt);
277 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to integer");
279 __position = __position + length;
284 bool _ScannerImpl::IsNextTokenConvertibleToInt(void)
286 return IsNextTokenConvertibleToInt(__radix);
289 bool _ScannerImpl::IsNextTokenConvertibleToInt(int radix)
291 result r = E_SUCCESS;
295 String pattern(ANY_PATTERN);
297 r = GetNextToken(pattern, out, length);
298 SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_NUM_FORMAT, "[%s] Can not get the next token as integer", GetErrorMessage(E_NUM_FORMAT));
300 out.Replace(DEFAULT_GROUP_SEPARATOR, L"");
301 r = Integer::Parse(out, radix, val);
302 SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_NUM_FORMAT, "[%s] Can not get next Integer", GetErrorMessage(E_NUM_FORMAT));
307 result _ScannerImpl::GetNextShort(short& nextShort)
309 return GetNextShort(nextShort, __radix);
312 result _ScannerImpl::GetNextShort(short& nextShort, int radix)
314 result r = E_SUCCESS;
317 String pattern(ANY_PATTERN);
319 r = GetNextToken(pattern, out, length);
320 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS || r == E_DATA_NOT_ENOUGH, E_DATA_NOT_ENOUGH, "Input has no remaining tokens");
322 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to short");
324 out.Replace(DEFAULT_GROUP_SEPARATOR, L"");
325 r = Short::Parse(out, radix, nextShort);
326 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to short");
328 __position = __position + length;
333 bool _ScannerImpl::IsNextTokenConvertibleToShort(void)
335 return IsNextTokenConvertibleToShort(__radix);
338 bool _ScannerImpl::IsNextTokenConvertibleToShort(int radix)
340 result r = E_SUCCESS;
344 String pattern(ANY_PATTERN);
346 r = GetNextToken(pattern, out, length);
347 SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_NUM_FORMAT, "[%s] Can not get next token as short", GetErrorMessage(E_NUM_FORMAT));
349 out.Replace(DEFAULT_GROUP_SEPARATOR, L"");
350 r = Short::Parse(out, radix, val);
351 SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_NUM_FORMAT, "[%s] Can not get next short", GetErrorMessage(E_NUM_FORMAT));
356 result _ScannerImpl::GetNextLongLong(long long& nextLongLong)
358 result r = E_SUCCESS;
361 String pattern(ANY_PATTERN);
363 r = GetNextToken(pattern, out, length);
364 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS || r == E_DATA_NOT_ENOUGH, E_DATA_NOT_ENOUGH, "Input has no remaining tokens");
366 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to long long");
368 out.Replace(DEFAULT_GROUP_SEPARATOR, L"");
369 r = LongLong::Parse(out, nextLongLong);
370 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to long long");
372 __position = __position + length;
377 bool _ScannerImpl::IsNextTokenConvertibleToLongLong(void)
379 result r = E_SUCCESS;
383 String pattern(ANY_PATTERN);
385 r = GetNextToken(pattern, out, length);
386 SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_NUM_FORMAT, "[E_NUM_FORMAT] Can not get next token as long long");
388 r = LongLong::Parse(out, val);
389 SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_NUM_FORMAT, "[E_NUM_FORMAT] Can not get next long long");
394 result _ScannerImpl::GetNextFloat(float& nextFloat)
396 result r = E_SUCCESS;
399 String pattern(ANY_PATTERN);
401 r = GetNextToken(pattern, out, length);
402 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS || r == E_DATA_NOT_ENOUGH, E_DATA_NOT_ENOUGH, "Input has no remaining tokens");
404 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to float");
406 out.Replace(DEFAULT_GROUP_SEPARATOR, L"");
407 r = Float::Parse(out, nextFloat);
408 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to float");
410 __position = __position + length;
416 bool _ScannerImpl::IsNextTokenConvertibleToFloat(void)
418 result r = E_SUCCESS;
420 RegularExpression re;
423 String pattern(ANY_PATTERN);
425 r = GetNextToken(pattern, out, length);
426 SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_NUM_FORMAT, "[%s] Can not get next token as float", GetErrorMessage(E_NUM_FORMAT));
428 out.Replace(DEFAULT_GROUP_SEPARATOR, L"");
429 r = Float::Parse(out, val);
430 SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_NUM_FORMAT, "[%s] Can not get next float", GetErrorMessage(E_NUM_FORMAT));
435 result _ScannerImpl::GetNextDouble(double& nextDouble)
437 result r = E_SUCCESS;
440 String pattern(ANY_PATTERN);
442 r = GetNextToken(pattern, out, length);
443 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS || r == E_DATA_NOT_ENOUGH, E_DATA_NOT_ENOUGH, "Input has no remaining tokens");
445 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to double");
447 out.Replace(DEFAULT_GROUP_SEPARATOR, L"");
448 r = Double::Parse(out, nextDouble);
449 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to double");
451 __position = __position + length;
456 bool _ScannerImpl::IsNextTokenConvertibleToDouble(void)
458 result r = E_SUCCESS;
462 String pattern(ANY_PATTERN);
464 r = GetNextToken(pattern, out, length);
465 SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_NUM_FORMAT, "[%s] Can not get next token as double", GetErrorMessage(E_NUM_FORMAT));
467 out.Replace(DEFAULT_GROUP_SEPARATOR, L"");
468 r = Double::Parse(out, val);
469 SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_NUM_FORMAT, "[%s] Can not get next token", GetErrorMessage(E_NUM_FORMAT));
474 result _ScannerImpl::GetNextBool(bool& nextBool)
476 result r = E_SUCCESS;
479 String pattern(ANY_PATTERN);
481 r = GetNextToken(pattern, out, length);
482 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS || r == E_DATA_NOT_ENOUGH, E_DATA_NOT_ENOUGH, "Input has no remaining tokens");
484 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not parse the token to bool");
487 r = out.ToUpper(temp);
488 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_NUM_FORMAT, "Can not get next bool");
490 if(!temp.CompareTo(L"TRUE"))
493 __position = __position + length;
495 else if(!temp.CompareTo(L"FALSE"))
498 __position = __position + length;
508 bool _ScannerImpl::IsNextTokenConvertibleToBool(void)
510 result r = E_SUCCESS;
514 String pattern(ANY_PATTERN);
516 r = GetNextToken(pattern, out, length);
517 SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_NUM_FORMAT, "[%s] Can not get next token as bool", GetErrorMessage(E_NUM_FORMAT));
521 if((!temp.CompareTo(L"TRUE")) || (!temp.CompareTo(L"FALSE")))
533 bool _ScannerImpl::HasNextLine(void)
535 result r = E_SUCCESS;
536 String pattern(DEFAULT_LINE_SEPARATOR_PATTERN);
537 RegularExpression regex;
538 ArrayList matchedStrList;
541 r = regex.Construct(pattern, REGEX_UNICODE);
542 SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_DATA_NOT_ENOUGH, "[%s] Regular expression construction failed", GetErrorMessage(E_DATA_NOT_ENOUGH));
544 r = matchedStrList.Construct();
545 SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, false, E_DATA_NOT_ENOUGH, "[%s] Arraylist construction failed", GetErrorMessage(E_DATA_NOT_ENOUGH));
547 res = regex.Match(String(__pParseStr + __position), false, &matchedStrList);
548 SysTryReturn(NID_BASE_UTIL, res == true, false, E_DATA_NOT_ENOUGH, "[%s] Match Failed", GetErrorMessage(E_DATA_NOT_ENOUGH));
554 result _ScannerImpl::GetNextLine(String& nextLine)
556 result r = E_SUCCESS;
557 String pattern(COMPLETE_LINE_PATTERN);
558 RegularExpression regex;
559 ArrayList matchedStrList;
563 r = regex.Construct(pattern, REGEX_UNICODE);
564 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_DATA_NOT_ENOUGH, "Regular expression construction failed");
566 r = matchedStrList.Construct();
567 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_DATA_NOT_ENOUGH, "Arraylist construction failed");
569 res = regex.Match(String(__pParseStr + __position), false, &matchedStrList);
570 SysTryReturnResult(NID_BASE_UTIL, res == true, E_DATA_NOT_ENOUGH, "Match Failed");
572 matches = matchedStrList.GetCount();
575 String temp = *(String *)matchedStrList.GetAt(0);
576 __position = __position + temp.GetLength();
578 RegularExpression re;
579 r = re.Construct(DEFAULT_LINE_SEPARATOR_PATTERN, REGEX_UNICODE);
580 re.Replace(temp, L"", true);
583 matchedStrList.RemoveAll();
590 result _ScannerImpl::FindInLine(const String& str, String& MatchedStr)
592 result r = E_SUCCESS;
593 _RegularExpressionImpl regex;
594 ArrayList matchedStrList;
598 r = regex.Construct(str, REGEX_UNICODE);
599 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_DATA_NOT_FOUND, "Regular expression construction failed");
601 r = matchedStrList.Construct();
602 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_DATA_NOT_FOUND, "Arraylist construction failed");
604 res = regex.Match(String(__pParseStr + __position), false, &matchedStrList);
605 SysTryReturnResult(NID_BASE_UTIL, res == true, E_DATA_NOT_FOUND, "Match Failed");
607 matches = matchedStrList.GetCount();
610 MatchedStr = *(String *)matchedStrList.GetAt(0);
611 int matchEnd = regex.GetLastMatchEnd();
612 __position = __position + matchEnd;
613 matchedStrList.RemoveAll();
619 result _ScannerImpl::FindInLine(const RegularExpression& pattern, String& MatchedStr)
621 String patStr(pattern.GetPattern());
622 return FindInLine(patStr, MatchedStr);
625 void _ScannerImpl::Skip(const String& str)
627 result r = E_SUCCESS;
628 RegularExpression regex;
629 ArrayList matchedStrList;
633 r = regex.Construct(str, REGEX_UNICODE);
634 SysTryCatch(NID_BASE_UTIL, r == E_SUCCESS, , r, "[%s] Regular expression construction failed", GetErrorMessage(r));
636 r = matchedStrList.Construct();
637 SysTryCatch(NID_BASE_UTIL, r == E_SUCCESS, , r, "[%s] ArrayList construction failed", GetErrorMessage(r));
639 res = regex.Match(String(__pParseStr + __position), false, &matchedStrList);
640 SysTryCatch(NID_BASE_UTIL, res == true, , E_SYSTEM, "[%s] Regular expression match failed", GetErrorMessage(E_SYSTEM));
642 matches = matchedStrList.GetCount();
645 String temp = *(String *)matchedStrList.GetAt(0);
646 int length = temp.GetLength();
647 const wchar_t* wstr1 = temp.GetPointer();
648 const wchar_t* wstr2 = __pParseStr + __position;
651 while(*wstr1 != 0x0000)
653 if(*wstr1++ != *wstr2++)
661 __position = __position + length;
663 matchedStrList.RemoveAll();
665 //Skip if there is any delimiters before the next token
666 RegularExpression re;
667 r = re.Construct(DEFAULT_DELIMITER_PATTERN, REGEX_UNICODE);
668 res = re.Match(String(__pParseStr + __position), false, &matchedStrList);
669 matches = matchedStrList.GetCount();
672 String temp = *(String *)matchedStrList.GetAt(0);
673 int length = temp.GetLength();
674 __position = __position + length;
675 matchedStrList.RemoveAll();
684 void _ScannerImpl::Skip(const RegularExpression& pattern)
686 String patStr(pattern.GetPattern());
690 int _ScannerImpl::GetRadix(void)
695 String _ScannerImpl::GetDelimiter(void)
700 void _ScannerImpl::SetDelimiter(const String& delimiter)
702 __delimiter = delimiter;
705 void _ScannerImpl::SetDelimiter(const RegularExpression& pattern)
707 __delimiter = pattern.GetPattern();
710 void _ScannerImpl::SetRadix(int radix)
712 if(((radix == Character::RADIX_BINARY) || (radix == Character::RADIX_OCTAL) ||
713 (radix == Character::RADIX_DECIMAL) || (radix == Character::RADIX_HEXADECIMAL)))
719 result _ScannerImpl::GetNextToken(const String& pattern, String& ret, int& length)
721 result r = E_SUCCESS;
722 SysTryReturnResult(NID_BASE_UTIL, __pParseStr != null, E_DATA_NOT_ENOUGH, "Input has no remaining tokens.");
723 SysTryReturnResult(NID_BASE_UTIL, *__pParseStr != 0x0000, E_DATA_NOT_ENOUGH, "Input has no remaining tokens.");
725 RegularExpression regex;
726 ArrayList matchedStrList;
729 String regPattern(pattern);
731 regPattern.Append(__delimiter);
733 r = regex.Construct(regPattern, REGEX_UNICODE);
734 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_OPERATION_FAILED, "Regular expression construction failed");
736 r = matchedStrList.Construct();
737 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_OPERATION_FAILED, "Arraylist construction failed");
739 res = regex.Match(String(__pParseStr + __position), false, &matchedStrList);
740 SysTryReturnResult(NID_BASE_UTIL, res == true, E_OPERATION_FAILED, "Match Failed");
742 matches = matchedStrList.GetCount();
745 String temp = *(String *)matchedStrList.GetAt(0);
746 length = temp.GetLength();
747 RegularExpression re;
748 r = re.Construct(__delimiter, REGEX_UNICODE);
749 re.Replace(temp, L"", true);
751 matchedStrList.RemoveAll();
757 result _ScannerImpl::GetNextMatchingString(const String& pattern, String& ret, int& length)
759 result r = E_SUCCESS;
760 RegularExpression regex;
761 ArrayList matchedStrList;
768 String strPat(ANY_PATTERN);
769 strPat.Append(DEFAULT_DELIMITER_PATTERN);
771 r = regex.Construct(strPat, REGEX_UNICODE);
772 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_OPERATION_FAILED, "Regular expression construction failed");
774 r = matchedStrList.Construct();
775 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_OPERATION_FAILED, "Arraylist construction failed");
777 res = regex.Match(String(__pParseStr + __position), false, &matchedStrList);
779 SysTryReturnResult(NID_BASE_UTIL, res == true, E_OPERATION_FAILED, "Match Failed");
781 matches = matchedStrList.GetCount();
784 nextToken = *(String *)matchedStrList.GetAt(0);
785 matchedStrList.RemoveAll();
789 strPat.Append(DEFAULT_DELIMITER_PATTERN);
790 r = regex.Construct(strPat, REGEX_UNICODE);
791 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_OPERATION_FAILED, "Regular expression construction failed");
793 r = matchedStrList.Construct();
794 SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_OPERATION_FAILED, "Arraylist construction failed");
796 res = regex.Match(String(__pParseStr + __position), false, &matchedStrList);
797 SysTryReturnResult(NID_BASE_UTIL, res == true, E_OPERATION_FAILED, "Match Failed");
799 matches = matchedStrList.GetCount();
802 matchToken = *(String *)matchedStrList.GetAt(0);
803 matchedStrList.RemoveAll();
805 if((nextToken == matchToken) == true)
807 length = matchToken.GetLength();
808 RegularExpression re;
809 r = re.Construct(DEFAULT_DELIMITER_PATTERN, REGEX_UNICODE);
810 re.Replace(matchToken, L"", true);
815 r = E_OPERATION_FAILED;
822 }}} // Osp::Base::Utility