BLPAPI C++  3.21.0
blpapi_schema.h
Go to the documentation of this file.
1 /* Copyright 2012. Bloomberg Finance L.P.
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy
4  * of this software and associated documentation files (the "Software"), to
5  * deal in the Software without restriction, including without limitation the
6  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7  * sell copies of the Software, and to permit persons to whom the Software is
8  * furnished to do so, subject to the following conditions: The above
9  * copyright notice and this permission notice shall be included in all copies
10  * or substantial portions of the Software.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
18  * IN THE SOFTWARE.
19  */
20 
28 #ifndef INCLUDED_BLPAPI_SCHEMA
29 #define INCLUDED_BLPAPI_SCHEMA
30 
73 #ifndef INCLUDED_BLPAPI_CONSTANT
74 #include <blpapi_constant.h>
75 #endif
76 
77 #ifndef INCLUDED_BLPAPI_DEFS
78 #include <blpapi_defs.h>
79 #endif
80 
81 #ifndef INCLUDED_BLPAPI_EXCEPTION
82 #include <blpapi_exception.h>
83 #endif
84 
85 #ifndef INCLUDED_BLPAPI_NAME
86 #include <blpapi_name.h>
87 #endif
88 
89 #ifndef INCLUDED_BLPAPI_STREAMPROXY
90 #include <blpapi_streamproxy.h>
91 #endif
92 
93 #ifndef INCLUDED_BLPAPI_TYPES
94 #include <blpapi_types.h>
95 #endif
96 
98 
99 #ifdef __cplusplus
100 extern "C" {
101 #endif
102 
105  const blpapi_SchemaElementDefinition_t *field);
106 
109  const blpapi_SchemaElementDefinition_t *field);
110 
113  const blpapi_SchemaElementDefinition_t *field);
114 
117  const blpapi_SchemaElementDefinition_t *field);
118 
121  const blpapi_SchemaElementDefinition_t *field);
122 
125  const blpapi_SchemaElementDefinition_t *field, size_t index);
126 
127 // -- NOT USED or IMPLEMENTED: removing
128 // BLPAPI_EXPORT
129 // size_t blpapi_SchemaElementDefinition_numNames(
130 // const blpapi_SchemaElementDefinition_t *field);
131 
134  const blpapi_SchemaElementDefinition_t *field);
135 
138  const blpapi_SchemaElementDefinition_t *field);
139 
142  const blpapi_SchemaElementDefinition_t *element,
143  blpapi_StreamWriter_t streamWriter,
144  void *userStream,
145  int level,
146  int spacesPerLevel);
147 
150  blpapi_SchemaElementDefinition_t *field, void *userdata);
151 
154  const blpapi_SchemaElementDefinition_t *field);
155 
158  const blpapi_SchemaTypeDefinition_t *type);
159 
162  const blpapi_SchemaTypeDefinition_t *type);
163 
166  const blpapi_SchemaTypeDefinition_t *type);
167 
170  const blpapi_SchemaTypeDefinition_t *type);
171 
174  const blpapi_SchemaTypeDefinition_t *type);
175 
178  const blpapi_SchemaTypeDefinition_t *type);
179 
182  const blpapi_SchemaTypeDefinition_t *type);
183 
186  const blpapi_SchemaTypeDefinition_t *type);
187 
190  const blpapi_SchemaTypeDefinition_t *type);
191 
194  const blpapi_SchemaTypeDefinition_t *type);
195 
198  const blpapi_SchemaTypeDefinition_t *type);
199 
203  const blpapi_SchemaTypeDefinition_t *type,
204  const char *nameString,
205  const blpapi_Name_t *name);
206 
210  const blpapi_SchemaTypeDefinition_t *type, size_t index);
211 
214  const blpapi_SchemaTypeDefinition_t *element,
215  blpapi_StreamWriter_t streamWriter,
216  void *userStream,
217  int level,
218  int spacesPerLevel);
219 
222  blpapi_SchemaTypeDefinition_t *element, void *userdata);
223 
226  const blpapi_SchemaTypeDefinition_t *element);
227 
230  const blpapi_SchemaTypeDefinition_t *element);
231 
232 #ifdef __cplusplus
233 }
234 
235 #ifndef INCLUDED_IOSFWD
236 #include <iosfwd>
237 #define INCLUDED_IOSFWD
238 #endif
239 
247 namespace BloombergLP {
248 namespace blpapi {
249 
257 struct SchemaStatus {
258 
259  enum Value {
262 
266 
269 
273  };
274 };
275 
276 class SchemaTypeDefinition;
277 
328 
330 
331  public:
332  /*
333  * Constants used in the SchemaElementDefinition interface.
334  */
335 
336  enum {
339  };
340 
342 
348  void setUserData(void *userData);
358  Name name() const;
364  const char *description() const;
371  int status() const;
377  const SchemaTypeDefinition typeDefinition() const;
382  size_t minValues() const;
388  size_t maxValues() const;
394  size_t numAlternateNames() const;
399  Name getAlternateName(size_t index) const;
406  void *userData() const;
420  std::ostream& print(
421  std::ostream& stream, int level = 0, int spacesPerLevel = 4) const;
436 };
437 
472 
474 
475  public:
477 
483  // MANIPULATORS
484 
485  void setUserData(void *userData);
494  // ACCESSORS
495 
496  int datatype() const;
504  Name name() const;
509  const char *description() const;
517  int status() const;
523  size_t numElementDefinitions() const;
531  bool isComplexType() const;
537  bool isSimpleType() const;
543  bool isEnumerationType() const;
549  bool hasElementDefinition(const Name& name) const;
556  bool hasElementDefinition(const char *name) const;
570  SchemaElementDefinition getElementDefinition(const char *nameString) const;
577  SchemaElementDefinition getElementDefinition(size_t index) const;
584  const ConstantList enumeration() const;
591  void *userData() const;
605  std::ostream& print(
606  std::ostream& stream, int level = 0, int spacesPerLevel = 4) const;
619 };
620 
624 // FREE OPERATORS
625 
626 std::ostream& operator<<(
627  std::ostream& stream, const SchemaElementDefinition& element);
640 std::ostream& operator<<(
641  std::ostream& stream, const SchemaTypeDefinition& typeDef);
654 // ============================================================================
655 // INLINE FUNCTION DEFINITIONS
656 // ============================================================================
657 
658 // -----------------------------
659 // class SchemaElementDefinition
660 // -----------------------------
661 
664  : d_impl_p(handle)
665 {
666 }
667 
669 
671 {
672  return Name(blpapi_SchemaElementDefinition_name(d_impl_p));
673 }
674 
675 inline const char *SchemaElementDefinition::description() const
676 {
678 }
679 
681 {
682  return blpapi_SchemaElementDefinition_status(d_impl_p);
683 }
684 
685 inline const SchemaTypeDefinition
687 {
688  return blpapi_SchemaElementDefinition_type(d_impl_p);
689 }
690 
692 {
694 }
695 
697 {
699 }
700 
702 {
704 }
705 
707 {
708  blpapi_Name_t *alternateName
710  if (alternateName == 0) {
712  }
713  return alternateName;
714 }
715 
716 inline std::ostream& SchemaElementDefinition::print(
717  std::ostream& stream, int level, int spacesPerLevel) const
718 {
721  &stream,
722  level,
723  spacesPerLevel);
724  return stream;
725 }
726 
727 inline std::ostream& operator<<(
728  std::ostream& stream, const SchemaElementDefinition& element)
729 {
730  element.print(stream, 0, -1);
731  return stream;
732 }
733 
734 inline void SchemaElementDefinition::setUserData(void *newUserData)
735 {
736  blpapi_SchemaElementDefinition_setUserData(d_impl_p, newUserData);
737 }
738 
740 {
742 }
743 
745 {
746  return d_impl_p;
747 }
748 // --------------------------
749 // class SchemaTypeDefinition
750 // --------------------------
751 
754  : d_impl_p(handle)
755 {
756 }
757 
759 
761 {
762  return blpapi_SchemaTypeDefinition_datatype(d_impl_p);
763 }
764 
766 {
767  return blpapi_SchemaTypeDefinition_name(d_impl_p);
768 }
769 
770 inline const char *SchemaTypeDefinition::description() const
771 {
773 }
774 
776 {
777  return blpapi_SchemaTypeDefinition_status(d_impl_p);
778 }
779 
781 {
783 }
784 
786  const Name& elementName) const
787 {
789  d_impl_p, 0, elementName.impl())
790  ? true
791  : false;
792 }
793 
795  const char *nameString) const
796 {
798  d_impl_p, nameString, 0)
799  ? true
800  : false;
801 }
802 
804  const Name& elementName) const
805 {
808  d_impl_p, 0, elementName.impl());
809  if (def == 0) {
811  }
812  return def;
813 }
814 
816  const char *nameString) const
817 {
820  d_impl_p, nameString, 0);
821  if (def == 0) {
823  }
824  return def;
825 }
826 
828  size_t index) const
829 {
832  d_impl_p, index);
833  if (def == 0) {
835  }
836  return def;
837 }
838 
840 {
841  return blpapi_SchemaTypeDefinition_isComplexType(d_impl_p) ? true : false;
842 }
843 
845 {
846  return blpapi_SchemaTypeDefinition_isSimpleType(d_impl_p) ? true : false;
847 }
848 
850 {
851  return blpapi_SchemaTypeDefinition_isEnumerationType(d_impl_p) ? true
852  : false;
853 }
854 
855 inline std::ostream& SchemaTypeDefinition::print(
856  std::ostream& stream, int level, int spacesPerLevel) const
857 {
860  &stream,
861  level,
862  spacesPerLevel);
863  return stream;
864 }
865 
866 inline std::ostream& operator<<(
867  std::ostream& stream, const SchemaTypeDefinition& typeDef)
868 {
869  typeDef.print(stream, 0, -1);
870  return stream;
871 }
872 
873 inline void SchemaTypeDefinition::setUserData(void *newUserData)
874 {
875  blpapi_SchemaTypeDefinition_setUserData(d_impl_p, newUserData);
876 }
877 
878 inline void *SchemaTypeDefinition::userData() const
879 {
880  return blpapi_SchemaTypeDefinition_userData(d_impl_p);
881 }
882 
884 {
886 }
887 
888 } // close namespace blpapi
889 } // close namespace BloombergLP
890 
891 #endif // #ifdef __cplusplus
892 
893 #endif // #ifndef INCLUDED_BLPAPI_SCHEMA
int blpapi_SchemaTypeDefinition_isSimple(const blpapi_SchemaTypeDefinition_t *type)
SchemaElementDefinition getElementDefinition(const Name &name) const
Definition: blpapi_schema.h:803
blpapi_SchemaElementDefinition_t * blpapi_SchemaTypeDefinition_getElementDefinitionAt(const blpapi_SchemaTypeDefinition_t *type, size_t index)
int datatype() const
Definition: blpapi_schema.h:760
blpapi_SchemaTypeDefinition_t * blpapi_SchemaElementDefinition_type(const blpapi_SchemaElementDefinition_t *field)
int blpapi_SchemaTypeDefinition_isSimpleType(const blpapi_SchemaTypeDefinition_t *type)
bool isComplexType() const
Definition: blpapi_schema.h:839
size_t blpapi_SchemaTypeDefinition_numElementDefinitions(const blpapi_SchemaTypeDefinition_t *type)
std::ostream & print(std::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition: blpapi_schema.h:855
#define BLPAPI_ELEMENTDEFINITION_UNBOUNDED
Definition: blpapi_defs.h:114
Common definitions used by the library.
SchemaTypeDefinition(blpapi_SchemaTypeDefinition_t *handle)
Definition: blpapi_schema.h:752
void * userData() const
Definition: blpapi_schema.h:878
Definition: blpapi_abstractsession.h:215
#define BLPAPI_STATUS_ACTIVE
Definition: blpapi_defs.h:98
blpapi_SchemaElementDefinition_t * blpapi_SchemaTypeDefinition_getElementDefinition(const blpapi_SchemaTypeDefinition_t *type, const char *nameString, const blpapi_Name_t *name)
int blpapi_SchemaTypeDefinition_isComplex(const blpapi_SchemaTypeDefinition_t *type)
size_t blpapi_SchemaElementDefinition_numAlternateNames(const blpapi_SchemaElementDefinition_t *field)
void blpapi_SchemaElementDefinition_setUserData(blpapi_SchemaElementDefinition_t *field, void *userdata)
Definition: blpapi_name.h:150
Definition: blpapi_constant.h:396
const SchemaTypeDefinition typeDefinition() const
Definition: blpapi_schema.h:686
#define BLPAPI_STATUS_INACTIVE
Definition: blpapi_defs.h:100
Name name() const
Definition: blpapi_schema.h:670
const char * blpapi_SchemaTypeDefinition_description(const blpapi_SchemaTypeDefinition_t *type)
bool isSimpleType() const
Definition: blpapi_schema.h:844
blpapi_Name_t * blpapi_SchemaElementDefinition_getAlternateName(const blpapi_SchemaElementDefinition_t *field, size_t index)
#define BLPAPI_STATUS_DEPRECATED
Definition: blpapi_defs.h:99
blpapi_Name_t * impl() const
Definition: blpapi_name.h:403
struct blpapi_Name blpapi_Name_t
Definition: blpapi_types.h:154
int blpapi_SchemaTypeDefinition_isEnumerationType(const blpapi_SchemaTypeDefinition_t *type)
std::ostream & print(std::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition: blpapi_schema.h:716
const ConstantList enumeration() const
Definition: blpapi_schema.h:883
Definition: blpapi_schema.h:327
size_t blpapi_SchemaElementDefinition_minValues(const blpapi_SchemaElementDefinition_t *field)
Provide a representation for schema-level enumeration constants.
int(* blpapi_StreamWriter_t)(const char *data, int length, void *stream)
Definition: blpapi_streamproxy.h:53
size_t numElementDefinitions() const
Definition: blpapi_schema.h:780
Value
Definition: blpapi_schema.h:259
int status() const
Definition: blpapi_schema.h:680
int blpapi_SchemaTypeDefinition_isComplexType(const blpapi_SchemaTypeDefinition_t *type)
#define BLPAPI_ERROR_ITEM_NOT_FOUND
Definition: blpapi_error.h:78
~SchemaTypeDefinition()
Definition: blpapi_schema.h:758
void * userData() const
Definition: blpapi_schema.h:739
struct blpapi_SchemaElementDefinition blpapi_SchemaElementDefinition_t
Definition: blpapi_types.h:191
int blpapi_SchemaTypeDefinition_status(const blpapi_SchemaTypeDefinition_t *type)
void setUserData(void *userData)
Definition: blpapi_schema.h:873
static void throwOnError(int errorCode)
Definition: blpapi_exception.h:526
struct blpapi_ConstantList blpapi_ConstantList_t
Definition: blpapi_types.h:133
blpapi_Name_t * blpapi_SchemaTypeDefinition_name(const blpapi_SchemaTypeDefinition_t *type)
~SchemaElementDefinition()
Definition: blpapi_schema.h:668
This item is not current and will not appear in Messages.
Definition: blpapi_schema.h:267
int blpapi_SchemaElementDefinition_print(const blpapi_SchemaElementDefinition_t *element, blpapi_StreamWriter_t streamWriter, void *userStream, int level, int spacesPerLevel)
Definition: blpapi_schema.h:263
This item is current and may appear in Messages.
Definition: blpapi_schema.h:260
void * blpapi_SchemaTypeDefinition_t
Definition: blpapi_schema.h:97
std::ostream & operator<<(std::ostream &os, const CorrelationId &correlator)
Definition: blpapi_correlationid.h:592
blpapi_ConstantList_t * blpapi_SchemaTypeDefinition_enumeration(const blpapi_SchemaTypeDefinition_t *element)
size_t minValues() const
Definition: blpapi_schema.h:691
Indicates an array has an unbounded number of values.
Definition: blpapi_schema.h:337
void blpapi_SchemaTypeDefinition_setUserData(blpapi_SchemaTypeDefinition_t *element, void *userdata)
bool hasElementDefinition(const Name &name) const
Definition: blpapi_schema.h:785
const char * blpapi_SchemaElementDefinition_description(const blpapi_SchemaElementDefinition_t *field)
const char * description() const
Definition: blpapi_schema.h:675
int status() const
Definition: blpapi_schema.h:775
SchemaElementDefinition(blpapi_SchemaElementDefinition_t *handle)
Definition: blpapi_schema.h:662
A signature for callback on print and default C++ implementation.
void * blpapi_SchemaTypeDefinition_userData(const blpapi_SchemaTypeDefinition_t *element)
int blpapi_SchemaTypeDefinition_isEnumeration(const blpapi_SchemaTypeDefinition_t *type)
blpapi_SchemaElementDefinition_t * impl() const
Definition: blpapi_schema.h:744
int blpapi_SchemaElementDefinition_status(const blpapi_SchemaElementDefinition_t *field)
int blpapi_SchemaTypeDefinition_print(const blpapi_SchemaTypeDefinition_t *element, blpapi_StreamWriter_t streamWriter, void *userStream, int level, int spacesPerLevel)
size_t numAlternateNames() const
Definition: blpapi_schema.h:701
void setUserData(void *userData)
Definition: blpapi_schema.h:734
Defines Exceptions that can be thrown by the blpapi library.
#define BLPAPI_ERROR_INDEX_OUT_OF_RANGE
Definition: blpapi_error.h:76
void * blpapi_SchemaElementDefinition_userData(const blpapi_SchemaElementDefinition_t *field)
Definition: blpapi_schema.h:257
const char * description() const
Definition: blpapi_schema.h:770
static int writeToStream(const char *data, int length, void *stream)
Definition: blpapi_streamproxy.h:93
Name name() const
Definition: blpapi_schema.h:765
Name getAlternateName(size_t index) const
Definition: blpapi_schema.h:706
#define BLPAPI_EXPORT
Definition: blpapi_defs.h:171
size_t blpapi_SchemaElementDefinition_maxValues(const blpapi_SchemaElementDefinition_t *field)
size_t maxValues() const
Definition: blpapi_schema.h:696
blpapi_Name_t * blpapi_SchemaElementDefinition_name(const blpapi_SchemaElementDefinition_t *field)
Definition: blpapi_schema.h:471
Provide BLPAPI types.
#define BLPAPI_STATUS_PENDING_DEPRECATION
Definition: blpapi_defs.h:101
Provide a representation of strings for use as container keys.
int blpapi_SchemaTypeDefinition_datatype(const blpapi_SchemaTypeDefinition_t *type)
bool isEnumerationType() const
Definition: blpapi_schema.h:849