OnixS C++ FIX Engine  4.12.0
API Documentation
FlatGroup.h
Go to the documentation of this file.
1 /*
2 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3 *
4 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5 * and international copyright treaties.
6 *
7 * Access to and use of the software is governed by the terms of the applicable OnixS Software
8 * Services Agreement (the Agreement) and Customer end user license agreements granting
9 * a non-assignable, non-transferable and non-exclusive license to use the software
10 * for it's own data processing purposes under the terms defined in the Agreement.
11 *
12 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13 * of this source code or associated reference material to any other location for further reproduction
14 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15 *
16 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17 * the terms of the Agreement is a violation of copyright law.
18 */
19 
20 #pragma once
21 
22 #include <iterator>
23 
26 
27 namespace OnixS {
28 namespace FIX {
29 ONIXS_FIXENGINE_API_DECL(class, FlatMessage);
30 ONIXS_FIXENGINE_API_DECL(class, FlatGroup);
31 
32 /// A single instance of the FIX Repeating Group. Provides an access
33 /// to the fields of a particular repeating group instance.
35 {
36 public:
37 
38  /// Looks for a field using the given tag number.
39  /// @return A valid reference in case of success, otherwise - an invalid one.
40  FlatFieldRef find(Tag) const;
41 
42  /// Provides an access to a field value by the given temporary reference.
43  StringRef operator[](const FlatFieldRef &) const;
44 
45  /// Returns the reference to a repeating group - if exists.
46  ///
47  /// @param numberOfInstancesRef A reference of
48  /// the field that defines the number of instances
49  /// in this repeating group (the NoXXX field).
50  ///
51  /// @throw std::exception if the given field does not contain the number of instances.
52  FlatGroup getGroup(const FlatFieldRef & numberOfInstancesRef) const;
53 
54 private:
55 
56  friend class MessageOperator;
57 
58  FlatGroupInstance(const FlatMessage *, const StringRef &, const FlatGroupInstance * parent);
59  FlatGroupInstance(const FlatMessage *, const FlatGroupInstance *, const FlatGroupInstance * parent);
60 
61  const FlatMessage * container_;
62  Tag parentLeadingTag_;
63  FlatField leadingField_;
64 };
65 
66 /// Encapsulates operations over the FIX Repeating Group.
67 ///
68 /// The repeating group represents an array of repeating group instances,
69 /// This class exposes corresponding services to manipulate the array
70 /// of repeating group instances. Similar to the OnixS::FIX::FlatGroupInstance
71 /// it behaves like a pointer/reference to the underlying data. It's
72 /// a light-weight object which just wraps the internal data.
73 ///
74 /// The group remains valid until corresponding group fields are updated.
76 {
77 public:
78 
79  /// Returns the number of instances in the repeating group.
80  size_t size() const { return groupSize_; }
81 
82  /// Returns the StringRef value of the repeating group field.
83  StringRef groupFieldValue() const { return StringRef(groupFieldValue_, groupFieldValueSize_); }
84 
85  /// The constant iterator to iterate over all group instances in the repeating group.
87  {
88  public:
89 
90  typedef std::forward_iterator_tag iterator_category;
92  typedef std::ptrdiff_t difference_type;
95 
96  /// Initializes an iterator by a first group instance from which you need to iterate.
97  ConstIterator(const FlatGroup *, size_t);
98 
99  const FlatGroupInstance & operator*() const {
100  return currentGroupInstance_;
101  }
102 
103  const FlatGroupInstance * operator->() const {
104  return &currentGroupInstance_;
105  }
106 
107  bool operator == (const ConstIterator &) const;
108  bool operator != (const ConstIterator &) const;
109 
110  ConstIterator & operator ++();
111 
112  private:
113  /// The FlatMessage instance to iterate.
114  const FlatGroup * container_;
115 
116  /// The current group instance index.
117  size_t currentGroupInstanceIndex_;
118 
119  /// The current group instance.
120  FlatGroupInstance currentGroupInstance_;
121  };
122 
123  /// Returns the iterator to the first group instance in the group.
124  ConstIterator begin() const;
125 
126  /// Returns the iterator to the group instance after the last one in the group.
127  ConstIterator end() const;
128 
129 private:
130 
131  friend class MessageOperator;
132 
134 
135  const FlatMessage * container_;
136 
137  const FlatGroupInstance * parent_;
138 
139  const char * groupFieldValue_;
140 
141  size_t groupFieldValueSize_;
142 
143  size_t groupSize_;
144 };
145 
146 }
147 }
std::forward_iterator_tag iterator_category
Definition: FlatGroup.h:90
const FlatGroupInstance & operator*() const
Definition: FlatGroup.h:99
StringRef groupFieldValue() const
Returns the StringRef value of the repeating group field.
Definition: FlatGroup.h:83
Represents a temporary reference to a field in an editable serialized message.
#define ONIXS_FIXENGINE_API
Definition: ABI.h:45
Provides an access to FIX fields from a flat (tag=value) message.
Definition: FlatMessage.h:109
Provides an efficient way of accessing text-based FIX field values.
Definition: StringRef.h:59
size_t size() const
Returns the number of instances in the repeating group.
Definition: FlatGroup.h:80
ONIXS_FIXENGINE_API_DECL(class, IEngineListener)
Field primary attributes (a tag and a reference to a value).
Definition: FlatMessage.h:61
unsigned Tag
Alias for tag numbers.
Definition: Tag.h:28
const FlatGroupInstance * operator->() const
Definition: FlatGroup.h:103
bool operator==(const FieldValueRef &ref, const std::string &str)
A single instance of the FIX Repeating Group.
Definition: FlatGroup.h:34
Encapsulates operations over the FIX Repeating Group.
Definition: FlatGroup.h:75
FlatGroupInstance & reference
Definition: FlatGroup.h:94
bool operator!=(const FieldValueRef &ref, const std::string &str)
The constant iterator to iterate over all group instances in the repeating group. ...
Definition: FlatGroup.h:86