LCOV - code coverage report
Current view: top level - source/simulation2/serialization - DebugSerializer.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 1 1 100.0 %
Date: 2026-12-03 01:19:39 Functions: 0 0 -

          Line data    Source code
       1             : /* Copyright (C) 2026 Wildfire Games.
       2             :  * This file is part of 0 A.D.
       3             :  *
       4             :  * 0 A.D. is free software: you can redistribute it and/or modify
       5             :  * it under the terms of the GNU General Public License as published by
       6             :  * the Free Software Foundation, either version 2 of the License, or
       7             :  * (at your option) any later version.
       8             :  *
       9             :  * 0 A.D. is distributed in the hope that it will be useful,
      10             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  * GNU General Public License for more details.
      13             :  *
      14             :  * You should have received a copy of the GNU General Public License
      15             :  * along with 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
      16             :  */
      17             : 
      18             : #ifndef INCLUDED_DEBUGSERIALIZER
      19             : #define INCLUDED_DEBUGSERIALIZER
      20             : 
      21             : #include "ISerializer.h"
      22             : 
      23             : #include "simulation2/system/Component.h"
      24             : #include "lib/code_annotation.h"
      25             : #include "maths/Fixed.h"
      26             : 
      27             : #include <js/TypeDecls.h>
      28             : #include <cstddef>
      29             : #include <cstdint>
      30             : #include <iosfwd>
      31             : #include <string>
      32             : 
      33             : namespace Script { class Interface; }
      34             : 
      35             : /**
      36             :  * Serialize to a human-readable YAML-like format.
      37             :  */
      38          21 : class CDebugSerializer : public ISerializer
      39             : {
      40             :     NONCOPYABLE(CDebugSerializer);
      41             : public:
      42             :     /**
      43             :      * @param scriptInterface Script interface corresponding to any JS::Value passed to ScriptVal()
      44             :      * @param stream Stream to receive UTF-8 encoded output
      45             :      * @param includeDebugInfo If true then additional non-deterministic data will be included in the output
      46             :      */
      47             :     CDebugSerializer(const Script::Interface& scriptInterface, std::ostream& stream, bool includeDebugInfo = true);
      48             : 
      49             :     void Comment(const std::string& comment);
      50             :     void TextLine(const std::string& text);
      51             :     void Indent(int spaces);
      52             :     void Dedent(int spaces);
      53             : 
      54             :     virtual bool IsDebug() const;
      55             :     virtual std::ostream& GetStream();
      56             : 
      57             : protected:
      58             :     virtual void PutNumber(const char* name, uint8_t value);
      59             :     virtual void PutNumber(const char* name, int8_t value);
      60             :     virtual void PutNumber(const char* name, uint16_t value);
      61             :     virtual void PutNumber(const char* name, int16_t value);
      62             :     virtual void PutNumber(const char* name, uint32_t value);
      63             :     virtual void PutNumber(const char* name, int32_t value);
      64             :     virtual void PutNumber(const char* name, float value);
      65             :     virtual void PutNumber(const char* name, double value);
      66             :     virtual void PutNumber(const char* name, fixed value);
      67             :     virtual void PutBool(const char* name, bool value);
      68             :     virtual void PutString(const char* name, const std::string& value);
      69             :     virtual void PutScriptVal(const char* name, JS::MutableHandleValue value);
      70             :     virtual void PutRaw(const char* name, const std::uint8_t* data, size_t len);
      71             : 
      72             : private:
      73             :     const Script::Interface& m_ScriptInterface;
      74             :     std::ostream& m_Stream;
      75             :     bool m_IsDebug;
      76             :     int m_Indent;
      77             : };
      78             : 
      79             : #endif // INCLUDED_DEBUGSERIALIZER

Generated by: LCOV version 1.16