Skip to content

Commit

Permalink
Add structure 0x11 parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Werni2A committed Jul 14, 2024
1 parent 6c8403f commit 2eab8bd
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Enums/Structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ enum class Structure

T0x10 = 16, // @todo Is this probably DrawnInst? Place a part in the schematic and this will also appear. Or rather
// PinInst
T0x11 = 17,

WireScalar = 20,
WireBus = 21,
Expand Down
5 changes: 5 additions & 0 deletions src/RecordFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#include "Structures/StructSymbolPinBus.hpp"
#include "Structures/StructSymbolPinScalar.hpp"
#include "Structures/StructT0x10.hpp"
#include "Structures/StructT0x11.hpp"
#include "Structures/StructT0x34.hpp"
#include "Structures/StructT0x35.hpp"
#include "Structures/StructT0x45.hpp"
Expand Down Expand Up @@ -179,6 +180,10 @@ std::unique_ptr<OOCP::Record> OOCP::RecordFactory::build(StreamContext& aCtx, St
case Structure::T0x10:
return std::make_unique<StructT0x10>(aCtx);
break;
// @todo Are they really identical? If so, derive from the same base class.
case Structure::T0x11:
return std::make_unique<StructT0x11>(aCtx);
break;
case Structure::T0x34:
return std::make_unique<StructT0x34>(aCtx);
break;
Expand Down
72 changes: 72 additions & 0 deletions src/Structures/StructT0x11.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#ifndef STRUCTT0X11_HPP
#define STRUCTT0X11_HPP

#include <cstdint>
#include <memory>
#include <optional>
#include <ostream>
#include <string>
#include <vector>

#include <fmt/core.h>
#include <nameof.hpp>

#include "General.hpp"
#include "Structures/StructT0x10.hpp"

namespace OOCP
{
class StructT0x11 : public StructT0x10
{
public:
StructT0x11(StreamContext& aCtx)
: StructT0x10{aCtx}
{
}


std::string to_string() const override;

// void accept(Visitor& aVisitor) const override
// {
// aVisitor.visit(*this);
// }

Structure getObjectType() const override
{
return Structure::T0x11;
}
};

[[maybe_unused]] static std::string to_string(const StructT0x11& aObj)
{
std::string str;

str += fmt::format("{}:\n", nameof::nameof_type<decltype(aObj)>());

str += fmt::format("{}symbolDisplayProps:\n", indent(1));
for(size_t i = 0u; i < aObj.symbolDisplayProps.size(); ++i)
{
if(aObj.symbolDisplayProps[i])
{
str += indent(fmt::format("[{}]: {}", i, aObj.symbolDisplayProps[i]->to_string()), 2);
}
}

return str;
}

inline std::string StructT0x11::to_string() const
{
return OOCP::to_string(*this);
}

[[maybe_unused]] static std::ostream& operator<<(std::ostream& aOs, const StructT0x11& aObj)
{
aOs << to_string(aObj);

return aOs;
}
} // namespace OOCP

#endif // STRUCTT0X11_HPP

0 comments on commit 2eab8bd

Please sign in to comment.