[Plugin] jXML
#1

jXML
By J4Rr3x
Hi all, today I've made an useful plugin for load/read xml file. This is my first plugin, then I've made basic function for read xml. I've used PugiXML and XPath for made it more faster.

Natives:
pawn Код:
XML_Create(const filename[])
XML:XML_Open(const filename[])
XML_Close(XML:handle)
bool:XML_GetValueAsBool(XML:handle, const node[])
XML_GetValueAsInt(XML:handle, const node[])
Float:XML_GetValueAsFloat(XML:handle, const node[])
XML_GetValueAsString(XML:handle, const node[], destination[], size = sizeof destination)
Changelog:
Код:
14/05/2015:
- Added XML_Create(const filename[])
- Renamed all functions

13/05/2015:
- Made this plugin
Downloads:
[REMOVED]
Reply
#2

Needed it so much, thank you
Reply
#3

No include?
Reply
#4

Quote:
Originally Posted by ranme15
Посмотреть сообщение
Needed it so much, thank you
You're welcome, download include file.
Quote:
Originally Posted by Abagail
Посмотреть сообщение
No include?
Forgot it, sorry. Added.
Reply
#5

Nice! I was actually just looking for something like this about a week ago! It wasn't something I absolutely needed but yea, it's useful.

I can compile the linux plugin, but it'll be like an hour because I'm not home atm. EDIT: Tried making the makefile for it, can't get it to work...
Reply
#6

I'm sorry but isn't this just a ripoff of another XML plugin's code?
Reply
#7

Quote:
Originally Posted by xeeZ
Посмотреть сообщение
I'm sorry but isn't this just a ripoff of another XML plugin's code?
Looks like the code was ripped from this.

scripting.cpp (Zeex's plugin):

pawn Код:
// native xml_get_string(XML:handle, const xpath[], result[], size = sizeof result);
static cell AMX_NATIVE_CALL n_xml_get_string(AMX *amx, cell *params)
{
    document_iterator i = documents.find(reinterpret_cast<pugi::xml_document*>(params[1]));

    if (i != documents.end())
    {
        char *xpath;
        amx_StrParam(amx, params[2], xpath);

        cell* addr;
        amx_GetAddr(amx, params[3], &addr);

        try
        {
            amx_SetString(addr, pugi::xpath_query(xpath).evaluate_string(*(i->first)).c_str(), 0, 0, params[4]);
            return 1;
        }
        catch (std::exception &e)
        {
            logprintf("XML exception: %s\n", e.what());
        }
    }
    return 0;
}
jXML.cpp (jXML plugin):

pawn Код:
static cell AMX_NATIVE_CALL plugin_xml_get_value_string(AMX *amx, cell *params) // native xml_get_value_string(XML:handle, const node[], destination[], size = sizeof destination);
{
    document_iterator doc = documents.find(reinterpret_cast<pugi::xml_document*>(params[1]));

    if (doc != documents.end())
    {
        char *node;
        amx_StrParam(amx, params[2], node);

        cell* addr;
        amx_GetAddr(amx, params[3], &addr);

        try
        {
            amx_SetString(addr, pugi::xpath_query(node).evaluate_string(*(doc->first)).c_str(), 0, 0, params[4]);
            return 1;
        }
        catch (std::exception &error)
        {
            logprintf("[jXML] Exception: %s\n", error.what());
        }
    }
    return 0;
}
Reply
#8

WTF? I don't know Zeex's plugin, the look it's the same because I've use PugiXML because I already know and I've used this in other my project. If you believe this is a ripoff, I can delete post and when I add new functions I'll repost the plugin
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)