X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fbuilder%2Ftree-node-manipulator.h;h=0852497112aeeca32c0fa8f1c17f7e8e9e905ba9;hb=9ddd5fea6278d06b8874988498c7c4c6508750ba;hp=bd6953731b4d9a7b40f3878d42d2ee124487696e;hpb=1c3cb32385174b852b8d57b531625f733238f664;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/builder/tree-node-manipulator.h b/dali-toolkit/internal/builder/tree-node-manipulator.h index bd69537..0852497 100644 --- a/dali-toolkit/internal/builder/tree-node-manipulator.h +++ b/dali-toolkit/internal/builder/tree-node-manipulator.h @@ -1,8 +1,8 @@ -#ifndef __DALI_SCRIPT_TREE_NODE_MANIPULATOR_H__ -#define __DALI_SCRIPT_TREE_NODE_MANIPULATOR_H__ +#ifndef DALI_SCRIPT_TREE_NODE_MANIPULATOR_H +#define DALI_SCRIPT_TREE_NODE_MANIPULATOR_H /* - * Copyright (c) 2014 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. @@ -19,25 +19,23 @@ */ // EXTERNAL INCLUDES -#include // pair -#include -#include #include +#include +#include // pair -#include +#include +#include // INTERNAL INCLUDES -#include +#include namespace Dali { - namespace Toolkit { - namespace Internal { -typedef std::vector VectorChar; +typedef std::vector VectorChar; typedef VectorChar::iterator VectorCharIter; /* @@ -92,7 +90,7 @@ public: * @param child The child to add * @return the added child */ - TreeNode *AddChild(TreeNode *child); + TreeNode* AddChild(TreeNode* child); /* * Change the type of the Node @@ -100,13 +98,13 @@ public: * the children are removed * @param type The new type */ - void SetType( TreeNode::NodeType type); + void SetType(TreeNode::NodeType type); /* * Set the name of the node * @param name The name to set */ - void SetName( const char* name ); + void SetName(const char* name); /* * Set the substituion flag @@ -114,7 +112,7 @@ public: * in the tree. * @param on The state */ - void SetSubstitution( bool on ); + void SetSubstitution(bool on); /* * Get the nodes type @@ -132,25 +130,25 @@ public: * Set the node as a string value * @param string The string value */ - void SetString( const char* string ); + void SetString(const char* string); /* * Set the node as an integer value * @param i The integer */ - void SetInteger( int i ); + void SetInteger(int i); /* * Set the node as an float value * @param f The float */ - void SetFloat( float f ); + void SetFloat(float f); /* * Set the node as an boolean value * @param b The boolean */ - void SetBoolean( bool b ); + void SetBoolean(bool b); /* * Get the nodes parent @@ -171,7 +169,7 @@ public: void Write(std::ostream& output, int indent) const; private: - TreeNode *mNode; + TreeNode* mNode; /* * Move the nodes strings to the buffer @@ -191,28 +189,27 @@ private: /* * Do write to string stream */ - void DoWrite(const TreeNode *value, std::ostream& output, int ident) const; - + void DoWrite(const TreeNode* value, std::ostream& output, int level, int ident, bool groupChildren) const; }; /* * Collect nodes */ -struct CollectNodes : public std::unary_function +struct CollectNodes { - CollectNodes() {}; + CollectNodes(){}; /* * Call operator to add nodes to the list */ - result_type operator()(argument_type& n) + void operator()(TreeNode*& n) { DALI_ASSERT_DEBUG(n && "Operation on NULL JSON node"); nodes.push_back(n); } typedef std::vector VectorNodes; - typedef VectorNodes::iterator iterator; + typedef VectorNodes::iterator iterator; VectorNodes nodes; ///< List of collected nodes }; @@ -220,19 +217,18 @@ struct CollectNodes : public std::unary_function /* * Depth first walk of nodes applying given operation (unary_function) */ -template -void DepthFirst( TreeNode* node, Operation& operation) +template +void DepthFirst(TreeNode* node, Operation& operation) { DALI_ASSERT_DEBUG(node && "Operation on NULL JSON node"); for(TreeNode::ConstIterator iter = node->CBegin(); iter != node->CEnd(); ++iter) { // iterator access is const for external api but were modifying - DepthFirst( const_cast(&((*iter).second)), operation); + DepthFirst(const_cast(&((*iter).second)), operation); } operation(node); - } /* @@ -241,7 +237,7 @@ void DepthFirst( TreeNode* node, Operation& operation) * @param tree The tree to search * @return the TreeNode if found, else NULL */ -const TreeNode* FindIt(const std::string& childName, const TreeNode* tree); +const TreeNode* FindIt(std::string_view childName, const TreeNode* tree); /* * Copy string to a buffer @@ -251,8 +247,7 @@ const TreeNode* FindIt(const std::string& childName, const TreeNode* tree); * @param sentinel The buffer sentinel * @return The start of the given buffer */ -char *CopyString( const char *fromString, VectorCharIter& iter, const VectorCharIter& sentinel); - +char* CopyString(const char* fromString, VectorCharIter& iter, const VectorCharIter& sentinel); } // namespace Internal @@ -260,4 +255,4 @@ char *CopyString( const char *fromString, VectorCharIter& iter, const VectorChar } // namespace Dali -#endif // __DALI_SCRIPT_TREE_NODE_MANIPULATOR_H__ +#endif // DALI_SCRIPT_TREE_NODE_MANIPULATOR_H