a design question in C++

vadi's Avatar, Join Date: Oct 2009
Newbie Member

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?
vadi's Avatar, Join Date: Oct 2009
Newbie Member
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
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Your problem is not very detailed and so having just a base class parser could help you.
xpi0t0s's Avatar, Join Date: Aug 2004
Can you give a couple of examples of the kinds of strings you want parsed?
Also you mention "design pattern". What is that, exactly?