TinyURDF 1.0.0
Loading...
Searching...
No Matches
parser_base.h
Go to the documentation of this file.
1#ifndef INCLUDE_TINYURDF_COMMON_PARSER_BASE_H_
2#define INCLUDE_TINYURDF_COMMON_PARSER_BASE_H_
3
4// Copyright 2025 wissem CHIHA
5
6#include <memory>
7#include <loguru/loguru.hpp>
8#include <tinyxml2/tinyxml2.h>
10
11template <class T>
12class ParserBase : public ObjectBase {
13 public:
14 const char* getNameOf(const tinyxml2::XMLElement* xml) {
15 const char* name = xml->Attribute("name");
16 if (!name) {
17 return "";
18 } else {
19 return name;
20 }
21 }
22 virtual void parse(const tinyxml2::XMLElement* xml) {
23 if (!xml) {
24 LOG_F(ERROR, "Parser::parse() passed nullptr");
25 return;
26 }
27 }
28 virtual std::shared_ptr<T> get() { return Tptr; }
29 protected:
31 virtual ~ParserBase(){}
32 std::shared_ptr<T> Tptr;
33};
34#endif // INCLUDE_TINYURDF_COMMON_PARSER_BASE_H_
Definition object_base.h:8
Definition parser_base.h:12
const char * getNameOf(const tinyxml2::XMLElement *xml)
Definition parser_base.h:14
virtual std::shared_ptr< T > get()
Definition parser_base.h:28
ParserBase()
Definition parser_base.h:30
std::shared_ptr< T > Tptr
Definition parser_base.h:32
virtual ~ParserBase()
Definition parser_base.h:31
virtual void parse(const tinyxml2::XMLElement *xml)
Definition parser_base.h:22