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 147763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:50:18+00:00 2026-05-11T08:50:18+00:00

I will first describe the problem and then what I currently look at, in

  • 0

I will first describe the problem and then what I currently look at, in terms of libraries.

In my application, we have a set of variables that are always available. For example: TOTAL_ITEMS, PRICE, CONTRACTS, ETC (we have around 15 of them). A clients of the application would like to have certain calculations performed and displayed, using those variables. Up until now, I have been constantly adding those calculations to the app. It’s pain in the butt, and I would like to make it more generic by way of creating a template, where the user can specify a set of formulas that the application will parse and calculate.

Here is one case:

total_cost = CONTRACTS*PRICE*TOTAL_ITEMS 

So, want to do something like that for the user to define in the template file:

total_cost = CONTRACTS*PRICE*TOTAL_ITEMS and some meta-date, like screen to display it on. Hence they will be specifying the formula with a screen. And the file will contain many formulas of this nature.

Right now, I am looking at two libraies: Spirit and matheval

Would anyone make recommendations what’s better for this task, as well as references, examples, links?

Please let me know if the question is unclear, and I will try to further clarify it .

Thanks,

Sasha

  • 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. 2026-05-11T08:50:19+00:00Added an answer on May 11, 2026 at 8:50 am

    If you have a fixed number of variables it may be a bit overkill to invoke a parser. Though Spirit is cool and I’ve been wanting to use it in a project.

    I would probably just tokenize the string, make a map of your variables keyed by name (assuming all your variables are ints):

    map<const char*,int*> vars; vars['CONTRACTS'] = &contracts; ... 

    Then use a simple postfix calculator function to do the actual math.

    Edit:

    Looking at MathEval, it seems to do exactly what you want; set variables and evaluate mathematical functions using those variables. I’m not sure why you would want to create a solution at the level of a syntax parser. Do you have any requirements that MathEval does not fulfill?

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

Sidebar

Ask A Question

Stats

  • Questions 65k
  • Answers 65k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer None of those answers are close to what you want.… May 11, 2026 at 11:14 am
  • added an answer I haven't done vba for Excel in a long time,… May 11, 2026 at 11:14 am
  • added an answer Fundamentally, WCF messages are XML, since the S.S.C.Message class uses… May 11, 2026 at 11:14 am

Related Questions

Why are circular references in Visual Studio a bad practice? First, I will describe
With :limit in query, I will get first N records. What is the easiest
I am preparing to use continuous integration for the first time. I will be
First of all, I will admit I am a novice to web services, although
When upgrading MySQL, I first create a backup of the database. Then I will
I am trying to write a JavaScript function that will return its first argument(function)
I am writing my first project that will use autoconf and teaching it to
I will preface this question by saying, I do not think it is solvable.
I will choose Java as an example, most people know it, though every other
I will be entering my third year of university in my next academic year,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.