You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
2.5 KiB
C++
64 lines
2.5 KiB
C++
/*
|
|
* Copyright (c) Contributors to the Open 3D Engine Project.
|
|
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AzCore/XML/rapidxml.h>
|
|
|
|
namespace ProjectSettingsTool
|
|
{
|
|
// Wraps a plist dict node with a friendly api to allow lookups and other actions in it
|
|
class PlistDictionary
|
|
{
|
|
public:
|
|
// Constructs the dictionary wrapper
|
|
PlistDictionary(AZ::rapidxml::xml_document<char>* plist);
|
|
|
|
// Allocates a new node with given name and value
|
|
AZ::rapidxml::xml_node<char>* MakeNode(const char* name, const char* value);
|
|
AZ::rapidxml::xml_node<char>* MakeNode();
|
|
|
|
// Returns pointer to property data node
|
|
AZ::rapidxml::xml_node<char>* GetPropertyValueNode(const char* key);
|
|
|
|
// Creates a new property and returns pointer to its value node
|
|
AZ::rapidxml::xml_node<char>* AddProperty(const char* key);
|
|
// Removes property from dictionary
|
|
void RemoveProperty(const char* key);
|
|
|
|
// Returns pointer to property data value or nullptr if it is empty
|
|
const char* GetPropertyValue(const char* key);
|
|
const char* GetPropertyValue(AZ::rapidxml::xml_node<char>* node);
|
|
|
|
// Returns pointer to property data name or nullptr if it is empty
|
|
const char* GetPropertyValueName(const char* key);
|
|
const char* GetPropertyValueName(AZ::rapidxml::xml_node<char>* node);
|
|
|
|
// Changes value of property data and creates it if it doesn't exist
|
|
AZ::rapidxml::xml_node<char>* SetPropertyValue(const char* key, const char* newValue);
|
|
void SetPropertyValue(AZ::rapidxml::xml_node<char>* node, const char* newValue);
|
|
|
|
// Changes name of property data and creates it if it doesn't exist
|
|
AZ::rapidxml::xml_node<char>* SetPropertyValueName(const char* key, const char* newName);
|
|
void SetPropertyValueName(AZ::rapidxml::xml_node<char>* node, const char* newName);
|
|
|
|
// Checks to make sure a plist file has a valid dictionary
|
|
static bool ContainsValidDict(AZ::rapidxml::xml_document<char>* plist);
|
|
|
|
protected:
|
|
// Returns pointer to property key node
|
|
AZ::rapidxml::xml_node<char>* GetPropertyKeyNode(const char* key);
|
|
|
|
|
|
// pList dictionary is found in
|
|
AZ::rapidxml::xml_document<char>* m_document;
|
|
// The dictionary of properties
|
|
AZ::rapidxml::xml_node<char>* m_dict;
|
|
};
|
|
} // namespace ProjectSettingsTool
|