Code Monkey home page Code Monkey logo

Comments (5)

zeux avatar zeux commented on August 17, 2024

(for people who don't read Russian, the question/proposal is to enhance pugixml to make it easier to work with QString)

There are several ways in that you could change pugixml to make it easier to work with different Qt types - examples include Textalk@be9050c / Textalk@96799df and extra support for getting/setting node/attribute data with QString (I had a suggested patch at some point for something like that but I can't really find it).

In general I don't really see this as something that needs to be in pugixml core. I'd prefer a separate header - e.g. similar to contrib/foreach.hpp there could be contrib/qt.hpp - that somehow extended the API or provided conversion helpers so that you could use Qt types.

My understanding is that getting node data as QString is already transparent enough since QString provides a ctor from const char* - so the only inconvenience is in passing data to pugixml, where you have to do .toStdString().c_str() for all arguments. This can probably be wrapped in a helper class or a macro somehow.

from pugixml.

ybungalobill avatar ybungalobill commented on August 17, 2024

Note that by default toStdString() returns ISO-8859-1, not the system codepage, nor UTF-8 expected by pugixml in narrow compilation. The correct way is to use .toUtf8().data().

from pugixml.

zeux avatar zeux commented on August 17, 2024

I was looking at Qt 5.5 documentation when I wrote the code above:

Returns a std::string object with the data contained in this QString. The Unicode data is converted into 8-bit characters using the toUtf8() function.

Qt 4 uses toAscii in the toStdString implementation, yeah... My understanding is that .toUtf8().data() does not necessarily give a zero-terminated string?

from pugixml.

ybungalobill avatar ybungalobill commented on August 17, 2024

Hmm, you are right. Didn't know, and that's a good Qt change!

from pugixml.

zeux avatar zeux commented on August 17, 2024

Closing this for now; as mentioned above, happy to accept a separate header (e.g. contrib/qt.hpp) that somehow makes Qt interop easier.

from pugixml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.