X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Fdevel-api%2Fbuilder%2Fbase64-encoding.cpp;h=024c1b5e357e6ebe31ff74ea283166e68ae63eb5;hb=cd320a0d23f1e8db975021f71837e4523b5894a5;hp=279943031ab5535f4b42a28367e65d17bbe501eb;hpb=61eb93cd9df8f71406040d485fdc518755f49f84;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/devel-api/builder/base64-encoding.cpp b/dali-toolkit/devel-api/builder/base64-encoding.cpp index 2799430..024c1b5 100644 --- a/dali-toolkit/devel-api/builder/base64-encoding.cpp +++ b/dali-toolkit/devel-api/builder/base64-encoding.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,41 +16,39 @@ */ // EXTERNAL INCLUDES -#include #include +#include -#include -#include #include +#include +#include #include namespace Dali { - namespace Toolkit { - namespace { const int MAX_PROPERTY_STRING_LENGTH(64); // Cuts larger strings into blocks of this size. -bool GetStringFromProperty( const Property::Value& value, std::string& output ) +bool GetStringFromProperty(const Property::Value& value, std::string& output) { bool extracted = false; - if( value.Get( output ) ) + if(value.Get(output)) { extracted = true; } else { - Property::Array* array = value.GetArray(); - if( array ) + const Property::Array* array = value.GetArray(); + if(array) { const unsigned int arraySize = array->Size(); - for( unsigned int i = 0; i < arraySize; ++i ) + for(unsigned int i = 0; i < arraySize; ++i) { std::string element; - if( array->GetElementAt( i ).Get( element ) ) + if(array->GetElementAt(i).Get(element)) { extracted = true; output += element; @@ -68,50 +66,48 @@ bool GetStringFromProperty( const Property::Value& value, std::string& output ) return extracted; } -}//anonymous namespace +} //anonymous namespace -bool DecodeBase64PropertyData( const Property::Value& value, std::vector& outputData ) +bool DecodeBase64PropertyData(const Property::Value& value, std::vector& outputData) { - bool decoded = false; + bool decoded = false; std::string encodedString; - - if( GetStringFromProperty( value, encodedString ) ) + if(GetStringFromProperty(value, encodedString)) { std::vector outputTmpData; - outputTmpData.reserve( ceil( encodedString.size() * 0.75f ) ); - bn::decode_b64( encodedString.begin(), encodedString.end(), std::back_inserter(outputTmpData) ); + outputTmpData.reserve(ceil(encodedString.size() * 0.75f)); + bn::decode_b64(encodedString.begin(), encodedString.end(), std::back_inserter(outputTmpData)); outputData.clear(); - outputData.resize( outputTmpData.size() / sizeof(uint32_t) ); + outputData.resize(outputTmpData.size() / sizeof(uint32_t)); // Treat as a block of data - memcpy( &outputData[0], &outputTmpData[0], outputTmpData.size() ); + memcpy(&outputData[0], &outputTmpData[0], outputTmpData.size()); decoded = true; } return decoded; } -void EncodeBase64PropertyData( Property::Value& value, const std::vector& inputData ) +void EncodeBase64PropertyData(Property::Value& value, const std::vector& inputData) { std::ostringstream oss; - bn::encode_b64( reinterpret_cast(&inputData[0]), - reinterpret_cast(&inputData[0]+inputData.size()), - std::ostream_iterator(oss, "") ); - + bn::encode_b64(reinterpret_cast(&inputData[0]), + reinterpret_cast(&inputData[0] + inputData.size()), + std::ostream_iterator(oss, "")); std::string encodedString = oss.str(); - if( encodedString.length() > MAX_PROPERTY_STRING_LENGTH) + if(encodedString.length() > MAX_PROPERTY_STRING_LENGTH) { // cut string up into blocks of MAX_PROPERTY_STRING_LENGTH and store to an array auto numStrings = encodedString.length() / MAX_PROPERTY_STRING_LENGTH + ((encodedString.length() % MAX_PROPERTY_STRING_LENGTH) != 0); Property::Array array; - for(auto i=0u; i