Files
o3de/Code/Legacy/CrySystem/XML/XMLBinaryNode.h
T
Artur K 56904d1799 Cry Legacy: the Lessening (#5961)
* Generic Cleanup

Removals:

* Unused cvars,member variables and defines
* Windows media center edition support routines
* CSystem - removed debug_GetCallStackRaw/GetRootWindowMessageHandler/
UnloadDLL/ShutdownModuleLibraries

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Fix CryMessageBox return values in Windows build

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove named selection group and a few smaller unused functionalities

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove ObjectManager export functionality + 2 deprecated functions

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove object legacy freeze/hide support from ObjectManager

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove ObjectManager duplicate name dection, as well as object renaming

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove ObjectManager serialization and selection callbacks

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* ObjectManager - remove MoveObjects/HitTestObject/EndEditParams and related members/functions

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove a bunch of unused clone related functionality + misc

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* ObjectManager - misc removals

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* ObjectManager - more removals

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove unused object selection/retrieval in ObjectManager and LoadObjects in ObjectLoader

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* CBaseObject - remove unused material layers mask support

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* More CBaseObject cleanups.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* CBaseObject - remove SubObj functions and IMouseCreateCallback

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove unused procedural floor management, helper scale and tags.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* CBaseObject - remove more unused methods.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Removals in multiple places.

CBaseObject - unused `OBJTYPE_DUMMY` flag removed, member `IsSameClass`
CObjectArchive removed unused methods/members
CObjectManager removed unused `Update` method

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* More removals

IDisplayViewport - HitTestLine/GetGridStep/setHitcontext/
GetConstructionPlane
Unused Cry_Matrix44 template specializations.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* O3DE.exe Project-Centric "Open Editor" fix (#5852)

* The O3DE.exe Open Editor button now attempts to open the Editor in the
build directory of the project being opened.

If their is no Editor within the build directory of the Project, it uses
the Editor.exe in the current O3DE.exe executable directory if it exists

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Engine .gitignore now ignores the build directory if placed in the
AutomatedTesting project

Previously it was just ignoring a `[Bb]uild` directory if it was
directly within the engine root.
This change matches the behavior of the project templates.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Renamed the ProjectUtils GetEditorDirectory function to
GetEditorExecutablePath

Added a platform specific implementation for retrieving the path to the
Editor executable in the GetEditorExectuablePath function.

It first attempts to locate the Editor via checking the project build
directory for an Editor executable before falling back to checking the
binary directory of the currently running O3DE executable.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Correct the MacOS GetEditorExecutablePath to return the Editor path

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Adding missing C++20 std::erase implementations (#5735)

There were already implementations for std::erase_if.
This adds the counterpart AZStd::erase versions

resolves #5734

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* More removals and refactors

`ShowMessage` and `CryMessageBox` return void now
Simplify code in `CSystem::WarningV`
Remove unused `CryGetTicksPerSec`
Remove unused WinBase functionality
Replace `nanosleep` call in WinBase with `std::this_thread::sleep_for`
Remove unused Win32Wrapper routines
Remove unused IFunctorBase.h and IEntityObjectListener.h
Fix VectorAndArray.cpp compilation
Use QMessageBox instead of CryMessageBox in the editor.
Remove empty ArchiveVars platform specific files

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Fix test code.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove an unused  function

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* CBaseObject and undo description removals.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* A bunch of removals

* Remove IRenderNode
* Remove editor's KDTree
* Remove StatObjBus, InstanceStatObjEventBus::ReleaseData is redundant (
same functionality in the only available handler is triggered by
`OnCryEditorCloseScene`)
* Remove CExportManager::AddStatObj/AddMeshes/AddMesh,
IExportManager::ExportSingleStatObj
* Remove CIconManager/IIconManager::GetObject
* Remove CBaseObject::IntersectRayMesh
* Remove IIndexedMesh and related structs.
* Unused IUndoObject::GetDescription and all derived implementations.
* Unused CUndoBaseLibrary/CUndoBaseLibraryManager
* Unused Matrix34_tpl typedefs
* Legacy Xml classes cleanup

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove unused `Vec3ToVector3D` helper

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* fix - remove unused static variable

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

Co-authored-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
2021-11-29 11:21:06 -07:00

215 lines
8.9 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 "IXml.h"
#include "XMLBinaryHeaders.h"
// Compare function for string comparison, can be strcmp or _stricmp
typedef int (__cdecl * XmlStrCmpFunc)(const char* str1, const char* str2);
extern XmlStrCmpFunc g_pXmlStrCmp;
class CBinaryXmlNode;
//////////////////////////////////////////////////////////////////////////
class CBinaryXmlData
{
public:
const XMLBinary::Node* pNodes = nullptr;
const XMLBinary::Attribute* pAttributes = nullptr;
const XMLBinary::NodeIndex* pChildIndices = nullptr;
const char* pStringData = nullptr;
const char* pFileContents = nullptr;
size_t nFileSize = 0;
bool bOwnsFileContentsMemory = true;
CBinaryXmlNode* pBinaryNodes = nullptr;
int nRefCount = 0;
CBinaryXmlData() = default;
~CBinaryXmlData();
};
// forward declaration
namespace XMLBinary
{
class XMLBinaryReader;
};
//////////////////////////////////////////////////////////////////////////
// CBinaryXmlNode class only used for fast read only binary XML import
//////////////////////////////////////////////////////////////////////////
class CBinaryXmlNode
: public IXmlNode
{
public:
//////////////////////////////////////////////////////////////////////////
// Custom new/delete with pool allocator.
//////////////////////////////////////////////////////////////////////////
//void* operator new( size_t nSize );
//void operator delete( void *ptr );
void DeleteThis() override { }
//! Create new XML node.
XmlNodeRef createNode(const char* tag) override;
// Summary:
// Reference counting.
void AddRef() override { ++m_pData->nRefCount; };
// Notes:
// When ref count reach zero XML node dies.
void Release() override
{
if (--m_pData->nRefCount <= 0)
{
delete m_pData;
}
};
//! Get XML node tag.
const char* getTag() const override { return _string(_node()->nTagStringOffset); };
void setTag([[maybe_unused]] const char* tag) override { assert(0); };
//! Return true if given tag is equal to node tag.
bool isTag(const char* tag) const override;
//! Get XML Node attributes.
int getNumAttributes() const override { return (int)_node()->nAttributeCount; };
//! Return attribute key and value by attribute index.
bool getAttributeByIndex(int index, const char** key, const char** value) override;
//! Return attribute key and value by attribute index, string version.
virtual bool getAttributeByIndex(int index, XmlString& key, XmlString& value);
void copyAttributes(XmlNodeRef fromNode) override { assert(0); };
//! Get XML Node attribute for specified key.
const char* getAttr(const char* key) const override;
//! Get XML Node attribute for specified key.
// Returns true if the attribute exists, false otherwise.
bool getAttr(const char* key, const char** value) const override;
//! Check if attributes with specified key exist.
bool haveAttr(const char* key) const override;
XmlNodeRef newChild([[maybe_unused]] const char* tagName) override { assert(0); return 0; };
void addChild([[maybe_unused]] const XmlNodeRef& node) override { assert(0); };
void removeChild([[maybe_unused]] const XmlNodeRef& node) override { assert(0); };
//! Remove all child nodes.
void removeAllChilds() override { assert(0); };
//! Get number of child XML nodes.
int getChildCount() const override { return (int)_node()->nChildCount; };
//! Get XML Node child nodes.
XmlNodeRef getChild(int i) const override;
//! Find node with specified tag.
XmlNodeRef findChild(const char* tag) const override;
void deleteChild([[maybe_unused]] const char* tag) { assert(0); };
//! Get parent XML node.
XmlNodeRef getParent() const override;
//! Returns content of this node.
const char* getContent() const override { return _string(_node()->nContentStringOffset); };
void setContent([[maybe_unused]] const char* str) override { assert(0); };
//! Set line number in xml.
void setLine([[maybe_unused]] int line) override { assert(0); };
//! Returns XML of this node and sub nodes.
IXmlStringData* getXMLData([[maybe_unused]] int nReserveMem = 0) const override { assert(0); return 0; };
XmlString getXML([[maybe_unused]] int level = 0) const override { assert(0); return ""; };
bool saveToFile([[maybe_unused]] const char* fileName) override { assert(0); return false; }; // saves in one huge chunk
bool saveToFile([[maybe_unused]] const char* fileName, [[maybe_unused]] size_t chunkSizeBytes, [[maybe_unused]] AZ::IO::HandleType fileHandle = AZ::IO::InvalidHandle) override { assert(0); return false; }; // save in small memory chunks
//! Set new XML Node attribute (or override attribute with same key).
using IXmlNode::setAttr;
void setAttr([[maybe_unused]] const char* key, [[maybe_unused]] const char* value) override { assert(0); };
void setAttr([[maybe_unused]] const char* key, [[maybe_unused]] int value) override { assert(0); };
void setAttr([[maybe_unused]] const char* key, [[maybe_unused]] unsigned int value) override { assert(0); };
void setAttr([[maybe_unused]] const char* key, [[maybe_unused]] int64 value) override { assert(0); };
void setAttr([[maybe_unused]] const char* key, [[maybe_unused]] uint64 value, [[maybe_unused]] bool useHexFormat = true /* ignored */) override { assert(0); };
void setAttr([[maybe_unused]] const char* key, [[maybe_unused]] float value) override { assert(0); };
void setAttr([[maybe_unused]] const char* key, [[maybe_unused]] f64 value) override { assert(0); };
void setAttr([[maybe_unused]] const char* key, [[maybe_unused]] const Vec2& value) override { assert(0); };
void setAttr([[maybe_unused]] const char* key, [[maybe_unused]] const Ang3& value) override { assert(0); };
void setAttr([[maybe_unused]] const char* key, [[maybe_unused]] const Vec3& value) override { assert(0); };
void setAttr([[maybe_unused]] const char* key, [[maybe_unused]] const Vec4& value) override { assert(0); };
void setAttr([[maybe_unused]] const char* key, [[maybe_unused]] const Quat& value) override { assert(0); };
void delAttr([[maybe_unused]] const char* key) override { assert(0); };
void removeAllAttributes() override { assert(0); };
//! Get attribute value of node.
bool getAttr(const char* key, int& value) const override;
bool getAttr(const char* key, unsigned int& value) const override;
bool getAttr(const char* key, int64& value) const override;
bool getAttr(const char* key, uint64& value, bool useHexFormat = true /* ignored */) const override;
bool getAttr(const char* key, float& value) const override;
bool getAttr(const char* key, f64& value) const override;
bool getAttr(const char* key, bool& value) const override;
bool getAttr(const char* key, XmlString& value) const override {const char* v(NULL); bool boHasAttribute(getAttr(key, &v)); value = v; return boHasAttribute; }
bool getAttr(const char* key, Vec2& value) const override;
bool getAttr(const char* key, Ang3& value) const override;
bool getAttr(const char* key, Vec3& value) const override;
bool getAttr(const char* key, Vec4& value) const override;
bool getAttr(const char* key, Quat& value) const override;
bool getAttr(const char* key, ColorB& value) const override;
private:
//////////////////////////////////////////////////////////////////////////
// INTERNAL METHODS
//////////////////////////////////////////////////////////////////////////
const char* GetValue(const char* key) const
{
const XMLBinary::Attribute* const pAttributes = m_pData->pAttributes;
const char* const pStringData = m_pData->pStringData;
const int nFirst = _node()->nFirstAttributeIndex;
const int nLast = nFirst + _node()->nAttributeCount;
for (int i = nFirst; i < nLast; i++)
{
const char* const attrKey = pStringData + pAttributes[i].nKeyStringOffset;
if (g_pXmlStrCmp(key, attrKey) == 0)
{
const char* attrValue = pStringData + pAttributes[i].nValueStringOffset;
return attrValue;
}
}
return 0;
}
// Return current node in binary data.
const XMLBinary::Node* _node() const
{
return &m_pData->pNodes[this - m_pData->pBinaryNodes];
}
const char* _string(int nIndex) const
{
return m_pData->pStringData + nIndex;
}
protected:
void setParent([[maybe_unused]] const XmlNodeRef& inRef) override { assert(0); }
//////////////////////////////////////////////////////////////////////////
private:
CBinaryXmlData* m_pData;
friend class XMLBinary::XMLBinaryReader;
};