-#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.
*/
// EXTERNAL INCLUDES
-#include <utility> // pair
-#include <iterator>
#include <cstring>
+#include <iterator>
+#include <utility> // pair
-#include <dali/public-api/common/dali-common.h>
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
#include <dali/public-api/common/vector-wrapper.h>
// INTERNAL INCLUDES
namespace Dali
{
-
namespace Toolkit
{
-
namespace Internal
{
-typedef std::vector<char> VectorChar;
+typedef std::vector<char> VectorChar;
typedef VectorChar::iterator VectorCharIter;
/*
* @param child The child to add
* @return the added child
*/
- TreeNode *AddChild(TreeNode *child);
+ TreeNode* AddChild(TreeNode* child);
/*
* Change the type of the Node
* 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
* in the tree.
* @param on The state
*/
- void SetSubstitution( bool on );
+ void SetSubstitution(bool on);
/*
* Get the nodes type
* 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
void Write(std::ostream& output, int indent) const;
private:
- TreeNode *mNode;
+ TreeNode* mNode;
/*
* Move the nodes strings to the buffer
/*
* Do write to string stream
*/
- void DoWrite(const TreeNode *value, std::ostream& output, int level, int ident, bool groupChildren) const;
-
+ void DoWrite(const TreeNode* value, std::ostream& output, int level, int ident, bool groupChildren) const;
};
/*
* Collect nodes
*/
-struct CollectNodes : public std::unary_function<TreeNode*, void>
+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<const TreeNode*> VectorNodes;
- typedef VectorNodes::iterator iterator;
+ typedef VectorNodes::iterator iterator;
VectorNodes nodes; ///< List of collected nodes
};
/*
* Depth first walk of nodes applying given operation (unary_function)
*/
-template <typename Operation>
-void DepthFirst( TreeNode* node, Operation& operation)
+template<typename Operation>
+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<TreeNode*>(&((*iter).second)), operation);
+ DepthFirst(const_cast<TreeNode*>(&((*iter).second)), operation);
}
operation(node);
-
}
/*
* @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
* @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
} // namespace Dali
-#endif // __DALI_SCRIPT_TREE_NODE_MANIPULATOR_H__
+#endif // DALI_SCRIPT_TREE_NODE_MANIPULATOR_H