Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9160571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:46:13+00:00 2026-06-17T13:46:13+00:00

I am rewriting our application using wxWidgets. One of the goals is to replace

  • 0

I am rewriting our application using wxWidgets. One of the goals is to replace our old approach to the localized strings. Another possible goal is to embed the Python interpreter to the application — but only later. Anyway, it would be nice any C/C++ code or library capable of Python-like string formatting that uses the curly braces.

If you do not know Python, here is the doc for its format function. You can find the reference to the Format Specification Mini-Language inside, and the Format examples. Some extract from the doc… (The >>> is a prompt of the interactive Python mode, the line below shows the result of the call. Python uses single or double quotes as a string delimiter):

>>> '{0}, {1}, {2}'.format('a', 'b', 'c')
'a, b, c'
>>> '{}, {}, {}'.format('a', 'b', 'c')  # 3.1+ only
'a, b, c'
>>> '{2}, {1}, {0}'.format('a', 'b', 'c')
'c, b, a'
>>> '{0}{1}{0}'.format('abra', 'cad')   # arguments' indices can be repeated
'abracadabra'

I would also like to use the Python formatting with the named placeholders (instead of numeric indices). In Python, the str.format_map(mapping) method of strings is used where the mapping is of the map<string, some_type> like type. Say, my_dictionary contains mapping like:

"name"    --> "Guido"
"country" --> "Netherlands"

Having a template string like below, I would like to get the result…

wxString template("{name} was born in {country}.");
wxString result(format_map(s, my_dictionary));

// the result should contain...
// "Guido was born in Netherlands."

Do you know any avaliable C or C++ code capable of that, or do I have to write my own?

Thanks for your time and experience,

Petr

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:46:14+00:00Added an answer on June 17, 2026 at 1:46 pm

    Yes. The fmt library uses format string syntax based on Python’s str.format. It supports most of the formatting options of str.format including named arguments. Here’s an example:

    std::string s = fmt::format("{0}{1}{0}", "abra", "cad");
    // s == "abracadabra"
    

    Disclaimer: I’m the author of this library.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have recently been rewriting our PHP application's model code using OO. We have
We're currently rewriting our organizations ASP.NET MVC application which has been written twice already.
I’m looking at rewriting a portion of our application in C# (currently legacy VB6
One of the user of our application has a xml named zean.xml file located
I'm rewriting one of our forms so that it can handle international domains, but
We're rewriting a website used by one of our clients. The user traffic on
We're rewriting a site using Rails, and the old site makes extensive use of
I am rewriting a big piece of our application which requires a user to
I'm in the process of rewriting our application. We are building DataMappers to work
I am looking in to implementing Url rewriting for our site, using the rewrite

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.