Home

Ian Collins a écrit :
> mosfet wrote:
>> Hi,
>>
>> In my project I am supposed to test if some HTTP headers belongs to a
>> know list of system headers so I wrote the following code.
>> I get a WebRequest class(ported from .net world) and a HttpWebRequest
>> deriving from it.
>> In my WebRequest I have some getters/setters defined like this
>> :
>>
>> typedef std::basic_string<TCHAR> tstring;
>>
> What's a TCHAR and isn't there an alternative standard type?
>
>> #define DECL_GET_PROP( PropName, Type ) \
>> Type& get_##PropName() { return m_##PropName; }
>>
> <snip>
>> class WebRequest
>> {
>> public:
>> ....
>> // Properties
>> virtual DECL_GETSET_PROP(Accept, tstring);
>
> <snip>
>
>> ....
>> };
>> I know macros are evil but in my case I find it useful, so the first
>> line for instance will be expanded as :
>> virtual tstring& get_Accept() { return m_Accept; }
>> virtual void set_Accept(tstring PropVal) {m_Accept = PropVal; }
>>
> It's not the macros that would bother me, its the presence of all the
> setter and getter methods, which tent to be indicative of a poor design.
>
>> The problem is my get/set methods don't have the same signature, for
>> instance Accept takes a string while ContentLength takes a long.
>> My question is how to solve this ?
>> Should I use delegated instaead of member function pointers ?
>>
> There you are, there is a problem with the design! You probably want to
> look at the factory pattern, with a process object for each header item,
> build a list of header objects for each message and process that.
>

It's not my design, tell Microsoft they have bad design in their .NET
languages.

previous
next

Re: Howto link a lib in my Makefile
Re: two classes #including each other
Re: Getting error zipimport.ZipImportError: can't decompress data;zlib not available
Re: Writing Scalabe Software in C++
Re: Creating a shared object in python
Akogo
Fundacja Avalon
Rodzic Po Ludzku
Krwinka
Podaruj Zycie