Re: [Quickfix-developers] catch getField business rejects
Brought to you by:
orenmnero
|
From: Dale W. <wil...@oc...> - 2005-11-22 20:08:24
|
Hi Caleb (et. al.)
Caleb Epstein wrote:
> On 11/22/05, *Reiner Nix* <rei...@ma...
> <mailto:rei...@ma...>> wrote:
>
> Having get and set method without throwing an exception but able
> to manage
> null values. So a setFieldXXX (null) should suppress submitting
> the value in
> the FIX message where getFieldXXX() for an unset value should
> return null.
>
>
> I don't think this particular interface would work in C++ (we're
> dealing with either FIX::FieldBase or std::string objects and there is
> no "null"). It would be possible to provide some additional
> getField/setField overloads in FieldMap that would do what you want
> though:
>
> namespace FIX {
>
> struct nothrow {};
>
> class FieldMap {
> ...
> bool getField (FieldBase& field, nothrow) // doesn't throw; returns
> true is hasField (field)
> bool getField (int field, std::string&) // doesn't throw, returns
> true if hasField (field)
>
Rather than overload based on a bool (or adding a bool with a default)
I'd much rather see:
bool getOptionalField(FieldBase& field);
This makes it much more obvious (to me anyway) when to use this method:
If the field is optional then it's not an exception for it to be missing.
That being said, I really like the idea, 'cause I'm certainly tired of
typing:
if(message.isSetField(filbert))
{
message.getField(filbert);
etc
}
> I can't really see the value in them, but these could also be added:
>
> bool setField (const FieldBase&, nothrow) // doesn't throw (and
> has no effect) if value is empty
> bool setField (int field, const std::string& value, nothrow) //
> same as above
Agreed, these don't make a whole lot of sense.
Dale
>
> If people really want these interfaces they'd be very simple to add.
>
> --
> Caleb Epstein
> caleb dot epstein at gmail dot com
--
-----------------------------------------------------
Dale Wilson, Senior Software Engineer
Object Computing, Inc. (OCI)
http://www.ociweb.com/ http://www.theaceorb.com/
----------------------------------------------------
|