User defined custom filter

This is a discussion on User defined custom filter within the C++ Programming forums, part of the General Programming Boards category; Hi All, I have a project to handle large data files, one of the features i would like to build ...

  1. #1
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,409

    User defined custom filter

    Hi All,

    I have a project to handle large data files, one of the features i would like to build in is a custom filter,
    For example the user selects their parameters and then adds logic before running the report.

    so they might choose 'region, value, average order value'

    and wish to add logic that says:

    If region EQUAL TO midlands AND value > 1000 AND average order value > 15

    How can i take that user input and add it into my code at runtime?

    Its new territory for me this kind of thing so am asking for suggestions on what i should be getting into to accomplish this.

    I have done some cursory searching but the results are leading me off at too many tangents, has anybody any direct links on this?

    Is it interpretation, expressions? lexical analysis? parsing? all of the above?

    Any advice appreciated!
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  2. #2
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,638
    Would it not be easier to make the data files into a database and do all of that with SQL?

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,207
    Well, it's interpretation of an expression. Lexical analysis (which breaks your string into a set of tokens like, say, "IF", "region", "EQUAL", etc) and parsing (the process of analysing text containing a set of tokens, formally known as "syntactic analysis") are tools to achieve that.

    Depending on your needs, you might want to use some form of regular expression library. There are lots of such libraries available (or even in the latest C++ standard, IIRC, if you have a compiler that supports it, although that might be jumping the gun).

    You might also wish to consider if your large data files can be inserted into a spreadsheet or database....
    Right 98% of the time, and don't care about the other 3%.

  4. #4
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,409
    Ok yea, might be worth looking into as an exercise then, the reason it was getting written rather than SQL or databse stuff is just to give a very simple interface for a couple of computer-phobic people to pull simple reports from the data, by wasy of therapy for them perhaps! the logic filter was a nice to have for any other user, there is no ms access installed on these machines but maybe we will just get open office base or summat
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  5. #5
    Registered User
    Join Date
    Oct 2006
    Posts
    2,294
    look into SQLite. it's free, open source, and pretty simple to use.

  6. #6
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,409
    That looks pretty cool i like it, there is a c++ interface, smashing
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. User defined cos function
    By zfite in forum C Programming
    Replies: 11
    Last Post: 04-03-2011, 02:40 AM
  2. User defined Variable name
    By mat429 in forum C Programming
    Replies: 4
    Last Post: 08-28-2008, 08:07 AM
  3. User defined functions
    By alexpos in forum C Programming
    Replies: 2
    Last Post: 10-23-2005, 02:53 PM
  4. New to user defined functions
    By Extropian in forum C Programming
    Replies: 4
    Last Post: 08-15-2005, 10:45 PM
  5. Replies: 7
    Last Post: 04-13-2003, 10:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21