00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00046
00047 #ifndef __B2BITS_FIXGroup_h__
00048 #define __B2BITS_FIXGroup_h__
00049
00050 #include <string>
00051 #include "B2BITS_V12_Defines.h"
00052 #include "B2BITS_PubEngineDefines.h"
00053 #include <B2BITS_IntDefines.h>
00054 #include <B2BITS_Types.h>
00055 #include <B2BITS_AutoPtr.h>
00056
00057 namespace Engine
00058 {
00059 struct FIXFieldValue;
00060 class TagValue;
00061
00063 class V12_API FIXGroup
00064 {
00065 public:
00067 FIXGroup();
00068
00070 virtual ~FIXGroup();
00071
00076 virtual int size() const = 0;
00077
00082 virtual int leadingField() const = 0;
00083
00104 virtual const std::string* get(int tag, int index) const = 0;
00105
00120 virtual bool get(int tag, FIXFieldValue* value, int index) const = 0;
00121
00131 virtual bool set(int tag, const FIXFieldValue& value, int index) = 0;
00132
00146 virtual bool set(int tag, const std::string& value, int index) = 0;
00147
00160 virtual bool remove(int tag, int index) = 0;
00161
00170 virtual bool isSupported(int tag) const;
00171
00187 virtual FIXGroup* getGroup(int tag, int index) = 0;
00188 virtual FIXGroup const* getGroup(int tag, int index) const = 0;
00189
00203 static void release(FIXGroup* pGroup);
00204
00210 virtual FixFieldsContainer *getFields() const = 0;
00211
00223 virtual void release()const = 0;
00224
00226 void *operator new(size_t size);
00227
00229 void operator delete(void *obj);
00230
00231
00232 virtual void write(int tag, std::ostream& out, int index ) const = 0;
00233 virtual bool hasFlag(int tag, int index ) const = 0;
00234
00235 virtual System::i64 getAsInt64( int tag, int index ) const = 0;
00236 virtual System::u64 getAsUInt64( int tag, int index ) const = 0;
00237 virtual System::i32 getAsInt32( int tag, int index ) const = 0;
00238 virtual System::u32 getAsUInt32( int tag, int index ) const = 0;
00239 virtual int getAsInt( int tag, int index ) const = 0;
00240 virtual unsigned int getAsUInt( int tag, int index ) const = 0;
00241
00244 virtual double getAsDouble( int tag, int index ) const = 0;
00245 virtual Decimal getAsDecimal( int tag, int index ) const = 0;
00246
00249 virtual char getAsChar( int tag, int index ) const = 0;
00250
00253 virtual AsciiString getAsString( int tag, int index ) const = 0;
00254
00257 virtual ByteArray getAsRaw( int tag, int index ) const = 0;
00258
00261 virtual bool getAsBoolean( int tag, int index ) const = 0;
00262
00263 virtual Engine::MonthYear getAsMonthYear( int tag, int index ) const = 0;
00264 virtual Engine::LocalMktDate getAsLocalMktDate( int tag, int index ) const = 0;
00265 virtual Engine::UTCDateOnly getAsDateOnly( int tag, int index ) const = 0;
00266 virtual Engine::UTCTimeOnly getAsTimeOnly( int tag, int index ) const = 0;
00267 virtual Engine::UTCTimestamp getAsTimestamp( int tag, int index ) const = 0;
00268 virtual bool isEqual( int tag, int index, TagValue const* rv, int rvTag ) const = 0;
00269 virtual bool isEmpty( int tag, int index ) const = 0;
00270
00271
00285 virtual bool set( int tag, Engine::MonthYear value, int index ) = 0;
00286 virtual bool set( int tag, Engine::LocalMktDate value, int index ) = 0;
00287 virtual bool set( int tag, Engine::UTCDateOnly value, int index ) = 0;
00288 virtual bool set( int tag, Engine::UTCTimeOnly value, int index ) = 0;
00289 virtual bool set( int tag, Engine::UTCTimestamp value, int index ) = 0;
00290 virtual bool set( int tag, System::i32 value, int index ) = 0;
00291 virtual bool set( int tag, System::u32 value, int index ) = 0;
00292 virtual bool set( int tag, System::i64 value, int index ) = 0;
00293 virtual bool set( int tag, System::u64 value, int index ) = 0;
00294 virtual bool set( int tag, double value, int index ) = 0;
00295 virtual bool set( int tag, Decimal value, int index ) = 0;
00296 virtual bool set( int tag, AsciiString value, int index ) = 0;
00297 virtual bool set( int tag, ByteArray value, int index ) = 0;
00298 virtual bool set( int tag, char value, int index ) = 0;
00299 virtual bool set( int tag, bool value, int index ) = 0;
00300 bool set( int tag, char const* value, int index ) { return set( tag, AsciiString( value ), index ); }
00301 };
00302 }
00303
00304 namespace Utils{
00305
00307 template <>
00308 class AutoPtr<Engine::FIXGroup>
00309 {
00310 public:
00312 typedef void (Engine::FIXGroup::*ReleaseMethod)()const;
00313
00315 AutoPtr() : ptr_(NULL), releaseMethod_(NULL) { }
00316
00320 AutoPtr(const Engine::FIXGroup *ptr, ReleaseMethod releaseMethod) : ptr_(ptr), releaseMethod_(releaseMethod)
00321 {
00322 }
00323
00325 AutoPtr(AutoPtr<Engine::FIXGroup> & ptr)
00326 {
00327 reset(ptr.ptr_, ptr.releaseMethod_);
00328
00329 ptr.ptr_ = NULL;
00330 ptr.releaseMethod_ = NULL;
00331 }
00332
00334 AutoPtr & operator=(AutoPtr<Engine::FIXGroup> & ptr)
00335 {
00336 reset(ptr.ptr_, ptr.releaseMethod_);
00337
00338 ptr.ptr_ = NULL;
00339 ptr.releaseMethod_ = NULL;
00340
00341 return *this;
00342 }
00343
00345 ~AutoPtr()
00346 {
00347 if (ptr_ != NULL)
00348 (ptr_->*releaseMethod_)();
00349 }
00350
00353 Engine::FIXGroup *release()
00354 {
00355 releaseMethod_ = NULL;
00356
00357 Engine::FIXGroup *ptr = const_cast<Engine::FIXGroup *>(ptr_);
00358 ptr_ = NULL;
00359
00360 return ptr;
00361 }
00362
00366 void reset(const Engine::FIXGroup *ptr, ReleaseMethod releaseMethod)
00367 {
00368 if (ptr_ != NULL)
00369 (ptr_->*releaseMethod_)();
00370
00371 ptr_ = ptr;
00372 releaseMethod_ = releaseMethod;
00373 }
00374
00377 Engine::FIXGroup *get() const
00378 {
00379 return const_cast<Engine::FIXGroup *>(ptr_);
00380 }
00381
00383 Engine::FIXGroup & operator*()
00384 {
00385 return *const_cast<Engine::FIXGroup *>(ptr_);
00386 }
00387
00389 Engine::FIXGroup** operator&()
00390 {
00391 return const_cast<Engine::FIXGroup **>(&ptr_);
00392 }
00393
00395 Engine::FIXGroup *operator->()
00396 {
00397 return get();
00398 }
00399
00400 private:
00402 const Engine::FIXGroup *ptr_;
00403
00405 ReleaseMethod releaseMethod_;
00406 };
00407
00408 }
00409
00410
00411 #endif // __B2BITS_FIXGroup_h__