X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fbuilder%2Fbuilder-get-is.inl.h;h=0a7f6d5cb808c7b6b01731c4e620069020e86b36;hp=63cd31e5ac48256171803c563dd7948cd9a4dddf;hb=cc7137614f4136f571ccecc22ad1b72c01f16156;hpb=bc5e9a0b52e07309fd557deb212333d1798109f3 diff --git a/dali-toolkit/internal/builder/builder-get-is.inl.h b/dali-toolkit/internal/builder/builder-get-is.inl.h index 63cd31e..0a7f6d5 100644 --- a/dali-toolkit/internal/builder/builder-get-is.inl.h +++ b/dali-toolkit/internal/builder/builder-get-is.inl.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TOOLKIT_INTERNAL_BUILDER_GET_IS_INL__ -#define __DALI_TOOLKIT_INTERNAL_BUILDER_GET_IS_INL__ +#ifndef DALI_TOOLKIT_INTERNAL_BUILDER_GET_IS_INL +#define DALI_TOOLKIT_INTERNAL_BUILDER_GET_IS_INL /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -23,12 +23,12 @@ inline OptionalChild IsChild(const TreeNode* node, const std::string& childName) { - if( node ) + if(node) { const TreeNode* c = node->GetChild(childName); - if( NULL != c ) + if(NULL != c) { - return OptionalChild( *c ); + return OptionalChild(*c); } else { @@ -43,12 +43,12 @@ inline OptionalChild IsChild(const TreeNode* node, const std::string& childName) inline OptionalChild IsChildIgnoreCase(const TreeNode* node, const std::string& childName) { - if( node ) + if(node) { const TreeNode* c = node->GetChildIgnoreCase(childName); - if( NULL != c ) + if(NULL != c) { - return OptionalChild( *c ); + return OptionalChild(*c); } else { @@ -73,7 +73,7 @@ inline OptionalChild IsChildIgnoreCase(const TreeNode& node, const std::string& inline OptionalString IsString(const OptionalChild& node) { - if( node && (*node).GetType() == TreeNode::STRING ) + if(node && (*node).GetType() == TreeNode::STRING) { return OptionalString((*node).GetString()); } @@ -87,36 +87,36 @@ inline OptionalFloat IsFloat(const OptionalChild& node) { OptionalFloat ret; - if( node ) + if(node) { - if( (*node).GetType() == TreeNode::FLOAT ) + if((*node).GetType() == TreeNode::FLOAT) { ret = (*node).GetFloat(); } - else if( (*node).GetType() == TreeNode::INTEGER ) + else if((*node).GetType() == TreeNode::INTEGER) { // JSON has number not float/int but JsonParser discriminates. // Here we don't care so we allow coercion - ret = static_cast( (*node).GetInteger() ); + ret = static_cast((*node).GetInteger()); } } return ret; } -inline OptionalInteger IsInteger(const OptionalChild &node) +inline OptionalInteger IsInteger(const OptionalChild& node) { OptionalInteger ret; - if( node ) + if(node) { - if( (*node).GetType() == TreeNode::INTEGER ) + if((*node).GetType() == TreeNode::INTEGER) { ret = (*node).GetInteger(); } - else if( (*node).GetType() == TreeNode::FLOAT ) + else if((*node).GetType() == TreeNode::FLOAT) { - ret = static_cast( (*node).GetFloat() ); + ret = static_cast((*node).GetFloat()); } } @@ -125,7 +125,7 @@ inline OptionalInteger IsInteger(const OptionalChild &node) inline OptionalBoolean IsBoolean(const OptionalChild& node) { - if( node && (*node).GetType() == TreeNode::BOOLEAN ) + if(node && (*node).GetType() == TreeNode::BOOLEAN) { return OptionalBoolean(1 == (*node).GetInteger()); } @@ -135,18 +135,17 @@ inline OptionalBoolean IsBoolean(const OptionalChild& node) } } - // copy N Numbers -template +template inline bool CopyNumbers(TreeNode::ConstIterator iter, int N, T& vector) { for(int i = 0; i < N; ++i) { - if( (*iter).second.GetType() == TreeNode::FLOAT) + if((*iter).second.GetType() == TreeNode::FLOAT) { vector[i] = (*iter).second.GetFloat(); } - else if( (*iter).second.GetType() == TreeNode::INTEGER ) + else if((*iter).second.GetType() == TreeNode::INTEGER) { vector[i] = static_cast((*iter).second.GetInteger()); } @@ -164,10 +163,10 @@ inline OptionalVector4 IsVector4(const OptionalChild& node) { OptionalVector4 ret; - if( node && (TreeNode::ARRAY == (*node).GetType()) && (*node).Size() >= 4 ) + if(node && (TreeNode::ARRAY == (*node).GetType()) && (*node).Size() >= 4) { Dali::Vector4 v; - if( CopyNumbers((*node).CBegin(), 4, v) ) + if(CopyNumbers((*node).CBegin(), 4, v)) { ret = OptionalVector4(v); } @@ -180,10 +179,10 @@ inline OptionalVector3 IsVector3(const OptionalChild& node) { OptionalVector3 ret; - if( node && (TreeNode::ARRAY == (*node).GetType()) && (*node).Size() >= 3 ) + if(node && (TreeNode::ARRAY == (*node).GetType()) && (*node).Size() >= 3) { Dali::Vector3 v; - if( CopyNumbers((*node).CBegin(), 3, v) ) + if(CopyNumbers((*node).CBegin(), 3, v)) { ret = OptionalVector3(v); } @@ -196,10 +195,10 @@ inline OptionalVector2 IsVector2(const OptionalChild& node) { OptionalVector2 ret; - if( node && (TreeNode::ARRAY == (*node).GetType()) && (*node).Size() >= 2 ) + if(node && (TreeNode::ARRAY == (*node).GetType()) && (*node).Size() >= 2) { Dali::Vector2 v; - if( CopyNumbers((*node).CBegin(), 2, v) ) + if(CopyNumbers((*node).CBegin(), 2, v)) { ret = OptionalVector2(v); } @@ -208,14 +207,14 @@ inline OptionalVector2 IsVector2(const OptionalChild& node) return ret; } -inline OptionalMatrix IsMatrix(const OptionalChild &node) +inline OptionalMatrix IsMatrix(const OptionalChild& node) { OptionalMatrix ret; - if( node && (TreeNode::ARRAY == (*node).GetType()) && (*node).Size() >= 16 ) + if(node && (TreeNode::ARRAY == (*node).GetType()) && (*node).Size() >= 16) { float v[16]; - if( CopyNumbers((*node).CBegin(), 16, v) ) + if(CopyNumbers((*node).CBegin(), 16, v)) { ret = OptionalMatrix(Dali::Matrix(v)); } @@ -228,14 +227,12 @@ inline OptionalMatrix3 IsMatrix3(const OptionalChild& node) { OptionalMatrix3 ret; - if( node && (TreeNode::ARRAY == (*node).GetType()) && (*node).Size() >= 9 ) + if(node && (TreeNode::ARRAY == (*node).GetType()) && (*node).Size() >= 9) { float v[9]; - if( CopyNumbers((*node).CBegin(), 9, v) ) + if(CopyNumbers((*node).CBegin(), 9, v)) { - ret = OptionalMatrix3(Dali::Matrix3(v[0], v[1], v[2], - v[3], v[4], v[5], - v[6], v[7], v[8] )); + ret = OptionalMatrix3(Dali::Matrix3(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8])); } } @@ -250,8 +247,8 @@ inline OptionalRect IsRect(const OptionalChild& node) if((*node).Size() >= 4) { TreeNode::ConstIterator iter((*node).CBegin()); - int v[4]; - if( CopyNumbers((*node).CBegin(), 4, v) ) + int v[4]; + if(CopyNumbers((*node).CBegin(), 4, v)) { ret = OptionalRect(Dali::Rect(v[0], v[1], v[2], v[3])); } @@ -268,8 +265,8 @@ inline OptionalExtents IsExtents(const OptionalChild& node) if((*node).Size() >= 4) { TreeNode::ConstIterator iter((*node).CBegin()); - int v[4]; - if( CopyNumbers((*node).CBegin(), 4, v) ) + int v[4]; + if(CopyNumbers((*node).CBegin(), 4, v)) { extents = OptionalExtents(Dali::Extents(v[0], v[1], v[2], v[3])); } @@ -281,164 +278,162 @@ inline OptionalExtents IsExtents(const OptionalChild& node) // // // -inline OptionalString IsString( const TreeNode& parent, const std::string& childName) +inline OptionalString IsString(const TreeNode& parent, const std::string& childName) { - return IsString( IsChild(&parent, childName) ); + return IsString(IsChild(&parent, childName)); } -inline OptionalFloat IsFloat( const TreeNode& parent, const std::string& childName) +inline OptionalFloat IsFloat(const TreeNode& parent, const std::string& childName) { - return IsFloat( IsChild(&parent, childName) ); + return IsFloat(IsChild(&parent, childName)); } -inline OptionalInteger IsInteger( const TreeNode& parent, const std::string& childName) +inline OptionalInteger IsInteger(const TreeNode& parent, const std::string& childName) { - return IsInteger( IsChild(&parent, childName) ); + return IsInteger(IsChild(&parent, childName)); } -inline OptionalBoolean IsBoolean( const TreeNode& parent, const std::string& childName) +inline OptionalBoolean IsBoolean(const TreeNode& parent, const std::string& childName) { - return IsBoolean( IsChild(parent, childName) ); + return IsBoolean(IsChild(parent, childName)); } -inline OptionalVector4 IsVector4(const TreeNode &parent, const std::string& childName) +inline OptionalVector4 IsVector4(const TreeNode& parent, const std::string& childName) { - return IsVector4( IsChild(parent, childName) ); + return IsVector4(IsChild(parent, childName)); } -inline OptionalVector3 IsVector3(const TreeNode &parent, const std::string& childName) +inline OptionalVector3 IsVector3(const TreeNode& parent, const std::string& childName) { - return IsVector3( IsChild(parent, childName) ); + return IsVector3(IsChild(parent, childName)); } -inline OptionalVector2 IsVector2(const TreeNode &parent, const std::string& childName) +inline OptionalVector2 IsVector2(const TreeNode& parent, const std::string& childName) { - return IsVector2( IsChild(parent, childName) ); + return IsVector2(IsChild(parent, childName)); } -inline OptionalMatrix IsMatrix(const TreeNode &parent, const std::string& childName) +inline OptionalMatrix IsMatrix(const TreeNode& parent, const std::string& childName) { - return IsMatrix( IsChild(parent, childName) ); + return IsMatrix(IsChild(parent, childName)); } -inline OptionalMatrix3 IsMatrix3(const TreeNode &parent, const std::string& childName) +inline OptionalMatrix3 IsMatrix3(const TreeNode& parent, const std::string& childName) { - return IsMatrix3( IsChild(&parent, childName) ); + return IsMatrix3(IsChild(&parent, childName)); } -inline OptionalRect IsRect(const TreeNode &parent, const std::string& childName) +inline OptionalRect IsRect(const TreeNode& parent, const std::string& childName) { - return IsRect( IsChild(&parent, childName) ); + return IsRect(IsChild(&parent, childName)); } -inline OptionalExtents IsExtents(const TreeNode &parent, const std::string& childName) +inline OptionalExtents IsExtents(const TreeNode& parent, const std::string& childName) { - return IsExtents( IsChild(&parent, childName) ); + return IsExtents(IsChild(&parent, childName)); } // // // -inline OptionalString IsString( const TreeNode& node ) +inline OptionalString IsString(const TreeNode& node) { - return IsString( OptionalChild( node ) ); + return IsString(OptionalChild(node)); } -inline OptionalFloat IsFloat( const TreeNode& node ) +inline OptionalFloat IsFloat(const TreeNode& node) { - return IsFloat( OptionalChild( node ) ); + return IsFloat(OptionalChild(node)); } -inline OptionalInteger IsInteger( const TreeNode& node ) +inline OptionalInteger IsInteger(const TreeNode& node) { - return IsInteger( OptionalChild( node ) ); + return IsInteger(OptionalChild(node)); } -inline OptionalBoolean IsBoolean( const TreeNode& node ) +inline OptionalBoolean IsBoolean(const TreeNode& node) { - return IsBoolean( OptionalChild( node ) ); + return IsBoolean(OptionalChild(node)); } -inline OptionalVector4 IsVector4(const TreeNode &node ) +inline OptionalVector4 IsVector4(const TreeNode& node) { - return IsVector4( OptionalChild( node ) ); + return IsVector4(OptionalChild(node)); } -inline OptionalVector3 IsVector3(const TreeNode &node ) +inline OptionalVector3 IsVector3(const TreeNode& node) { - return IsVector3( OptionalChild( node ) ); + return IsVector3(OptionalChild(node)); } -inline OptionalVector2 IsVector2(const TreeNode &node ) +inline OptionalVector2 IsVector2(const TreeNode& node) { - return IsVector2( OptionalChild( node ) ); + return IsVector2(OptionalChild(node)); } -inline OptionalMatrix IsMatrix(const TreeNode &node ) +inline OptionalMatrix IsMatrix(const TreeNode& node) { - return IsMatrix( OptionalChild( node ) ); + return IsMatrix(OptionalChild(node)); } -inline OptionalMatrix3 IsMatrix3(const TreeNode &node ) +inline OptionalMatrix3 IsMatrix3(const TreeNode& node) { - return IsMatrix3( OptionalChild( node ) ); + return IsMatrix3(OptionalChild(node)); } -inline OptionalRect IsRect(const TreeNode &node ) +inline OptionalRect IsRect(const TreeNode& node) { - return IsRect( OptionalChild( node ) ); + return IsRect(OptionalChild(node)); } -inline OptionalExtents IsExtents(const TreeNode &node ) +inline OptionalExtents IsExtents(const TreeNode& node) { - return IsExtents( OptionalChild( node ) ); + return IsExtents(OptionalChild(node)); } // // // -inline Dali::Vector4 GetVector4(const TreeNode &child) +inline Dali::Vector4 GetVector4(const TreeNode& child) { - OptionalVector4 v( IsVector4( OptionalChild( child ) ) ); + OptionalVector4 v(IsVector4(OptionalChild(child))); DALI_ASSERT_ALWAYS(v); return *v; } -inline Dali::Vector3 GetVector3(const TreeNode &child) +inline Dali::Vector3 GetVector3(const TreeNode& child) { - OptionalVector3 v( IsVector3( OptionalChild( child ) ) ); + OptionalVector3 v(IsVector3(OptionalChild(child))); DALI_ASSERT_ALWAYS(v); return *v; } -inline Dali::Vector2 GetVector2(const TreeNode &child) +inline Dali::Vector2 GetVector2(const TreeNode& child) { - OptionalVector2 v( IsVector2( OptionalChild( child ) ) ); + OptionalVector2 v(IsVector2(OptionalChild(child))); DALI_ASSERT_ALWAYS(v); return *v; } -inline float GetFloat(const TreeNode &child) +inline float GetFloat(const TreeNode& child) { - OptionalFloat v( IsFloat( OptionalChild( child ) ) ); + OptionalFloat v(IsFloat(OptionalChild(child))); DALI_ASSERT_ALWAYS(v); return *v; } -inline bool GetBoolean(const TreeNode &child) +inline bool GetBoolean(const TreeNode& child) { - OptionalBoolean v( IsBoolean( OptionalChild( child ) ) ); + OptionalBoolean v(IsBoolean(OptionalChild(child))); DALI_ASSERT_ALWAYS(v); return *v; } -inline int GetInteger(const TreeNode &child) +inline int GetInteger(const TreeNode& child) { - OptionalInteger v( IsInteger( OptionalChild( child ) ) ); + OptionalInteger v(IsInteger(OptionalChild(child))); DALI_ASSERT_ALWAYS(v); return *v; } - - -#endif // __DALI_TOOLKIT_INTERNAL_BUILDER_GET_IS_INL__ +#endif // DALI_TOOLKIT_INTERNAL_BUILDER_GET_IS_INL