|
|
(18 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
− | eC_Bool CMyGUI::DoClick(const eC_Value& vAbsX, const eC_Value& vAbsY)
| + | <!-- |
− | {
| |
− | CGUICompositeObject* pkComp = new CGUICompositeObject(NULL, 0, 0, 100, 100);
| |
− | CGUIObject* pkObj = new CGUIObject(pkComp, 0, 0, 50, 50);
| |
| | | |
− | CGUIStreamWriterJSON kWriter;
| + | https://developers.google.com/speed/webp/docs/riff_container |
− | eC_PlatformFile* pkFile = new eC_PlatformFile("C:\\temp\\blabla.json", eC_PlatformFile::FS_WRITEACCESS);
| + | https://chromium.googlesource.com/webm/libvpx |
| | | |
− | pkFile->Write8i('{');
| + | vera++ -> checkstlye output -> warnings next generation (input as logfile) |
− | pkFile->Write8i('\n');
| |
| | | |
− | kWriter.SetStreamingFile(pkFile);
| + | google code stylguide |
− | GETGUI.WriteToStream(true);
| + | https://google.github.io/styleguide/cppguide.html |
| | | |
− | pkFile->Write8i('\n');
| + | google styleguide cpplint |
− | pkFile->Write8i('}');
| + | https://github.com/google/styleguide |
| | | |
− | delete pkComp;
| + | find bugs plugin -> warnings next generation |
− | delete pkFile;
| |
| | | |
− | return false;
| + | tags (e.g. TODO, FIXME, ...) can be found and listed |
− | }
| |
| | | |
− | #include "GUIStreamWriter.h"
| + | --> |
− | | |
− | #include "eC_TList_doubleLinked.h"
| |
− | | |
− | class CGUIStreamWriterJSON : public CGUIStreamWriter
| |
− | {
| |
− | public:
| |
− | CGUIStreamWriterJSON();
| |
− | ~CGUIStreamWriterJSON();
| |
− | | |
− | virtual void WriteUByte(const eC_UByte ubByte, const eC_Char* const pcTag);
| |
− | virtual void WriteByte(const eC_Byte bByte, const eC_Char* const pcTag);
| |
− | virtual void WriteUInt(const eC_UInt uiInt, const eC_Char* const pcTag);
| |
− | virtual void WriteUShort(const eC_UShort usShort, const eC_Char* const pcTag);
| |
− | virtual void WriteInt(const eC_Int iInt, const eC_Char* const pcTag);
| |
− | virtual void WriteHex(const eC_UInt uiInt, const eC_Char* const pcTag);
| |
− | virtual void WriteColor(const ColorValue_t eColor, const eC_Char* const pcTag);
| |
− | virtual void WriteFloat(const eC_Float fFloat, const eC_Char* const pcTag);
| |
− | virtual void WriteString(const eC_String &pkString, const eC_Char* const pcTag);
| |
− | virtual void WriteShort(const eC_Short iShort, const eC_Char* const pcTag);
| |
− | virtual void WriteBool(const eC_Bool bBool, const eC_Char* const pcTag);
| |
− | virtual void WriteBinary(const eC_TArray<eC_UByte>& aData, const eC_Char* const pcTag);
| |
− | | |
− | virtual void WriteCommentTag(const eC_Char* const pcTag);
| |
− | virtual void WriteCommentTag(const eC_String& kTag);
| |
− | | |
− | virtual void WriteStreamingFileHeader(const eC_Int iFileVersion);
| |
− | virtual eC_Bool SetFileEndianess(FileEndianess_t eFileEndianess);
| |
− | virtual eC_Bool SetFileAlignment(FileAlignment_t eFileAlignment);
| |
− | | |
− | void WriteNode(const eC_String& kName, const eC_String& kValue, const eC_Bool& bAddDoubleQuotes);
| |
− | void WriteNodeName(const eC_String& kName);
| |
− | void WriteNodeValue(const eC_String& kValue, const eC_Bool& bAddDoubleQuotes);
| |
− | | |
− | void BeginObject(const eC_String& kName);
| |
− | void EndObject();
| |
− | void BeginArray(const eC_String& kName);
| |
− | void EndArray();
| |
− | | |
− | void WriteIndentation();
| |
− | void WriteLineEnding();
| |
− | | |
− | private:
| |
− | enum TokenType_t
| |
− | {
| |
− | TT_OBJECT,
| |
− | TT_ARRAY,
| |
− | TT_NODE
| |
− | };
| |
− | | |
− | private:
| |
− | CGUIStreamWriterJSON(const CGUIStreamWriterJSON& kSource);
| |
− | CGUIStreamWriterJSON& operator=(const CGUIStreamWriterJSON& kSource);
| |
− | | |
− | void WriteUnterminatedString(const eC_String& kString);
| |
− | | |
− | private:
| |
− | eC_TListDoubleLinked<TokenType_t> m_kTokenStack;
| |
− | eC_UInt m_uiIdentation;
| |
− | eC_UInt m_uiCurrentNumberOfElements;
| |
− | };
| |
− | | |
− | #include "GUIStreamWriterJSON.h"
| |
− | #include "GUICompositeObject.h"
| |
− | | |
− | CGUIStreamWriterJSON::CGUIStreamWriterJSON() :
| |
− | CGUIStreamWriter(FileType_t::FILE_TYPE_CUSTOM, FileEndianess_t::FILE_ENDIANESS_LITTLE, FileAlignment_t::FILE_ALIGNMENT_8BIT),
| |
− | m_uiIdentation(1),
| |
− | m_uiCurrentNumberOfElements(0)
| |
− | {
| |
− | }
| |
− | | |
− | CGUIStreamWriterJSON::~CGUIStreamWriterJSON()
| |
− | {
| |
− | //WriteUnterminatedString("}");
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::WriteUByte(const eC_UByte ubByte, const eC_Char* const pcTag)
| |
− | {
| |
− | eC_String kValue(ubByte);
| |
− | WriteNode(pcTag, kValue, false);
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::WriteByte(const eC_Byte bByte, const eC_Char* const pcTag)
| |
− | {
| |
− | eC_String kValue(bByte);
| |
− | WriteNode(pcTag, kValue, false);
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::WriteUInt(const eC_UInt uiInt, const eC_Char* const pcTag)
| |
− | {
| |
− | eC_String kValue(uiInt);
| |
− | WriteNode(pcTag, kValue, false);
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::WriteUShort(const eC_UShort usShort, const eC_Char* const pcTag)
| |
− | {
| |
− | eC_String kValue(usShort);
| |
− | WriteNode(pcTag, kValue, false);
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::WriteInt(const eC_Int iInt, const eC_Char* const pcTag)
| |
− | {
| |
− | eC_String kValue(iInt);
| |
− | WriteNode(pcTag, kValue, false);
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::WriteHex(const eC_UInt uiInt, const eC_Char* const pcTag)
| |
− | {
| |
− | eC_String kValue(uiInt);
| |
− | WriteNode(pcTag, kValue, false);
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::WriteColor(const ColorValue_t eColor, const eC_Char* const pcTag)
| |
− | {
| |
− | WriteHex(eColor.uiColor, pcTag);
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::WriteFloat(const eC_Float fFloat, const eC_Char* const pcTag)
| |
− | {
| |
− | eC_String kValue(fFloat);
| |
− | WriteNode(pcTag, kValue, false);
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::WriteString(const eC_String &pkString, const eC_Char* const pcTag)
| |
− | {
| |
− | WriteNode(pcTag, pkString, true);
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::WriteShort(const eC_Short iShort, const eC_Char* const pcTag)
| |
− | {
| |
− | eC_String kValue(iShort);
| |
− | WriteNode(pcTag, kValue, false);
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::WriteBool(const eC_Bool bBool, const eC_Char* const pcTag)
| |
− | {
| |
− | WriteNode(pcTag, (bBool) ? "true" : "false", false);
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::WriteBinary(const eC_TArray<eC_UByte>& aData, const eC_Char* const pcTag)
| |
− | {
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::WriteCommentTag(const eC_Char* const pcTag)
| |
− | {
| |
− | WriteCommentTag(eC_String(pcTag));
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::WriteCommentTag(const eC_String& kTag)
| |
− | {
| |
− | if (kTag.IsEmpty())
| |
− | return;
| |
− | | |
− | if (kTag == CGUICompositeObject::XMLTAG_CHILDREN)
| |
− | {
| |
− | BeginArray(kTag);
| |
− | }
| |
− | else if (kTag == CGUICompositeObject::XMLTAG_ENDCHILDREN)
| |
− | {
| |
− | EndArray();
| |
− | }
| |
− | else if (kTag == CGUIObject::XMLTAG_CLASSVERSION)
| |
− | {
| |
− | }
| |
− | else
| |
− | {
| |
− | if (kTag.GetArray()[0] != '/')
| |
− | BeginObject(kTag);
| |
− | else
| |
− | EndObject();
| |
− | }
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::WriteStreamingFileHeader(const eC_Int iFileVersion)
| |
− | {
| |
− | }
| |
− | | |
− | eC_Bool CGUIStreamWriterJSON::SetFileEndianess(FileEndianess_t eFileEndianess)
| |
− | {
| |
− | m_eFileEndianess = eFileEndianess;
| |
− | | |
− | return true;
| |
− | }
| |
− | | |
− | eC_Bool CGUIStreamWriterJSON::SetFileAlignment(FileAlignment_t eFileAlignment)
| |
− | {
| |
− | m_eFileAlignment = eFileAlignment;
| |
− | | |
− | return true;
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::WriteNode(const eC_String& kName, const eC_String& kValue, const eC_Bool& bAddDoubleQuotes)
| |
− | {
| |
− | if (kName == "ChildCount")
| |
− | return;
| |
− | | |
− | if (!kName.IsEmpty())
| |
− | {
| |
− | WriteLineEnding();
| |
− | WriteNodeName(kName);
| |
− | WriteNodeValue(kValue, bAddDoubleQuotes);
| |
− | | |
− | ++m_uiCurrentNumberOfElements;
| |
− | }
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::WriteNodeName(const eC_String& kName)
| |
− | {
| |
− | WriteIndentation();
| |
− | WriteUnterminatedString("\"" + kName + "\": ");
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::WriteNodeValue(const eC_String& kValue, const eC_Bool& bAddDoubleQuotes)
| |
− | {
| |
− | //if (m_kTokenStack.GetQuantity() == 0)
| |
− | | |
− | eC_String kText;
| |
− | if (bAddDoubleQuotes)
| |
− | kText += "\"";
| |
− | kText += kValue;
| |
− | if (bAddDoubleQuotes)
| |
− | kText += "\"";
| |
− | | |
− | WriteUnterminatedString(kText);
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::BeginObject(const eC_String& kName)
| |
− | {
| |
− | WriteLineEnding();
| |
− | | |
− | eC_Bool bWriteName = true;
| |
− | | |
− | if ((m_kTokenStack.GetQuantity() > 0) &&
| |
− | (*m_kTokenStack.GetAt(m_kTokenStack.GetQuantity() - 1) == TT_ARRAY)
| |
− | )
| |
− | bWriteName = false;
| |
− | | |
− | if (bWriteName)
| |
− | {
| |
− | if (!kName.IsEmpty())
| |
− | WriteNodeName(kName);
| |
− | }
| |
− | else
| |
− | WriteIndentation();
| |
− | | |
− | WriteUnterminatedString("{\n");
| |
− | | |
− | m_uiCurrentNumberOfElements = 0;
| |
− | ++m_uiIdentation;
| |
− | | |
− | m_kTokenStack.AddAtEnd(TT_OBJECT);
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::EndObject()
| |
− | {
| |
− | WriteUnterminatedString("\n");
| |
− | | |
− | --m_uiIdentation;
| |
− | | |
− | WriteIndentation();
| |
− | WriteUnterminatedString("}");
| |
− | | |
− | TokenType_t eTokenType;
| |
− | m_kTokenStack.RemoveEnd(eTokenType);
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::BeginArray(const eC_String& kName)
| |
− | {
| |
− | WriteLineEnding();
| |
− | | |
− | if (!kName.IsEmpty())
| |
− | WriteNodeName(kName);
| |
− | WriteUnterminatedString("[\n");
| |
− | | |
− | m_uiCurrentNumberOfElements = 0;
| |
− | ++m_uiIdentation;
| |
− | | |
− | m_kTokenStack.AddAtEnd(TT_ARRAY);
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::EndArray()
| |
− | {
| |
− | WriteUnterminatedString("\n");
| |
− | --m_uiIdentation;
| |
− | | |
− | WriteIndentation();
| |
− | WriteUnterminatedString("]");
| |
− | | |
− | TokenType_t eTokenType;
| |
− | m_kTokenStack.RemoveEnd(eTokenType);
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::WriteUnterminatedString(const eC_String& kString)
| |
− | {
| |
− | if (kString.IsEmpty())
| |
− | return;
| |
− | | |
− | eC_Char* pkString = kString.ToASCII_Alloc();
| |
− | m_pkStreamingFile->Write8((eC_UByte*)pkString, kString.GetLength());
| |
− | | |
− | delete pkString;
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::WriteIndentation()
| |
− | {
| |
− | eC_String kText;
| |
− | | |
− | for (eC_UInt uiIndent = 0; uiIndent < m_uiIdentation; ++uiIndent)
| |
− | kText += " ";
| |
− | | |
− | WriteUnterminatedString(kText);
| |
− | }
| |
− | | |
− | void CGUIStreamWriterJSON::WriteLineEnding()
| |
− | {
| |
− | eC_String kText;
| |
− | | |
− | if (m_uiCurrentNumberOfElements > 0)
| |
− | kText += ",\n";
| |
− | WriteUnterminatedString(kText);
| |
− | }
| |