Skip to content

Conversation

@tretre91
Copy link
Contributor

@tretre91 tretre91 commented Dec 28, 2025

This PR fixes a few compile issues related to the use of std::string where a Rml::String is expected (or the opposite).

In SVGCache.cpp, I applied the same changes as in #820, since they got overwritten by #777. I also added an explanatory comment.

Also note that the samples and benchmarks don't compile when Rml::String is not std::string. I can add the fix for the samples in this PR if needed, I put the patch below.
For the benchmarks I don't know if it's necessary to fix them, as I wouldn't expect people to run them with a non-std string type. Afaict it's just that the bench.run(name, ...) function expects a std::string but is passed an Rml::String.

Patch for the samples
diff --git a/Samples/basic/svg/src/main.cpp b/Samples/basic/svg/src/main.cpp
index c0f5a797..7ad37699 100644
--- a/Samples/basic/svg/src/main.cpp
+++ b/Samples/basic/svg/src/main.cpp
@@ -115,7 +115,7 @@ int main(int /*argc*/, char** /*argv*/)
        Shell::LoadFonts();
 
        // Load and show the documents.
-       std::vector<std::string> rml_docs = {"basic/svg/data/svg_element.rml", "basic/svg/data/svg_decorator.rml", "basic/svg/data/svg_inline.rml"};
+       std::vector<Rml::String> rml_docs = {"basic/svg/data/svg_element.rml", "basic/svg/data/svg_decorator.rml", "basic/svg/data/svg_inline.rml"};
        for (const auto& rml_doc : rml_docs)
        {
                if (Rml::ElementDocument* document = context->LoadDocument(rml_doc))
diff --git a/Samples/basic/transform/src/main.cpp b/Samples/basic/transform/src/main.cpp
index e7eb7d7c..97445805 100644
--- a/Samples/basic/transform/src/main.cpp
+++ b/Samples/basic/transform/src/main.cpp
@@ -61,9 +61,7 @@ public:
 
                if (document && perspective > 0)
                {
-                       std::stringstream s;
-                       s << "perspective(" << perspective << "dp) ";
-                       document->SetProperty("transform", s.str());
+                       document->SetProperty("transform", Rml::CreateString("perspective(%fdp) ", perspective));
                }
        }
 
@@ -71,11 +69,11 @@ public:
        {
                if (document)
                {
-                       std::stringstream s;
+                       Rml::String s;
                        if (perspective > 0)
-                               s << "perspective(" << perspective << "dp) ";
-                       s << "rotate3d(0.0, 1.0, 0.0, " << degrees << "deg)";
-                       document->SetProperty("transform", s.str());
+                               s += Rml::CreateString("perspective(%fdp) ", perspective);
+                       s += Rml::CreateString("rotate3d(0.0, 1.0, 0.0, %fdeg)", degrees);
+                       document->SetProperty("transform", s);
                }
        }

@tretre91 tretre91 changed the title Fix compile issues in the SVGT when using the a non-std string typerelated to std::string use in the SVG plugin Fix compile issues in the SVG plugin when using a non-std string type Dec 28, 2025
@mikke89 mikke89 added the build Build system and compilation label Dec 28, 2025
@mikke89 mikke89 merged commit e5c8e5d into mikke89:master Dec 28, 2025
32 checks passed
@mikke89
Copy link
Owner

mikke89 commented Dec 28, 2025

Thanks a lot! Yeah, we don't have any tests for this so I expect they will keep needing some maintenance. Thanks for making these ones as you notice them.

Feel free to make a separate PR for the samples as well. It's not the highest priority but I'd happily accept a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Build system and compilation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants