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

Related Questions

I have a CSV file. The first row will always contain column headers. Depending
First, I will try to describe what I am willing to do and then,
I need a regular expression that will match the first letter of a song
I want to define that the first element will be of a specific type,
First of all, I know the standard answer will be that exceptions are never
The problem that I am having is a little hard to describe, so please
I am facing a peculiar problem. I will describe in brief bellow Suppose i
I have an ASP.NET 4.0 site on IIS 7.0 that is having first time
The Problem Before I describe my current setup I will describe my problem. I
Let me first describe my situation. I have a list of Hex values, which

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.