1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

a design question in C++

Discussion in 'C++' started by vadi, Oct 12, 2009.

  1. vadi

    vadi New Member

    Joined:
    Oct 12, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    I get a request in the format of string. I have to parse this string, get to know what type of request it is and populate different fields in objects of corresponding request class. There are around 6 request classes. These request classses have some fields in common but not all. I want to do parsing the string and getting required fields at only one place and I do not want to repeat this in every request class. how can I achive this? By using which design pattern?
     
  2. vadi

    vadi New Member

    Joined:
    Oct 12, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    To further clarify things, I have a class known as RMG2BUF. The request string is parsed and it builds a tree structure, each node being of type RMG2NODE. RMG2BUF class provides a way of traversing this tree and getting the value of any required fields. Now these fields have to be mapped to particular field in objects of 6 different request classes that I told earlier. The different request classes like CreateTTRequest,ModifyTTRequest,CancelTTRequest etc share many common fields. I want to do the fetching of values from RMG2BUF at only one place and I do not want to repeat it in setting common fields of different requests. I want to create something like a utility class which provides functions to set all the fields comprising all the requests but it should set it in the the request class object that I have passed
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    Your problem is not very detailed and so having just a base class parser could help you.
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Can you give a couple of examples of the kinds of strings you want parsed?
    Also you mention "design pattern". What is that, exactly?
     

Share This Page