Comments (5)
(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.
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.
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.
Hmm, you are right. Didn't know, and that's a good Qt change!
from pugixml.
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)
- strtod is locale dependent, so as xml_attribute::as_double and get_value_double HOT 1
- Empty text childs increase XML file size HOT 5
- xml_node_iterator should satisfy at least std::input_or_output_iterator concept HOT 3
- Assertion fails during number-to-string conversion if wrong C locale is set (non-MSVC) HOT 1
- Support std::filesystem::path HOT 2
- Version 1.14 HOT 1
- Can you add the ability to access child nodes using index? HOT 1
- PUGIXML_WCHAR_MODE and error messages. HOT 1
- add xml_node_type_str function for debugging and application logging HOT 3
- option to join multiple CDATA sections into one when parsing HOT 2
- parse_embed_pcdata and parse_merge_pcdata don't play together HOT 2
- Unexpected #endif in line 13201 with precompilation in a pch.h file HOT 2
- XML Canonicalization: as an option, allow parsing eol's into the document model (as PCDATA holding those) HOT 2
- Warning when building 1.14 in x86 on Clang HOT 3
- Position of the parse result offset in case of status_bad_start_element
- Error in handling loading errors example HOT 1
- Incorrect result of xml_document::load_file -"File was not found" HOT 2
- Question: I have made my own case insensitive version, is that ok? HOT 2
- Serilisation HOT 4
- pugi::xml_node and std::ranges, maybe a documentation request HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pugixml.