* @file FBaseUtilDeflator.cpp
* @brief This is the implementation file for Deflator class.
*/
-
-// Includes
#include <stdlib.h>
#include <new>
#include <unique_ptr.h>
#include <FBaseSysLog.h>
#include "zlib.h"
-
namespace Tizen { namespace Base { namespace Utility
{
{
}
-
Deflator::~Deflator(void)
{
}
-
///////////////////////////////////////////////////////////////////////////////
/// Deflator class Operations
default:
compLevel = Z_DEFAULT_COMPRESSION;
}
- pInArray = const_cast < Byte* >(src.GetPointer() + src.GetPosition());
+ pInArray = const_cast< Byte* >(src.GetPointer() + src.GetPosition());
stream.zalloc = (alloc_func) 0;
stream.zfree = (free_func) 0;
return null;
}
- std::unique_ptr< Byte, FreeCustomDeleter> pOutArray(static_cast< Byte* >(pOutPutArray));
+ std::unique_ptr< Byte, FreeCustomDeleter > pOutArray(static_cast< Byte* >(pOutPutArray));
outputSize = stream.total_out;
return pOutBuf.release();
}
-
ByteBuffer*
Deflator::DeflateN(const ByteBuffer& src, CompressionLevel level)
{
int byteCount = src.GetRemaining();
return DeflateN(src, byteCount, level);
}
-
-} } } // Tizen::Base::Utility
+}}} // Tizen::Base::Utility
\ No newline at end of file
* @File : FBaseUtilFileUnzipper.cpp
* @brief : Implementation for FileUnzipper Class
*/
-
#include <limits.h>
#include <unique_ptr.h>
#include "FBaseUtil_ZipEntryInfo.h"
#include "FBaseUtil_FileUnzipperImpl.h"
-
namespace Tizen {namespace Base {namespace Utility
{
-
#define UNZ_COMP_CASE_SENSITIVE 1
#define UNZ_COMP_NO_CASE_SENSITIVE 2
#define UNZ_WRITE_BUF_LEN 4096 \
// _BADA_SLP_FIXME : TODO - Select an optimal value for this.
-
FileUnzipper::FileUnzipper(void)
: __pFileUnzipperImpl(null)
{
}
-
FileUnzipper::~FileUnzipper(void)
{
delete __pFileUnzipperImpl;
}
-
result
FileUnzipper::Construct(const String& filePath)
{
SysTryReturnResult(NID_BASE_UTIL, !IsFailed(r), r, "[%s] Propagating.", GetErrorMessage(r));
__pFileUnzipperImpl = pFileUnzipperImpl.release();
-
+
return r;
}
-
result
FileUnzipper::UnzipTo(const String& dirPath) const
{
return __pFileUnzipperImpl->UnzipTo(dirPath);
}
-
result
FileUnzipper::UnzipTo(const String& dirPath, const String& zipEntryName) const
{
return __pFileUnzipperImpl->UnzipTo(dirPath, zipEntryName);
}
-
int
FileUnzipper::GetEntryCount(void) const
{
return __pFileUnzipperImpl->GetEntryCount();
}
-
int
FileUnzipper::GetFileCount(void) const
{
return __pFileUnzipperImpl->GetFileCount();
}
-
int
FileUnzipper::GetDirectoryCount(void) const
{
return __pFileUnzipperImpl->GetDirectoryCount();
}
-
result
FileUnzipper::GetEntry(const String& zipEntryName, ZipEntry& entry) const
{
return __pFileUnzipperImpl->GetEntry(zipEntryName, entry);
}
-
result
FileUnzipper::GetEntry(int index, ZipEntry& entry) const
{
return __pFileUnzipperImpl->GetEntry(index, entry);
}
-
-
-} } } // Tizen::Base::Utility
+}}} // Tizen::Base::Utility
\ No newline at end of file
* @File : FBaseUtilFileZipper.cpp
* @brief : Implementation for FileZipper Class
*/
-
#include <limits.h>
#include <unique_ptr.h>
#include <FBaseSysLog.h>
#include "FBaseUtil_FileZipperImpl.h"
-
using namespace Tizen::Io;
namespace Tizen { namespace Base { namespace Utility
__pFileZipperImpl->SetOverwriteFlag(flag);
}
}
-
-} } } // Tizen::Base::Utility
+}}} // Tizen::Base::Utility
\ No newline at end of file
* @file FBaseUtilInflator.cpp
* @brief This is the implementation file for Inflator class.
*/
-
-// Includes
#include <stdlib.h>
#include <new>
#include <unique_ptr.h>
#include <FBaseSysLog.h>
#include "zlib.h"
-
namespace Tizen { namespace Base { namespace Utility
{
{
}
-
Inflator::~Inflator(void)
{
}
-
ByteBuffer*
Inflator::InflateN(const ByteBuffer& src, int byteCount)
{
return pOutBuf.release();
}
-
ByteBuffer*
Inflator::InflateN(const ByteBuffer& src)
{
return InflateN(src, src.GetRemaining());
}
-
-} } } // Tizen::Base::Utility
+}}} // Tizen::Base::Utility
\ No newline at end of file
* @brief This is the implementation file for the LinkeInfo class.
*
*/
-
-
-//Includes
#include <FBaseUtilLinkInfo.h>
-
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
{
}
-
LinkInfo::LinkInfo(const LinkInfo& value)
: __pLinkInfoImpl(null)
{
__text = value.__text;
}
-
LinkInfo::LinkInfo(LinkType linkType, const String& link)
: __linkType(linkType)
, __link(link)
{
}
-
LinkInfo::LinkInfo(LinkType linkType, const String& link, const String& text)
: __linkType(linkType)
, __link(link)
{
}
-
LinkInfo::~LinkInfo(void)
{
}
-
LinkInfo&
LinkInfo::operator =(const LinkInfo& rhs)
{
return(*this);
}
-
void
LinkInfo::SetLink(const String& link)
{
__link = link;
}
-
String
LinkInfo::GetLink(void) const
{
return __link;
}
-
void
LinkInfo::SetLinkType(LinkType linkType)
{
__linkType = linkType;
}
-
LinkType
LinkInfo::GetLinkType(void) const
{
return __linkType;
}
-
void
LinkInfo::SetText(const String& text)
{
__text = text;
}
-
String
LinkInfo::GetText(void) const
{
return __text;
}
-
-
-}}}
+}}}
\ No newline at end of file
* @file FBaseUtilMath.cpp
* @brief This is the implementation file for Math class.
*/
-
-// Includes
#include <math.h>
#include <stdlib.h>
#include <FBaseUtilMath.h>
-
namespace Tizen { namespace Base { namespace Utility
{
-
///////////////////////////////////////////////////////////////////////////////
/// Math class lifecycle
{
}
-
Math::~Math(void)
{
}
-
////////////////////////////////////////////////////////////////////////////////
/// Math class operations
return abs(x);
}
-
double
Math::Asin(double x)
{
return asin(x);
}
-
double
Math::Acos(double x)
{
return acos(x);
}
-
double
Math::Atan(double x)
{
return atan(x);
}
-
double
Math::Ceiling(double x)
{
return ceil(x);
}
-
double
Math::Cos(double x)
{
return cos(x);
}
-
double
Math::Cosh(double x)
{
return cosh(x);
}
-
double
Math::Exp(double x)
{
return exp(x);
}
-
double
Math::Floor(double x)
{
return floor(x);
}
-
double
Math::Log(double x)
{
return log(x);
}
-
double
Math::Log10(double x)
{
return log10(x);
}
-
int
Math::Max(int x, int y)
{
return (x >= y) ? x : y;
}
-
double
Math::Max(double x, double y)
{
return (x >= y) ? x : y;
}
-
int
Math::Min(int x, int y)
{
return (x <= y) ? x : y;
}
-
double
Math::Min(double x, double y)
{
return (x <= y) ? x : y;
}
-
double
Math::Pow(double x, double y)
{
return pow(x, y);
}
-
double
Math::Round(double x)
{
return round(x);
}
-
double
Math::Sin(double x)
{
return sin(x);
}
-
double
Math::Sinh(double x)
{
return sinh(x);
}
-
double
Math::Sqrt(double x)
{
return sqrt(x);
}
-
double
Math::Tan(double x)
{
return tan(x);
}
-
double
Math::Tanh(double x)
{
return tanh(x);
}
-
void
Math::Srand(unsigned int seed)
{
srand(seed);
}
-
int
Math::Rand(void)
{
return rand() % (RAND_VALUE_MAX + 1);
}
-
////////////////////////////////////////////////////////////////////////////////
/// Math class accessors
return M_E;
}
-
const double
Math::GetPi(void)
{
return M_PI;
}
-
-
-} } } // Tizen::Base::Utility
+} } } // Tizen::Base::Utility
\ No newline at end of file
* @File : FBaseUtilRegularExpression.cpp
* @brief : Implementation for RegularExpression Class
*/
-
-//Includes
-//#include "FBaseSysInternal.h"
#include <new>
#include <unique_ptr.h>
#include <FBaseUtilRegularExpression.h>
#include <FBaseSysLog.h>
#include "FBaseUtil_RegularExpressionImpl.h"
-
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
return r;
}
-
bool
RegularExpression::Match(const Tizen::Base::String& text, bool fullMatch, IList* pMatchedString) const
{
SysAssertf(__pRegularExpressionImpl != null, "Not yet constructed! Construct() should be called before use");
SysTryReturn(NID_BASE_UTIL, !text.IsEmpty(), r = false, E_INVALID_ARG, "[%s] Invalid argument is used. The length of the text is zero.", GetErrorMessage(E_INVALID_ARG));
return __pRegularExpressionImpl->Match(text, fullMatch, pMatchedString);
-
}
-
bool
RegularExpression::Consume(String& text, IList* pMatchedString) const
{
SysAssertf(__pRegularExpressionImpl != null, "Not yet constructed! Construct() should be called before use.");
SysTryReturn(NID_BASE_UTIL, !text.IsEmpty(), r = false, E_INVALID_ARG, "[%s] Invalid argument is used. The length of the text is zero.", GetErrorMessage(E_INVALID_ARG));
return __pRegularExpressionImpl->Consume(text, pMatchedString);
-
}
-
bool
RegularExpression::FindAndConsume(String& text, IList* pMatchedString) const
{
return __pRegularExpressionImpl->Replace(text, rewrite, globalReplace, startPos);
}
-
bool
RegularExpression::Extract(const String& text, const String& rewrite, String& out) const
{
return __pRegularExpressionImpl->GetPattern();
}
-
unsigned long
RegularExpression::GetOptions(void) const
{
return __pRegularExpressionImpl->SetOptions(options);
}
-
bool
RegularExpression::Equals(const Tizen::Base::Object& obj) const
{
- const RegularExpression* pOther = static_cast <const RegularExpression*>(&obj);
+ const RegularExpression* pOther = static_cast< const RegularExpression* >(&obj);
if ((__pRegularExpressionImpl != null) && (pOther->__pRegularExpressionImpl != null))
{
return __pRegularExpressionImpl->__pattern.GetHashCode();
}
-
-}}}
+}}}
\ No newline at end of file
* @File : FBaseUtil_FileUnzipperImpl.cpp
* @brief : Implementation for _FileUnzipperImpl Class
*/
-
#include <new>
#include <errno.h>
#include <unistd.h>
namespace Tizen {namespace Base {namespace Utility
{
-
#define UNZ_COMP_CASE_SENSITIVE 1
#define UNZ_COMP_NO_CASE_SENSITIVE 2
{
return unzLocateFile(pUnzipFile.get(), pFilePathForZip, UNZ_COMP_CASE_SENSITIVE) != UNZ_END_OF_LIST_OF_FILE;
}
+
return false;
}
-
_FileUnzipperImpl::_FileUnzipperImpl(void)
: __pArchiveName(null)
, __entryCount(0)
{
}
-
result
_FileUnzipperImpl::Construct(const String& filePath)
{
std::unique_ptr< ByteBuffer > pFilePathBuff(StringUtil::StringToUtf8N(filePath));
SysTryReturnResult(NID_BASE_UTIL, pFilePathBuff != null, E_INVALID_ARG, "Invalid file path.");
- const char* pFilePath = reinterpret_cast<const char*> (pFilePathBuff->GetPointer());
+ const char* pFilePath = reinterpret_cast< const char* >(pFilePathBuff->GetPointer());
SysSecureTryReturnResult(NID_BASE_UTIL, access(pFilePath, F_OK) == 0, E_FILE_NOT_FOUND, "Invalid file path [%s].", pFilePath);
std::unique_ptr< void, CloseUnzipFile > pUnzipFile(unzOpen(pFilePath));
err = unzGetCurrentFileInfo(pUnzipFile.get(), &unzfileInfo, unzFileEntryName, PATH_MAX, null, 0, null, 0);
SysTryReturnResult(NID_BASE_UTIL, err == UNZ_OK, E_IO, "Failed to get file entry info from the zip file.");
- (unzFileEntryName[strlen(unzFileEntryName) - 1] == '/')? dirCount++ : fileCount++;
+ (unzFileEntryName[strlen(unzFileEntryName) - 1] == '/') ? dirCount++ : fileCount++;
err = unzGoToNextFile(pUnzipFile.get());
SysTryReturnResult(NID_BASE_UTIL,
(err == UNZ_OK) || (err == UNZ_END_OF_LIST_OF_FILE), E_IO, "Failed to get the next entry in the zip file.");
- } while (UNZ_END_OF_LIST_OF_FILE != err);
+ }
+ while (UNZ_END_OF_LIST_OF_FILE != err);
int len = strlen(pFilePath);
std::unique_ptr< char[] > pArchiveName(new (std::nothrow) char[len + 1]);
result r = _FileUnzipperImpl::CreateDirectories(outPath);
SysSecureTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Failed to create Directory [%s]", outPath);
- if(outPath[strlen(outPath) - 1] != '/')
+ if (outPath[strlen(outPath) - 1] != '/')
{
std::unique_ptr< FILE, CloseFile > pFile(fopen(outPath, "w"));
r = __ConvertNativeErrorToResult(errno);
readLen = unzReadCurrentFile(pUnZipFile, writeBuf, sizeof(writeBuf));
r = (readLen < 0) ? E_IO : E_SUCCESS;
SysTryCatch(NID_BASE_UTIL, r == E_SUCCESS, unzCloseCurrentFile(pUnZipFile), r,
- "[%s] Failed to read from zip file.", GetErrorMessage(E_IO));
+ "[%s] Failed to read from zip file.", GetErrorMessage(E_IO));
if (readLen > 0)
{
FilePath outPath = {0};
int dirPathLength = pDirBuff->GetCapacity() - 1;
- strncat(outPath, reinterpret_cast<const char*> (pDirBuff->GetPointer()), dirPathLength);
+ strncat(outPath, reinterpret_cast< const char* >(pDirBuff->GetPointer()), dirPathLength);
std::unique_ptr< void, CloseUnzipFile > pUnzipFile(unzOpen(__pArchiveName.get()));
SysSecureTryReturnResult(NID_BASE_UTIL, pUnzipFile != null, E_IO, "Failed to open [%s].", __pArchiveName.get());
FilePath outPath = {0};
int dirPathLength = pDirBuff->GetCapacity() - 1;
- strncat(outPath, reinterpret_cast<const char*> (pDirBuff->GetPointer()), dirPathLength);
+ strncat(outPath, reinterpret_cast< const char* >(pDirBuff->GetPointer()), dirPathLength);
std::unique_ptr< ByteBuffer > pZipEntryBuff(StringUtil::StringToUtf8N(zipEntryName));
SysTryReturnResult(NID_BASE_UTIL, pZipEntryBuff != null, E_INVALID_ARG, "[%s] Invalid zip Entry Name.", GetErrorMessage(E_INVALID_ARG));
- const char* pZipEntryName = reinterpret_cast<const char*> (pZipEntryBuff->GetPointer());
+ const char* pZipEntryName = reinterpret_cast< const char* >(pZipEntryBuff->GetPointer());
std::unique_ptr< void, CloseUnzipFile > pUnzipFile(unzOpen(__pArchiveName.get()));
SysSecureTryReturnResult(NID_BASE_UTIL, pUnzipFile != null, E_IO, "Failed to open [%s].", __pArchiveName.get());
return __fileCount;
}
-
int
_FileUnzipperImpl::GetDirectoryCount(void) const
{
}
else
{
- pZipEntryInfo = static_cast <_ZipEntryInfo*>(entry.__unzFile);
+ pZipEntryInfo = static_cast< _ZipEntryInfo* >(entry.__unzFile);
}
-// pZipEntryInfo->__unzFile = __pUzFile;
pZipEntryInfo->__name = fileEntryName;
if (level == Z_BEST_SPEED)
{
std::unique_ptr< ByteBuffer > pZipEntryBuff(StringUtil::StringToUtf8N(zipEntryName));
SysTryReturnResult(NID_BASE_UTIL, pZipEntryBuff != null, E_INVALID_ARG, "Invalid file path.");
- const char* pZipEntryName = reinterpret_cast<const char*> (pZipEntryBuff->GetPointer());
+ const char* pZipEntryName = reinterpret_cast< const char* >(pZipEntryBuff->GetPointer());
std::unique_ptr< void, CloseUnzipFile > pZipFile(unzOpen(__pArchiveName.get()));
SysSecureTryReturnResult(NID_BASE_UTIL, pZipFile != null, E_IO, "Failed to open [%s].", __pArchiveName.get());
return GetCurrentFileInfo(pZipFile.get(), entry);
}
-
result
_FileUnzipperImpl::GetEntry(int index, ZipEntry& entry) const
{
return GetCurrentFileInfo(pZipFile.get(), entry);
}
-
-} } } // Tizen::Base::Utility
+}}} // Tizen::Base::Utility
\ No newline at end of file
*
* This header file contains the declarations of the _FileUnzipperImpl class.
*/
-
#ifndef _FBASE_UTIL_INTERNAL_FILEUNZIPPER_IMPL_H_
#define _FBASE_UTIL_INTERNAL_FILEUNZIPPER_IMPL_H_
namespace Tizen { namespace Base { namespace Utility
{
-
class _FileUnzipperImpl
: public Tizen::Base::Object
{
unsigned long __fileCount;
}; // _FileUnzipperImpl
-
}}} // Tizen::Base::Utility
-
-#endif // _FBASE_UTIL_INTERNAL_FILEUNZIPPER_IMPL_H_
+#endif // _FBASE_UTIL_INTERNAL_FILEUNZIPPER_IMPL_H_
\ No newline at end of file
* @File : FBaseUtil_FileZipperImpl.cpp
* @brief : Implementation for _FileZipperImpl Class
*/
-
#include <new>
#include <zip.h>
#include <errno.h>
#include "FBaseUtil_FileUnzipperImpl.h"
#include "FBaseUtil_FileZipperImpl.h"
-
using namespace Tizen::Io;
namespace Tizen { namespace Base { namespace Utility
std::unique_ptr< ByteBuffer > pFilePathBuff(StringUtil::StringToUtf8N(filePath));
SysTryReturnResult(NID_BASE_UTIL, pFilePathBuff != null, E_INVALID_ARG, "Invalid file path.");
- const char* pFilePath = reinterpret_cast<const char*> (pFilePathBuff->GetPointer());
+ const char* pFilePath = reinterpret_cast< const char* >(pFilePathBuff->GetPointer());
result r = IsFileExists(pFilePath);
SysSecureTryReturnResult(NID_BASE_UTIL, (r == E_SUCCESS) || (r == E_FILE_NOT_FOUND), r, "Invalid file path [%s].", pFilePath);
- int createOption = (r == E_FILE_NOT_FOUND)? APPEND_STATUS_CREATE : APPEND_STATUS_ADDINZIP;
+ int createOption = (r == E_FILE_NOT_FOUND) ? APPEND_STATUS_CREATE : APPEND_STATUS_ADDINZIP;
std::unique_ptr< void, ZipFileDeleter > pZfile(zipOpen(pFilePath, createOption));
SysSecureTryReturnResult(NID_BASE_UTIL, pZfile != null, E_IO, "Invalid file path [%s].", pFilePath);
std::unique_ptr< ByteBuffer > pFilePathBuff(StringUtil::StringToUtf8N(filePath));
SysTryReturnResult(NID_BASE_UTIL, pFilePathBuff != null, E_INVALID_ARG, "Invalid file path argument.");
- const char* pFilePath = reinterpret_cast<const char*> (pFilePathBuff->GetPointer());
+ const char* pFilePath = reinterpret_cast< const char* >(pFilePathBuff->GetPointer());
result r = IsFileExists(pFilePath);
SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_FILE_NOT_FOUND, "The file is not found.");
}
}
-// while (pFilePathForZip[0] == '/' || pFilePathForZip[0] == '\\')
-// {
-// pFilePathForZip++;
-// }
-
int compLevel = DEFAULT_COMPRESSION;
if (level == BEST_SPEED)
{
return AddToZip(pFilePath, pFilePathForZip, compLevel);
}
-
bool
_FileZipperImpl::GetOverwriteFlag(void) const
{
return __overwrite;
}
-
void
_FileZipperImpl::SetOverwriteFlag(bool flag)
{
// fall through
CATCH:
zipCloseFileInZip(pZfile.get());
- if(pFile != null)
+ if (pFile != null)
{
fclose(pFile);
}
return E_SUCCESS;
}
-
-
-} } } // Tizen::Base::Utility
+}}} // Tizen::Base::Utility
\ No newline at end of file
*
* This header file contains the declarations of the _FileZipperImpl class.
*/
-
#ifndef _FBASE_UTIL_INTERNAL_FILEZIPPERIMPL_H_
#define _FBASE_UTIL_INTERNAL_FILEZIPPERIMPL_H_
#include <FBaseUtilTypes.h>
#include <FBaseString.h>
-
namespace Tizen { namespace Base { namespace Utility
{
bool GetOverwriteFlag(void) const;
void SetOverwriteFlag(bool flag);
-
private:
/**
* This is the copy constructor for this class.
* @remarks This operator is hidden.
*/
_FileZipperImpl& operator =(const _FileZipperImpl& fileZipper);
-
+
result IsFileExists(const char* pFilePath);
- result AddToZip(const char* pFilePath,const char* pFilePathForZip, int level);
+ result AddToZip(const char* pFilePath, const char* pFilePathForZip, int level);
result OverwriteInZip(const char* pFilePath, const char* pFilePathForZip, int level);
std::unique_ptr< char[] > __pArchiveName;
bool __overwrite;
}; // _FileZipperImpl
-
}}} // Tizen::Base::Utility
-
-#endif // _FBASE_UTIL_INTERNAL_FILEZIPPERIMPL_H_
+#endif // _FBASE_UTIL_INTERNAL_FILEZIPPERIMPL_H_
\ No newline at end of file
* @File : FBaseUtil_ICUConverter.cpp
* @brief : Implementation for _ICUConverter Class
*/
-// Includes
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
#include <FBaseSysLog.h>
#include "FBaseUtil_IcuConverter.h"
-
namespace Tizen { namespace Base { namespace Utility
{
_ICUConverter::_ICUConverter(void)
- :__pConverter(null)
+ : __pConverter(null)
{
}
{
switch (err)
{
- case U_ZERO_ERROR:
- return E_SUCCESS;
- case U_MEMORY_ALLOCATION_ERROR:
- return E_OUT_OF_MEMORY;
+ case U_ZERO_ERROR:
+ return E_SUCCESS;
+
+ case U_MEMORY_ALLOCATION_ERROR:
+ return E_OUT_OF_MEMORY;
- case U_INDEX_OUTOFBOUNDS_ERROR:
- return E_INVALID_ARG;
+ case U_INDEX_OUTOFBOUNDS_ERROR:
+ return E_INVALID_ARG;
- case U_TRUNCATED_CHAR_FOUND:
- // fall through to U_INVALID_CHAR_FOUND
- case U_INVALID_CHAR_FOUND:
- // fall through to U_ILLEGAL_CHAR_FOUND
- case U_ILLEGAL_CHAR_FOUND:
- return E_INVALID_ENCODING_RANGE;
+ case U_TRUNCATED_CHAR_FOUND:
+ // fall through to U_INVALID_CHAR_FOUND
+ case U_INVALID_CHAR_FOUND:
+ // fall through to U_ILLEGAL_CHAR_FOUND
+ case U_ILLEGAL_CHAR_FOUND:
+ return E_INVALID_ENCODING_RANGE;
- case U_INVALID_TABLE_FORMAT:
- return E_SYSTEM;
+ case U_INVALID_TABLE_FORMAT:
+ return E_SYSTEM;
- case U_BUFFER_OVERFLOW_ERROR:
- return E_OVERFLOW;
+ case U_BUFFER_OVERFLOW_ERROR:
+ return E_OVERFLOW;
- case U_STRING_NOT_TERMINATED_WARNING:
- return E_INVALID_ARG;
+ case U_STRING_NOT_TERMINATED_WARNING:
+ return E_INVALID_ARG;
- case U_ILLEGAL_ARGUMENT_ERROR:
- return E_INVALID_ARG;
+ case U_ILLEGAL_ARGUMENT_ERROR:
+ return E_INVALID_ARG;
- case U_FILE_ACCESS_ERROR:
- case U_AMBIGUOUS_ALIAS_WARNING:
- return E_UNSUPPORTED_TYPE;
+ case U_FILE_ACCESS_ERROR:
+ case U_AMBIGUOUS_ALIAS_WARNING:
+ return E_UNSUPPORTED_TYPE;
- default:
- return E_SYSTEM;
+ default:
+ return E_SYSTEM;
}
}
+
return E_SUCCESS;
}
return pDst.release();
}
-} } } // Tizen::Base::Utility
+}}} // Tizen::Base::Utility
\ No newline at end of file
* @File : FBaseUtil_RegularExpressionImpl.cpp
* @brief : Implementation for _RegularExpressionImpl Class
*/
-
-//Includes
-//#include "FBaseSysInternal.h"
#include <stdlib.h>
#include <new>
#include <unique_ptr.h>
namespace Tizen { namespace Base { namespace Utility
{
-
static int allOptions =
(REGEX_CASELESS |
REGEX_MULTI_LINE |
struct RegExInfo
{
- void* pRe; // pcre object
- char* pPattern; // regular expression pattern
- unsigned long options; // options used while compiling
- int* pOffsets; // array to store offsets while match
- int offsetCount; // entries in offsets array
+ void* pRe; // pcre object
+ char* pPattern; // regular expression pattern
+ unsigned long options; // options used while compiling
+ int* pOffsets; // array to store offsets while match
+ int offsetCount; // entries in offsets array
// Valid in case of error
- char* pError; // Error string if compilation fails
- int errOffset; // Error offset in patter in case compilation fails
+ char* pError; // Error string if compilation fails
+ int errOffset; // Error offset in patter in case compilation fails
};
void
}
return grpCount;
-// return REGEX_MAX_GROUP_COUNT;
}
+
void
RegexAllocateOffset(RegExInfo* pRegex, int maxGroupCount)
{
}
}
-
_RegularExpressionImpl::_RegularExpressionImpl()
: __pReFull(null)
, __pRePartial(null)
return r;
}
-
result
_RegularExpressionImpl::Init(const String& pattern, const int options)
{
int errorCode = 0;
lenPattern = pTmpBuf->GetLimit() - 1;
pRegex = (RegExInfo*) calloc(1, sizeof(RegExInfo));
- if(pRegex != null)
+ if (pRegex != null)
{
pRegex->pError = emptyString;
pRegex->options = options;
pTmpBuf->SetByte(lenPattern, '\0');
- pRegex->pRe = pcre_compile2((const char*) pTmpBuf->GetPointer(), // Pattern to compile
+ pRegex->pRe = pcre_compile2((const char*) pTmpBuf->GetPointer(), // Pattern to compile
options, // Compile options
&errorCode, // Error code return by PCRE
(const char**) &pRegex->pError, // Pointer to string containing error message
free(pRegex);
return null;
}
- if(pRegex != null)
+
+ if (pRegex != null)
{
pRegex->pPattern = (char*) calloc(lenPattern, sizeof(char));
- if(pRegex->pPattern != null)
+ if (pRegex->pPattern != null)
{
strncpy(pRegex->pPattern, (const char*) pTmpBuf->GetPointer(), lenPattern);
}
int
_RegularExpressionImpl::Match(bool isFull, const String& text, int startPos, int matchOptions)
{
- result r = E_SUCCESS;
+ result r = E_SUCCESS;
std::unique_ptr< ByteBuffer > pTmpBuf(null);
bool containsNonAsciiChars = false;
Init(__pattern, __options);
}
- RegExInfo* pRegex = static_cast<RegExInfo*>((isFull) ? __pReFull : __pRePartial);
+ RegExInfo* pRegex = static_cast< RegExInfo* >((isFull) ? __pReFull : __pRePartial);
if ((pRegex == null))
{
SetLastResult(E_INVALID_STATE);
return -1;
}
+
if ((pRegex->pRe == null) || (pRegex->pOffsets == null))
{
SetLastResult(E_INVALID_ARG);
SetLastResult(E_OUT_OF_MEMORY);
return -1;
}
+
r = pTmpBuf->Construct(1);
- if(IsFailed(r) == true)
+ if (IsFailed(r) == true)
{
SetLastResult(r);
return -1;
}
+
r = pTmpBuf->SetByte('\0');
- if(IsFailed(r) == true)
+ if (IsFailed(r) == true)
{
SetLastResult(r);
return -1;
}
pTmpBuf->SetByte(pTmpBuf->GetLimit() - 1, '\0');
-
if ((pTmpBuf->GetLimit() - 1) != text.GetLength())
{
containsNonAsciiChars = true;
// Ressting offset array to invalid values
memset(pRegex->pOffsets, -1, pRegex->offsetCount * sizeof(int));
int matchCount = pcre_exec((pcre*) (pRegex->pRe), // the regular expression object
- null, // &extra,
+ null, // &extra,
(const char*) pTmpBuf->GetPointer(), // pointer to subject string
pTmpBuf->GetLimit() - 1, // length of subject string
startPos, // where to start in the subject string
SetLastResult(E_SUCCESS);
return true;
}
+
CATCH:
SetLastResult(r);
return false;
-
}
bool
{
break;
}
-
}
if (count == 0)
{
__isCompilationRequired = true;
}
+
return E_SUCCESS;
}
return __options;
}
-
result
_RegularExpressionImpl::GetLastMatchedGroups(const String& text, IList& matchedGrpStrList)
{
result r = E_SUCCESS;
- RegExInfo* pRegex = static_cast<RegExInfo*>((__isLastMatchPartial) ? __pRePartial : __pReFull);
+ RegExInfo* pRegex = static_cast< RegExInfo* >((__isLastMatchPartial) ? __pRePartial : __pReFull);
if (pRegex)
{
int grpCount = GetLastGroupCount();
goto FAILED;
}
}
+
return E_SUCCESS;
}
_RegularExpressionImpl::GetLastGroupCount(void)
{
int grpCount = 0;
- RegExInfo* pRegex = static_cast<RegExInfo*>((__isLastMatchPartial) ? __pRePartial : __pReFull);
+ RegExInfo* pRegex = static_cast< RegExInfo* >((__isLastMatchPartial) ? __pRePartial : __pReFull);
if (pRegex == null)
{
-
SetLastResult(E_INVALID_STATE);
return -1;
}
+
if (pRegex->pRe == null)
{
SetLastResult(E_INVALID_ARG);
return -1;
}
- int retValue = pcre_fullinfo((pcre*) (pRegex->pRe), // the regular expression object
- null, // points extra data, or null
+ int retValue = pcre_fullinfo((pcre*) (pRegex->pRe), // the regular expression object
+ null, // points extra data, or null
PCRE_INFO_CAPTURECOUNT, // what information is required
(void*) &grpCount // where to put the information
);
-// Handling error
+ // Handling error
if ((0 != retValue) || (grpCount < -1))
{
return -1;
return grpCount;
}
+
int
_RegularExpressionImpl::StringToUtf8Index(const Tizen::Base::String text, int index)
{
{
return 0;
}
+
result r = text.SubString(0, index, tmpStr);
if (!IsFailed(r))
{
}
}
-// SysLogExceptionxception("[%s] Regex: StringToUtf8Index failed", GetErrorMessage(r));
return newIndex;
}
+
int
_RegularExpressionImpl::Utf8ToStringIndex(char* pUtf8String, int index)
{
{
newIndex = tmpStr.GetLength();
}
- else
- {
-// SysLogExceptionxception("[%s] Regex: Utf8ToStringIndex failed", GetErrorMessage(r));
- }
pUtf8String[index] = byteAtIndex;
}
{
for (index = 0; index <= maxCount; index++)
{
- String* pTemp = static_cast<String*>(matchedGrpStrList.GetAt(index));
+ String* pTemp = static_cast< String* >(matchedGrpStrList.GetAt(index));
if (pTemp)
{
String tmp1("\\");
return r;
}
-
int
_RegularExpressionImpl::GetLastMatchStart(void)
{
- RegExInfo* pRegEx = static_cast<RegExInfo*>((__isLastMatchPartial) ? __pRePartial : __pReFull);
+ RegExInfo* pRegEx = static_cast< RegExInfo* >((__isLastMatchPartial) ? __pRePartial : __pReFull);
if (pRegEx)
{
return pRegEx->pOffsets[0];
int
_RegularExpressionImpl::GetLastMatchEnd(void)
{
- RegExInfo* pRegEx = static_cast<RegExInfo*>((__isLastMatchPartial) ? __pRePartial : __pReFull);
+ RegExInfo* pRegEx = static_cast< RegExInfo* >((__isLastMatchPartial) ? __pRePartial : __pReFull);
if (pRegEx)
{
return pRegEx->pOffsets[1];
{
String out("");
result r = E_SUCCESS;
- RegExInfo* pRegEx = static_cast<RegExInfo*>((__isLastMatchPartial) ? __pRePartial : __pReFull);
+ RegExInfo* pRegEx = static_cast< RegExInfo* >((__isLastMatchPartial) ? __pRePartial : __pReFull);
if (pRegEx && pRegEx->pOffsets[0] > -1 && pRegEx->pOffsets[1] > -1)
{
r = text.SubString(pRegEx->pOffsets[0], pRegEx->pOffsets[1] - pRegEx->pOffsets[0], out);
-
}
SetLastResult(r);
return out;
}
+
result
_RegularExpressionImpl::PcreCompileErrorToSystemError(int compileErr)
{
switch (compileErr)
{
case 23:
- //fall through
+ //fall through
case 52:
return E_SYSTEM;
case PCRE_ERROR_NOMATCH:
return E_SUCCESS;
-// case PCRE_ERROR_NULL:
case PCRE_ERROR_NOSUBSTRING:
//fall through
case PCRE_ERROR_MATCHLIMIT:
//fall through
case PCRE_ERROR_UNKNOWN_OPCODE:
//fall through
-// case PCRE_ERROR_UNKNOWN_NODE:
case PCRE_ERROR_BADUTF8:
//fall through
case PCRE_ERROR_BADUTF8_OFFSET:
//fall through
case PCRE_ERROR_BADNEWLINE:
-// case PCRE_ERROR_BADOFFSET:
-// case PCRE_ERROR_SHORTUTF8:
return E_INVALID_ARG;
case PCRE_ERROR_NOMEMORY:
return E_OUT_OF_MEMORY;
}
+
return E_SUCCESS;
}
}}}
* @brief This is the header file for the _RegularExpressionImpl class.
* This header file contains the declarations of the _RegularExpressionImpl class.
*/
-
#ifndef _FBASE_UTIL_INTERNAL_REGULAREXPRESSIONIMPL_H_
#define _FBASE_UTIL_INTERNAL_REGULAREXPRESSIONIMPL_H_
#include <FBaseColIList.h>
#include <FBaseColArrayList.h>
-
namespace Tizen { namespace Base { namespace Utility
{
int GetLastMatchStart(void);
int GetLastMatchEnd(void);
-
private:
void Cleanup(void);
// Initializes _RegularExpressionImpl object
friend class RegularExpression;
}; // _RegularExpressionImpl
-
}}} // Tizen::Base::Utility
-
-#endif // _FBASE_UTIL_INTERNAL_REGULAREXPRESSIONIMPL_H_
+#endif // _FBASE_UTIL_INTERNAL_REGULAREXPRESSIONIMPL_H_
\ No newline at end of file