From: Suchita Date: Tue, 2 Jul 2013 11:10:19 +0000 (+0600) Subject: Beautified source code of appfw/src/base/utility X-Git-Tag: accepted/tizen/20130912.081851^2~157 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=934e7674d0b43e84dea0bc464a5935a1b0f16cd5;p=platform%2Fframework%2Fnative%2Fappfw.git Beautified source code of appfw/src/base/utility Change-Id: Id23457f562f89f20de7009ca7c3b2ec5a71db2cf Signed-off-by: Suchita --- diff --git a/src/base/utility/FBaseUtilDeflator.cpp b/src/base/utility/FBaseUtilDeflator.cpp index 7aa5849..cffc652 100644 --- a/src/base/utility/FBaseUtilDeflator.cpp +++ b/src/base/utility/FBaseUtilDeflator.cpp @@ -18,8 +18,6 @@ * @file FBaseUtilDeflator.cpp * @brief This is the implementation file for Deflator class. */ - -// Includes #include #include #include @@ -28,7 +26,6 @@ #include #include "zlib.h" - namespace Tizen { namespace Base { namespace Utility { @@ -50,12 +47,10 @@ Deflator::Deflator(void) { } - Deflator::~Deflator(void) { } - /////////////////////////////////////////////////////////////////////////////// /// Deflator class Operations @@ -85,7 +80,7 @@ Deflator::DeflateN(const ByteBuffer& src, int byteCount, CompressionLevel level) 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; @@ -142,7 +137,7 @@ Deflator::DeflateN(const ByteBuffer& src, int byteCount, CompressionLevel level) 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; @@ -160,12 +155,10 @@ Deflator::DeflateN(const ByteBuffer& src, int byteCount, CompressionLevel level) 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 diff --git a/src/base/utility/FBaseUtilFileUnzipper.cpp b/src/base/utility/FBaseUtilFileUnzipper.cpp index 8cc10a1..f5fb6ac 100644 --- a/src/base/utility/FBaseUtilFileUnzipper.cpp +++ b/src/base/utility/FBaseUtilFileUnzipper.cpp @@ -18,7 +18,6 @@ * @File : FBaseUtilFileUnzipper.cpp * @brief : Implementation for FileUnzipper Class */ - #include #include @@ -28,30 +27,25 @@ #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) { @@ -66,11 +60,10 @@ 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 { @@ -80,7 +73,6 @@ FileUnzipper::UnzipTo(const String& dirPath) const return __pFileUnzipperImpl->UnzipTo(dirPath); } - result FileUnzipper::UnzipTo(const String& dirPath, const String& zipEntryName) const { @@ -91,7 +83,6 @@ FileUnzipper::UnzipTo(const String& dirPath, const String& zipEntryName) const return __pFileUnzipperImpl->UnzipTo(dirPath, zipEntryName); } - int FileUnzipper::GetEntryCount(void) const { @@ -99,7 +90,6 @@ FileUnzipper::GetEntryCount(void) const return __pFileUnzipperImpl->GetEntryCount(); } - int FileUnzipper::GetFileCount(void) const { @@ -108,7 +98,6 @@ FileUnzipper::GetFileCount(void) const return __pFileUnzipperImpl->GetFileCount(); } - int FileUnzipper::GetDirectoryCount(void) const { @@ -117,7 +106,6 @@ FileUnzipper::GetDirectoryCount(void) const return __pFileUnzipperImpl->GetDirectoryCount(); } - result FileUnzipper::GetEntry(const String& zipEntryName, ZipEntry& entry) const { @@ -127,7 +115,6 @@ FileUnzipper::GetEntry(const String& zipEntryName, ZipEntry& entry) const return __pFileUnzipperImpl->GetEntry(zipEntryName, entry); } - result FileUnzipper::GetEntry(int index, ZipEntry& entry) const { @@ -137,6 +124,4 @@ FileUnzipper::GetEntry(int index, ZipEntry& entry) const return __pFileUnzipperImpl->GetEntry(index, entry); } - - -} } } // Tizen::Base::Utility +}}} // Tizen::Base::Utility \ No newline at end of file diff --git a/src/base/utility/FBaseUtilFileZipper.cpp b/src/base/utility/FBaseUtilFileZipper.cpp index 815d501..dd344ec 100644 --- a/src/base/utility/FBaseUtilFileZipper.cpp +++ b/src/base/utility/FBaseUtilFileZipper.cpp @@ -18,7 +18,6 @@ * @File : FBaseUtilFileZipper.cpp * @brief : Implementation for FileZipper Class */ - #include #include @@ -27,7 +26,6 @@ #include #include "FBaseUtil_FileZipperImpl.h" - using namespace Tizen::Io; namespace Tizen { namespace Base { namespace Utility @@ -96,5 +94,4 @@ FileZipper::SetOverwriteFlag(bool flag) __pFileZipperImpl->SetOverwriteFlag(flag); } } - -} } } // Tizen::Base::Utility +}}} // Tizen::Base::Utility \ No newline at end of file diff --git a/src/base/utility/FBaseUtilInflator.cpp b/src/base/utility/FBaseUtilInflator.cpp index 5716823..0b81d37 100644 --- a/src/base/utility/FBaseUtilInflator.cpp +++ b/src/base/utility/FBaseUtilInflator.cpp @@ -18,8 +18,6 @@ * @file FBaseUtilInflator.cpp * @brief This is the implementation file for Inflator class. */ - -// Includes #include #include #include @@ -28,7 +26,6 @@ #include #include "zlib.h" - namespace Tizen { namespace Base { namespace Utility { @@ -50,12 +47,10 @@ Inflator::Inflator(void) { } - Inflator::~Inflator(void) { } - ByteBuffer* Inflator::InflateN(const ByteBuffer& src, int byteCount) { @@ -162,11 +157,9 @@ 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 diff --git a/src/base/utility/FBaseUtilLinkInfo.cpp b/src/base/utility/FBaseUtilLinkInfo.cpp index f502fd2..e7b840d 100644 --- a/src/base/utility/FBaseUtilLinkInfo.cpp +++ b/src/base/utility/FBaseUtilLinkInfo.cpp @@ -19,12 +19,8 @@ * @brief This is the implementation file for the LinkeInfo class. * */ - - -//Includes #include - using namespace Tizen::Base; using namespace Tizen::Base::Collection; @@ -37,7 +33,6 @@ LinkInfo::LinkInfo(void) { } - LinkInfo::LinkInfo(const LinkInfo& value) : __pLinkInfoImpl(null) { @@ -46,7 +41,6 @@ LinkInfo::LinkInfo(const LinkInfo& value) __text = value.__text; } - LinkInfo::LinkInfo(LinkType linkType, const String& link) : __linkType(linkType) , __link(link) @@ -55,7 +49,6 @@ LinkInfo::LinkInfo(LinkType linkType, const String& link) { } - LinkInfo::LinkInfo(LinkType linkType, const String& link, const String& text) : __linkType(linkType) , __link(link) @@ -64,12 +57,10 @@ LinkInfo::LinkInfo(LinkType linkType, const String& link, const String& text) { } - LinkInfo::~LinkInfo(void) { } - LinkInfo& LinkInfo::operator =(const LinkInfo& rhs) { @@ -82,47 +73,39 @@ 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 diff --git a/src/base/utility/FBaseUtilMath.cpp b/src/base/utility/FBaseUtilMath.cpp index 4da5508..b794893 100644 --- a/src/base/utility/FBaseUtilMath.cpp +++ b/src/base/utility/FBaseUtilMath.cpp @@ -18,17 +18,13 @@ * @file FBaseUtilMath.cpp * @brief This is the implementation file for Math class. */ - -// Includes #include #include #include - namespace Tizen { namespace Base { namespace Utility { - /////////////////////////////////////////////////////////////////////////////// /// Math class lifecycle @@ -36,12 +32,10 @@ Math::Math(void) { } - Math::~Math(void) { } - //////////////////////////////////////////////////////////////////////////////// /// Math class operations @@ -51,49 +45,42 @@ Math::Abs(int x) 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) { @@ -114,35 +101,30 @@ 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) { @@ -161,14 +143,12 @@ 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) { @@ -187,70 +167,60 @@ 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 @@ -260,12 +230,9 @@ Math::GetE(void) return M_E; } - const double Math::GetPi(void) { return M_PI; } - - -} } } // Tizen::Base::Utility +} } } // Tizen::Base::Utility \ No newline at end of file diff --git a/src/base/utility/FBaseUtilRegularExpression.cpp b/src/base/utility/FBaseUtilRegularExpression.cpp index def556f..efa7d33 100644 --- a/src/base/utility/FBaseUtilRegularExpression.cpp +++ b/src/base/utility/FBaseUtilRegularExpression.cpp @@ -18,16 +18,12 @@ * @File : FBaseUtilRegularExpression.cpp * @brief : Implementation for RegularExpression Class */ - -//Includes -//#include "FBaseSysInternal.h" #include #include #include #include #include "FBaseUtil_RegularExpressionImpl.h" - using namespace Tizen::Base; using namespace Tizen::Base::Collection; @@ -66,7 +62,6 @@ RegularExpression::Construct(const String& pattern, unsigned long options) return r; } - bool RegularExpression::Match(const Tizen::Base::String& text, bool fullMatch, IList* pMatchedString) const { @@ -74,10 +69,8 @@ RegularExpression::Match(const Tizen::Base::String& text, bool fullMatch, IList* 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 { @@ -85,10 +78,8 @@ 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 { @@ -108,7 +99,6 @@ RegularExpression::Replace(String& text, const String& rewrite, bool globalRepla return __pRegularExpressionImpl->Replace(text, rewrite, globalReplace, startPos); } - bool RegularExpression::Extract(const String& text, const String& rewrite, String& out) const { @@ -125,7 +115,6 @@ RegularExpression::GetPattern() const return __pRegularExpressionImpl->GetPattern(); } - unsigned long RegularExpression::GetOptions(void) const { @@ -140,11 +129,10 @@ RegularExpression::SetOptions(unsigned long options) return __pRegularExpressionImpl->SetOptions(options); } - bool RegularExpression::Equals(const Tizen::Base::Object& obj) const { - const RegularExpression* pOther = static_cast (&obj); + const RegularExpression* pOther = static_cast< const RegularExpression* >(&obj); if ((__pRegularExpressionImpl != null) && (pOther->__pRegularExpressionImpl != null)) { @@ -178,5 +166,4 @@ RegularExpression::GetHashCode(void) const return __pRegularExpressionImpl->__pattern.GetHashCode(); } - -}}} +}}} \ No newline at end of file diff --git a/src/base/utility/FBaseUtil_FileUnzipperImpl.cpp b/src/base/utility/FBaseUtil_FileUnzipperImpl.cpp index 89e49ef..d039610 100644 --- a/src/base/utility/FBaseUtil_FileUnzipperImpl.cpp +++ b/src/base/utility/FBaseUtil_FileUnzipperImpl.cpp @@ -18,7 +18,6 @@ * @File : FBaseUtil_FileUnzipperImpl.cpp * @brief : Implementation for _FileUnzipperImpl Class */ - #include #include #include @@ -39,7 +38,6 @@ using namespace Tizen::Io; namespace Tizen {namespace Base {namespace Utility { - #define UNZ_COMP_CASE_SENSITIVE 1 #define UNZ_COMP_NO_CASE_SENSITIVE 2 @@ -102,10 +100,10 @@ _FileUnzipperImpl::IsFileExistsInZip(const char pArchiveName[], const char* pFil { return unzLocateFile(pUnzipFile.get(), pFilePathForZip, UNZ_COMP_CASE_SENSITIVE) != UNZ_END_OF_LIST_OF_FILE; } + return false; } - _FileUnzipperImpl::_FileUnzipperImpl(void) : __pArchiveName(null) , __entryCount(0) @@ -118,7 +116,6 @@ _FileUnzipperImpl::~_FileUnzipperImpl(void) { } - result _FileUnzipperImpl::Construct(const String& filePath) { @@ -128,7 +125,7 @@ _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 (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)); @@ -152,13 +149,14 @@ _FileUnzipperImpl::Construct(const String& filePath) 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]); @@ -186,7 +184,7 @@ _FileUnzipperImpl::UnzipCurrentFileTo(void* pUnZipFile, FilePath outPath, int us 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); @@ -203,7 +201,7 @@ _FileUnzipperImpl::UnzipCurrentFileTo(void* pUnZipFile, FilePath outPath, int us 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) { @@ -242,7 +240,7 @@ _FileUnzipperImpl::UnzipTo(const String& dirPath) const FilePath outPath = {0}; int dirPathLength = pDirBuff->GetCapacity() - 1; - strncat(outPath, reinterpret_cast (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()); @@ -284,12 +282,12 @@ _FileUnzipperImpl::UnzipTo(const String& dirPath, const String& zipEntryName) co FilePath outPath = {0}; int dirPathLength = pDirBuff->GetCapacity() - 1; - strncat(outPath, reinterpret_cast (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 (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()); @@ -314,7 +312,6 @@ _FileUnzipperImpl::GetFileCount(void) const return __fileCount; } - int _FileUnzipperImpl::GetDirectoryCount(void) const { @@ -357,10 +354,9 @@ _FileUnzipperImpl::GetCurrentFileInfo(void* pUnZipFile, ZipEntry& entry) 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) { @@ -396,7 +392,7 @@ _FileUnzipperImpl::GetEntry(const String& zipEntryName, ZipEntry& entry) const 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 (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()); @@ -407,7 +403,6 @@ _FileUnzipperImpl::GetEntry(const String& zipEntryName, ZipEntry& entry) const return GetCurrentFileInfo(pZipFile.get(), entry); } - result _FileUnzipperImpl::GetEntry(int index, ZipEntry& entry) const { @@ -428,5 +423,4 @@ _FileUnzipperImpl::GetEntry(int index, ZipEntry& entry) const return GetCurrentFileInfo(pZipFile.get(), entry); } - -} } } // Tizen::Base::Utility +}}} // Tizen::Base::Utility \ No newline at end of file diff --git a/src/base/utility/FBaseUtil_FileUnzipperImpl.h b/src/base/utility/FBaseUtil_FileUnzipperImpl.h index 1b5659f..c8075ef 100644 --- a/src/base/utility/FBaseUtil_FileUnzipperImpl.h +++ b/src/base/utility/FBaseUtil_FileUnzipperImpl.h @@ -20,7 +20,6 @@ * * This header file contains the declarations of the _FileUnzipperImpl class. */ - #ifndef _FBASE_UTIL_INTERNAL_FILEUNZIPPER_IMPL_H_ #define _FBASE_UTIL_INTERNAL_FILEUNZIPPER_IMPL_H_ @@ -35,7 +34,6 @@ typedef char FilePath[PATH_MAX + 1]; namespace Tizen { namespace Base { namespace Utility { - class _FileUnzipperImpl : public Tizen::Base::Object { @@ -67,7 +65,5 @@ private: 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 diff --git a/src/base/utility/FBaseUtil_FileZipperImpl.cpp b/src/base/utility/FBaseUtil_FileZipperImpl.cpp index 9da97e5..4a9c794 100644 --- a/src/base/utility/FBaseUtil_FileZipperImpl.cpp +++ b/src/base/utility/FBaseUtil_FileZipperImpl.cpp @@ -18,7 +18,6 @@ * @File : FBaseUtil_FileZipperImpl.cpp * @brief : Implementation for _FileZipperImpl Class */ - #include #include #include @@ -32,7 +31,6 @@ #include "FBaseUtil_FileUnzipperImpl.h" #include "FBaseUtil_FileZipperImpl.h" - using namespace Tizen::Io; namespace Tizen { namespace Base { namespace Utility @@ -73,12 +71,12 @@ _FileZipperImpl::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 (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); @@ -103,7 +101,7 @@ _FileZipperImpl::AddToZip(const String& filePath, bool excludePath, CompressionL 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 (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."); @@ -123,11 +121,6 @@ _FileZipperImpl::AddToZip(const String& filePath, bool excludePath, CompressionL } } -// while (pFilePathForZip[0] == '/' || pFilePathForZip[0] == '\\') -// { -// pFilePathForZip++; -// } - int compLevel = DEFAULT_COMPRESSION; if (level == BEST_SPEED) { @@ -147,14 +140,12 @@ _FileZipperImpl::AddToZip(const String& filePath, bool excludePath, CompressionL return AddToZip(pFilePath, pFilePathForZip, compLevel); } - bool _FileZipperImpl::GetOverwriteFlag(void) const { return __overwrite; } - void _FileZipperImpl::SetOverwriteFlag(bool flag) { @@ -196,7 +187,7 @@ _FileZipperImpl::AddToZip(const char* pFilePath, const char* pFilePathForZip, in // fall through CATCH: zipCloseFileInZip(pZfile.get()); - if(pFile != null) + if (pFile != null) { fclose(pFile); } @@ -222,6 +213,4 @@ _FileZipperImpl::IsFileExists(const char* pFilePath) return E_SUCCESS; } - - -} } } // Tizen::Base::Utility +}}} // Tizen::Base::Utility \ No newline at end of file diff --git a/src/base/utility/FBaseUtil_FileZipperImpl.h b/src/base/utility/FBaseUtil_FileZipperImpl.h index 4c9e41f..e0d3ca7 100644 --- a/src/base/utility/FBaseUtil_FileZipperImpl.h +++ b/src/base/utility/FBaseUtil_FileZipperImpl.h @@ -20,7 +20,6 @@ * * This header file contains the declarations of the _FileZipperImpl class. */ - #ifndef _FBASE_UTIL_INTERNAL_FILEZIPPERIMPL_H_ #define _FBASE_UTIL_INTERNAL_FILEZIPPERIMPL_H_ @@ -29,7 +28,6 @@ #include #include - namespace Tizen { namespace Base { namespace Utility { @@ -46,7 +44,6 @@ public: bool GetOverwriteFlag(void) const; void SetOverwriteFlag(bool flag); - private: /** * This is the copy constructor for this class. @@ -61,16 +58,14 @@ private: * @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 diff --git a/src/base/utility/FBaseUtil_IcuConverter.cpp b/src/base/utility/FBaseUtil_IcuConverter.cpp index b974646..d1f9bb7 100644 --- a/src/base/utility/FBaseUtil_IcuConverter.cpp +++ b/src/base/utility/FBaseUtil_IcuConverter.cpp @@ -18,7 +18,6 @@ * @File : FBaseUtil_ICUConverter.cpp * @brief : Implementation for _ICUConverter Class */ -// Includes #include #include #include @@ -32,11 +31,10 @@ #include #include "FBaseUtil_IcuConverter.h" - namespace Tizen { namespace Base { namespace Utility { _ICUConverter::_ICUConverter(void) - :__pConverter(null) + : __pConverter(null) { } @@ -163,41 +161,43 @@ _ICUConverter::GetResultFromIcuErrorCode(UErrorCode& err) { 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; } @@ -280,4 +280,4 @@ Utf8ToWcharN(const char* pValue) return pDst.release(); } -} } } // Tizen::Base::Utility +}}} // Tizen::Base::Utility \ No newline at end of file diff --git a/src/base/utility/FBaseUtil_RegularExpressionImpl.cpp b/src/base/utility/FBaseUtil_RegularExpressionImpl.cpp index 619c243..8e050eb 100644 --- a/src/base/utility/FBaseUtil_RegularExpressionImpl.cpp +++ b/src/base/utility/FBaseUtil_RegularExpressionImpl.cpp @@ -18,9 +18,6 @@ * @File : FBaseUtil_RegularExpressionImpl.cpp * @brief : Implementation for _RegularExpressionImpl Class */ - -//Includes -//#include "FBaseSysInternal.h" #include #include #include @@ -37,7 +34,6 @@ using namespace Tizen::Base::Collection; namespace Tizen { namespace Base { namespace Utility { - static int allOptions = (REGEX_CASELESS | REGEX_MULTI_LINE | @@ -52,15 +48,15 @@ static char emptyString[1] = {'\0'}; 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 @@ -110,8 +106,8 @@ RegexGetGroupCountInPattern(const char* pattern, int len) } return grpCount; -// return REGEX_MAX_GROUP_COUNT; } + void RegexAllocateOffset(RegExInfo* pRegex, int maxGroupCount) { @@ -132,7 +128,6 @@ RegexAllocateOffset(RegExInfo* pRegex, int maxGroupCount) } } - _RegularExpressionImpl::_RegularExpressionImpl() : __pReFull(null) , __pRePartial(null) @@ -176,7 +171,6 @@ _RegularExpressionImpl::Construct(const String& pattern, unsigned long options) return r; } - result _RegularExpressionImpl::Init(const String& pattern, const int options) { @@ -221,12 +215,12 @@ _RegularExpressionImpl::Compile(const String& pattern, int options, bool forFull 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 @@ -242,10 +236,11 @@ _RegularExpressionImpl::Compile(const String& pattern, int options, bool forFull 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); } @@ -290,7 +285,7 @@ _RegularExpressionImpl::Match(const Tizen::Base::String& text, bool fullMatch, I 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; @@ -304,12 +299,13 @@ _RegularExpressionImpl::Match(bool isFull, const String& text, int startPos, int Init(__pattern, __options); } - RegExInfo* pRegex = static_cast((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); @@ -329,14 +325,16 @@ _RegularExpressionImpl::Match(bool isFull, const String& text, int startPos, int 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; @@ -352,7 +350,6 @@ _RegularExpressionImpl::Match(bool isFull, const String& text, int startPos, int } pTmpBuf->SetByte(pTmpBuf->GetLimit() - 1, '\0'); - if ((pTmpBuf->GetLimit() - 1) != text.GetLength()) { containsNonAsciiChars = true; @@ -363,7 +360,7 @@ _RegularExpressionImpl::Match(bool isFull, const String& text, int startPos, int // 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 @@ -432,10 +429,10 @@ _RegularExpressionImpl::Consume(Tizen::Base::String& text, Tizen::Base::Collecti SetLastResult(E_SUCCESS); return true; } + CATCH: SetLastResult(r); return false; - } bool @@ -561,7 +558,6 @@ _RegularExpressionImpl::Replace(Tizen::Base::String& text, const Tizen::Base::St { break; } - } if (count == 0) @@ -638,6 +634,7 @@ _RegularExpressionImpl::SetOptions(unsigned long options) { __isCompilationRequired = true; } + return E_SUCCESS; } @@ -647,12 +644,11 @@ _RegularExpressionImpl::GetOptions(void) const return __options; } - result _RegularExpressionImpl::GetLastMatchedGroups(const String& text, IList& matchedGrpStrList) { result r = E_SUCCESS; - RegExInfo* pRegex = static_cast((__isLastMatchPartial) ? __pRePartial : __pReFull); + RegExInfo* pRegex = static_cast< RegExInfo* >((__isLastMatchPartial) ? __pRePartial : __pReFull); if (pRegex) { int grpCount = GetLastGroupCount(); @@ -682,6 +678,7 @@ _RegularExpressionImpl::GetLastMatchedGroups(const String& text, IList& matchedG goto FAILED; } } + return E_SUCCESS; } @@ -694,26 +691,26 @@ int _RegularExpressionImpl::GetLastGroupCount(void) { int grpCount = 0; - RegExInfo* pRegex = static_cast((__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; @@ -721,6 +718,7 @@ _RegularExpressionImpl::GetLastGroupCount(void) return grpCount; } + int _RegularExpressionImpl::StringToUtf8Index(const Tizen::Base::String text, int index) { @@ -731,6 +729,7 @@ _RegularExpressionImpl::StringToUtf8Index(const Tizen::Base::String text, int in { return 0; } + result r = text.SubString(0, index, tmpStr); if (!IsFailed(r)) { @@ -741,9 +740,9 @@ _RegularExpressionImpl::StringToUtf8Index(const Tizen::Base::String text, int in } } -// SysLogExceptionxception("[%s] Regex: StringToUtf8Index failed", GetErrorMessage(r)); return newIndex; } + int _RegularExpressionImpl::Utf8ToStringIndex(char* pUtf8String, int index) { @@ -764,10 +763,6 @@ _RegularExpressionImpl::Utf8ToStringIndex(char* pUtf8String, int index) { newIndex = tmpStr.GetLength(); } - else - { -// SysLogExceptionxception("[%s] Regex: Utf8ToStringIndex failed", GetErrorMessage(r)); - } pUtf8String[index] = byteAtIndex; } @@ -866,7 +861,7 @@ _RegularExpressionImpl::Rewrite(const String& rewrite, const String& text, Strin { for (index = 0; index <= maxCount; index++) { - String* pTemp = static_cast(matchedGrpStrList.GetAt(index)); + String* pTemp = static_cast< String* >(matchedGrpStrList.GetAt(index)); if (pTemp) { String tmp1("\\"); @@ -894,11 +889,10 @@ FAILED: return r; } - int _RegularExpressionImpl::GetLastMatchStart(void) { - RegExInfo* pRegEx = static_cast((__isLastMatchPartial) ? __pRePartial : __pReFull); + RegExInfo* pRegEx = static_cast< RegExInfo* >((__isLastMatchPartial) ? __pRePartial : __pReFull); if (pRegEx) { return pRegEx->pOffsets[0]; @@ -910,7 +904,7 @@ _RegularExpressionImpl::GetLastMatchStart(void) int _RegularExpressionImpl::GetLastMatchEnd(void) { - RegExInfo* pRegEx = static_cast((__isLastMatchPartial) ? __pRePartial : __pReFull); + RegExInfo* pRegEx = static_cast< RegExInfo* >((__isLastMatchPartial) ? __pRePartial : __pReFull); if (pRegEx) { return pRegEx->pOffsets[1]; @@ -924,23 +918,23 @@ _RegularExpressionImpl::GetLastMatchedString(const String& text) { String out(""); result r = E_SUCCESS; - RegExInfo* pRegEx = static_cast((__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; @@ -960,7 +954,6 @@ _RegularExpressionImpl::PcreExecErrorToSystemError(int err) case PCRE_ERROR_NOMATCH: return E_SUCCESS; -// case PCRE_ERROR_NULL: case PCRE_ERROR_NOSUBSTRING: //fall through case PCRE_ERROR_MATCHLIMIT: @@ -998,19 +991,17 @@ _RegularExpressionImpl::PcreExecErrorToSystemError(int err) //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; } }}} diff --git a/src/base/utility/FBaseUtil_RegularExpressionImpl.h b/src/base/utility/FBaseUtil_RegularExpressionImpl.h index 14b5581..cf5124f 100644 --- a/src/base/utility/FBaseUtil_RegularExpressionImpl.h +++ b/src/base/utility/FBaseUtil_RegularExpressionImpl.h @@ -19,7 +19,6 @@ * @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_ @@ -30,7 +29,6 @@ #include #include - namespace Tizen { namespace Base { namespace Utility { @@ -53,7 +51,6 @@ public: int GetLastMatchStart(void); int GetLastMatchEnd(void); - private: void Cleanup(void); // Initializes _RegularExpressionImpl object @@ -91,7 +88,5 @@ private: 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