Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   a design question in C++ (http://www.go4expert.com/forums/design-question-cpp-t19749/)

vadi 12Oct2009 16:12

a design question in C++

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 12Oct2009 16:29

Re: a design question in C++
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 12Oct2009 17:31

Re: a design question in C++
Your problem is not very detailed and so having just a base class parser could help you.

xpi0t0s 13Oct2009 13:18

Re: a design question in C++
Can you give a couple of examples of the kinds of strings you want parsed?
Also you mention "design pattern". What is that, exactly?

All times are GMT +5.5. The time now is 06:18.