From 0d68ca05e2ce210f8ff83a6ea4220c2320b3605b Mon Sep 17 00:00:00 2001 From: Nuno Date: Wed, 20 Oct 2021 15:33:47 +0200 Subject: [PATCH] Revert xml_macros --- nel/include/nel/misc/xml_macros.h | 75 +++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/nel/include/nel/misc/xml_macros.h b/nel/include/nel/misc/xml_macros.h index e69de29bb..6d924954b 100644 --- a/nel/include/nel/misc/xml_macros.h +++ b/nel/include/nel/misc/xml_macros.h @@ -0,0 +1,75 @@ +// NeL - MMORPG Framework +// Copyright (C) 2010-2021 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef XML_MACROS_H +#define XML_MACROS_H + +// +// xmlNodePtr cur; +// CXMLAutoPtr prop; +// +// sint i; +// XML_READ_SINT(cur, "prop_name", i, -1); +// + +#define XML_READ_UINT(node, name, var, def) { \ + uint tmp; \ + prop = (char *) xmlGetProp(node, (xmlChar*)name); \ + if (prop && fromString((const char*)prop, tmp)) \ + var = tmp; \ + else \ + var = def; \ +} + +#define XML_READ_SINT(node, name, var, def) { \ + sint tmp; \ + prop = (char *) xmlGetProp(node, (xmlChar*)name); \ + if (prop && fromString((const char*)prop, tmp)) \ + var = tmp; \ + else \ + var = def; \ +} + +#define XML_READ_BOOL(node, name, var, def) { \ + prop = (char *) xmlGetProp(node, (xmlChar*)name); \ + if (prop) \ + var = NLMISC::toBool((const char*)prop); \ + else \ + var = def; \ +} + +#define XML_READ_COLOR(node, name, var, def) { \ + NLMISC::CRGBA tmp; \ + prop = (char *) xmlGetProp(node, (xmlChar*)name); \ + if (prop && fromString((const char*)prop, tmp)) \ + var = tmp; \ + else \ + var = def; \ +} + +#define XML_READ_STRING(node, name, var, def) { \ + prop = (char *) xmlGetProp(node, (xmlChar*)name); \ + if (prop) \ + var = (const char*)prop; \ + else \ + var = def; \ +} + +#endif // XML_MACROS_H + +