ThingWorx C SDK
twInfoTable.h
Go to the documentation of this file.
1 /*************************************
2  * Copyright (C) 2015 ThingWorx Inc. *
3  *************************************/
4 
11 #include "twOSPort.h"
12 #include "twBaseTypes.h"
13 #include "twList.h"
14 
15 #ifndef TW_INFOTABLE_H
16 #define TW_INFOTABLE_H
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 struct cJSON;
23 
31 typedef struct twDataShapeAspect {
32  char * name;
35 
50 twDataShapeAspect * twDataShapeAspect_Create(const char * name, twPrimitive * value);
51 
66 
75 void twDataShapeAspect_Delete(void * aspect);
76 
84 typedef struct twDataShapeEntry {
85  char * name;
86  char * description;
87  enum BaseType type;
90 
104 twDataShapeEntry * twDataShapeEntry_Create(const char * name, const char * description, enum BaseType type);
105 
119 
129 void twDataShapeEntry_Delete(void * entry);
130 
147 int twDataShapeEntry_AddAspect(struct twDataShapeEntry * entry, const char * name, twPrimitive * value);
148 
160 uint32_t twDataShapeEntry_GetLength(struct twDataShapeEntry * entry);
161 
175 int twDataShapeEntry_ToStream(struct twDataShapeEntry * entry, twStream * s);
176 
184 typedef struct twDataShape {
187  char * name;
188 } twDataShape;
189 
204 
217 
227 void twDataShape_Delete(void * ds);
228 
240 uint32_t twDataShape_GetLength(struct twDataShape * ds);
241 
251 int twDataShape_ToStream(struct twDataShape * ds, twStream * s);
252 
265 int twDataShape_SetName(struct twDataShape * ds, char * name);
266 
280 int twDataShape_AddEntry(struct twDataShape * ds, struct twDataShapeEntry * entry);
281 
293 int twDataShape_GetEntryIndex(struct twDataShape * ds, const char * name, int * index);
294 
302 typedef struct twInfoTableRow {
303  uint16_t numFields;
306 
320 
333 
343 void twInfoTableRow_Delete(void * row);
344 
355 
369 
383 
396 
410 
418 typedef struct twInfoTable {
421  uint32_t length;
423 } twInfoTable;
424 
438 
451 
461 void twInfoTable_Delete(void * it);
462 
479 
499 
511 
526 
543 
554 
574 twInfoTable * twInfoTable_CreateFromPrimitive(const char * name, twPrimitive * value);
575 
593 twInfoTable * twInfoTable_CreateFromString(const char * name, char * value, char duplicate);
594 
608 twInfoTable * twInfoTable_CreateFromNumber(const char * name, double value);
609 
623 twInfoTable * twInfoTable_CreateFromInteger(const char * name, int32_t value);
624 
641 twInfoTable * twInfoTable_CreateFromLocation(const char * name, twLocation * value);
642 
665 twInfoTable * twInfoTable_CreateFromBlob(const char * name, char * value, int32_t length, char isImage, char duplicate);
666 
681 twInfoTable * twInfoTable_CreateFromDatetime(const char * name, DATETIME value);
682 
697 twInfoTable * twInfoTable_CreateFromBoolean(const char * name, char value);
698 
716 int twInfoTable_GetString(twInfoTable * it, const char * name, int32_t row, char ** value);
717 
732 int twInfoTable_GetNumber(twInfoTable * it, const char * name, int32_t row, double * value);
746 int twInfoTable_GetInteger(twInfoTable * it, const char * name, int32_t row, int32_t * value);
747 
761 int twInfoTable_GetLocation(twInfoTable * it, const char * name, int32_t row, twLocation * value);
762 
776 int twInfoTable_GetBlob(twInfoTable * it, const char * name, int32_t row, char ** value, int32_t * length);
777 
791 int twInfoTable_GetDatetime(twInfoTable * it, const char * name, int32_t row, DATETIME * value);
792 
806 int twInfoTable_GetBoolean(twInfoTable * it, const char * name, int32_t row, char * value);
807 
821 int twInfoTable_GetPrimitive(twInfoTable * it, const char * name, int32_t row, twPrimitive ** value);
822 
850 twInfoTable * twInfoTable_CreateFromJson(struct cJSON * json, char * singleEntryName);
851 
861 struct cJSON * twDataShape_ToJson(twDataShape * ds, struct cJSON * parent);
862 
877 struct cJSON * twInfoTable_ToJson(twInfoTable * it);
878 
879 #ifdef __cplusplus
880 }
881 #endif
882 
883 #endif
int twInfoTable_GetNumber(twInfoTable *it, const char *name, int32_t row, double *value)
Helper function to retrieve a TW_NUMBER from a twInfoTable.
Definition: twInfoTable.c:802
twInfoTable * twInfoTable_CreateFromString(const char *name, char *value, char duplicate)
Helper function to create a twInfoTable with a single field and single row containing a TW_STRING...
Definition: twInfoTable.c:734
int twDataShape_ToStream(struct twDataShape *ds, twStream *s)
Serializes a twDataShape to a twStream.
Definition: twInfoTable.c:362
twInfoTable * twInfoTable_CreateFromJson(struct cJSON *json, char *singleEntryName)
Helper function that creates a twInfoTable from a cJSON object. If the JSON object does not represent...
Definition: twInfoTable.c:951
char * name
Definition: twInfoTable.h:32
void twDataShapeAspect_Delete(void *aspect)
Frees all memory associated with a twDataShapeAspect and all its owned substructures.
Definition: twInfoTable.c:52
twInfoTable * twInfoTable_CreateFromInteger(const char *name, int32_t value)
Helper function to create a twInfoTable with a single field and single row containing a TW_INTEGER...
Definition: twInfoTable.c:742
int twInfoTable_GetInteger(twInfoTable *it, const char *name, int32_t row, int32_t *value)
Helper function to retrieve a TW_INTEGER from a twInfoTable.
Definition: twInfoTable.c:809
twDataShape * ds
Definition: twInfoTable.h:419
twPrimitive * twInfoTableRow_GetEntry(twInfoTableRow *row, int index)
Gets the twPrimitive value of an entry in a twInfoTableRow.
Definition: twInfoTable.c:497
int twInfoTable_GetLocation(twInfoTable *it, const char *name, int32_t row, twLocation *value)
Helper function to retrieve a TW_LOCATION from a twInfoTable.
Definition: twInfoTable.c:816
struct twInfoTableRow twInfoTableRow
Info table row structure.
twDataShape * twDataShape_Create(twDataShapeEntry *firstEntry)
Creates a new twDataShape structure.
Definition: twInfoTable.c:235
void twDataShapeEntry_Delete(void *entry)
Frees all memory associated with a twDataShapeEntry structure and all its owned substructures.
Definition: twInfoTable.c:146
int twInfoTableRow_ToStream(twInfoTableRow *row, twStream *s)
Serializes a twInfoTableRow to a twStream.
Definition: twInfoTable.c:508
int twInfoTable_AddRow(twInfoTable *it, twInfoTableRow *row)
Adds a twInfoTableRow to a twInfoTable.
Definition: twInfoTable.c:670
uint32_t twDataShape_GetLength(struct twDataShape *ds)
Retrieves the length of a twDataShape.
Definition: twInfoTable.c:317
twList * entries
Definition: twInfoTable.h:186
twDataShape * twDataShape_CreateFromStream(struct twStream *s)
Creates a new twDataShape structure from data in a twStream.
Definition: twInfoTable.c:258
struct cJSON * twDataShape_ToJson(twDataShape *ds, struct cJSON *parent)
Helper function that outputs a twDataShape to a cJSON object.
Definition: twInfoTable.c:884
void twInfoTableRow_Delete(void *row)
Deletes a twInfoTableRow structure and frees all memory associated with it.
Definition: twInfoTable.c:452
int twDataShape_GetEntryIndex(struct twDataShape *ds, const char *name, int *index)
Gets the index of the twDataShapeEntry with the specified name.
Definition: twInfoTable.c:335
char * name
Definition: twInfoTable.h:187
int twDataShape_SetName(struct twDataShape *ds, char *name)
Sets the name of a twDataShape.
Definition: twInfoTable.c:296
twInfoTableRow * twInfoTableRow_Create(twPrimitive *firstEntry)
Creates a new twInfoTableRow.
Definition: twInfoTable.c:381
int twInfoTableRow_GetCount(twInfoTableRow *row)
Gets the number of fields in a twInfoTableRow.
Definition: twInfoTable.c:462
twInfoTable * twInfoTable_CreateFromDatetime(const char *name, DATETIME value)
Helper function to create a twInfoTable with a single field and single row containing a TW_DATETIME...
Definition: twInfoTable.c:754
#define TW_MUTEX
For Linux builds a TW_MUTEX is a pthread_mutex_t.
Definition: twLinux-openssl.h:81
twList * rows
Definition: twInfoTable.h:420
twPrimitive * value
Definition: twInfoTable.h:33
TW_MUTEX mtx
Definition: twInfoTable.h:422
int twInfoTable_ToStream(twInfoTable *it, twStream *s)
Serializes a twInfoTable to a twStream.
Definition: twInfoTable.c:695
struct twDataShapeAspect twDataShapeAspect
Data shape aspect structure definition.
struct twDataShape twDataShape
Data shape base structure definition.
Dynamically allocated byte array. Automatically expands its length as needed.
Definition: twBaseTypes.h:35
int numEntries
Definition: twInfoTable.h:185
uint16_t numFields
Definition: twInfoTable.h:303
twDataShapeEntry * twDataShapeEntry_CreateFromStream(struct twStream *s)
Creates a new twDataShapeEntry structure from data in a twStream.
Definition: twInfoTable.c:87
Wrappers for OS-specific functionality.
Linked list structure definition.
Definition: twList.h:46
int twInfoTable_Compare(twInfoTable *p1, twInfoTable *p2)
Compares two twInfoTable structures for equivalence.
Definition: twInfoTable.c:642
int twDataShapeEntry_ToStream(struct twDataShapeEntry *entry, twStream *s)
Serializes a twDataShapeEntry to a twStream.
Definition: twInfoTable.c:194
twDataShapeAspect * twDataShapeAspect_Create(const char *name, twPrimitive *value)
Creates a new twDataShapeAspect structure.
Definition: twInfoTable.c:16
void twDataShape_Delete(void *ds)
Frees all memory associated with a twDataShape structure and all its owned substructures.
Definition: twInfoTable.c:284
uint32_t twDataShapeEntry_GetLength(struct twDataShapeEntry *entry)
Retrieves the length of a twDataShapeEntry.
Definition: twInfoTable.c:164
int twInfoTable_GetBoolean(twInfoTable *it, const char *name, int32_t row, char *value)
Helper function to retrieve a TW_BOOLEAN from a twInfoTable.
Definition: twInfoTable.c:839
twInfoTable * twInfoTable_CreateFromNumber(const char *name, double value)
Helper function to create a twInfoTable with a single field and single row containing a TW_NUMBER...
Definition: twInfoTable.c:738
twDataShapeAspect * twDataShapeAspect_CreateFromStream(twStream *s)
Creates a new twDataShapeAspect structure from data in a twStream.
Definition: twInfoTable.c:32
void twInfoTable_Delete(void *it)
Frees all memory associated with a twInfoTable structure and all its owned substructures.
Definition: twInfoTable.c:627
twList * fieldEntries
Definition: twInfoTable.h:304
int twInfoTableRow_AddEntry(twInfoTableRow *row, twPrimitive *entry)
Adds a new twPrimitive to a twInfoTableRow.
Definition: twInfoTable.c:487
twInfoTable * twInfoTable_CreateFromLocation(const char *name, twLocation *value)
Helper function to create a twInfoTable with a single field and single row containing a TW_LOCATION...
Definition: twInfoTable.c:746
twInfoTable * twInfoTable_FullCopy(twInfoTable *it)
Creates a new twInfoTable structure and copies all data from an existing twInfoTable structure to the...
Definition: twInfoTable.c:597
DataShape entry structure definition.
Definition: twInfoTable.h:84
twDataShapeEntry * twDataShapeEntry_Create(const char *name, const char *description, enum BaseType type)
Creates a new twDataShapeEntry structure.
Definition: twInfoTable.c:64
Data shape base structure definition.
Definition: twInfoTable.h:184
twInfoTable * twInfoTable_CreateFromPrimitive(const char *name, twPrimitive *value)
Helper function to create a twInfoTable with a single field and single row containing a type and valu...
Definition: twInfoTable.c:717
ThingWorx BaseType definitions and functions.
struct twDataShapeEntry twDataShapeEntry
DataShape entry structure definition.
uint32_t length
Definition: twInfoTable.h:421
twList * aspects
Definition: twInfoTable.h:88
struct cJSON * twInfoTable_ToJson(twInfoTable *it)
Helper function that outputs a twInfoTable to a cJSON object.
Definition: twInfoTable.c:1109
twInfoTable * twInfoTable_CreateFromBoolean(const char *name, char value)
Helper function to create a twInfoTable with a single field and single row containing a TW_BOOLEAN...
Definition: twInfoTable.c:758
Info table base structure.
Definition: twInfoTable.h:418
twInfoTable * twInfoTable_CreateFromBlob(const char *name, char *value, int32_t length, char isImage, char duplicate)
Helper function to create a twInfoTable with a single field and single row containing a TW_BLOB or TW...
Definition: twInfoTable.c:750
Info table row structure.
Definition: twInfoTable.h:302
int twDataShapeEntry_AddAspect(struct twDataShapeEntry *entry, const char *name, twPrimitive *value)
Creates a new twDataShapeAspect with twDataShapeAspect::value value and adds it to the specified twDa...
Definition: twInfoTable.c:159
char * name
Definition: twInfoTable.h:85
int twInfoTable_GetDatetime(twInfoTable *it, const char *name, int32_t row, DATETIME *value)
Helper function to retrieve a TW_DATETIME from a twInfoTable.
Definition: twInfoTable.c:833
int twInfoTable_GetString(twInfoTable *it, const char *name, int32_t row, char **value)
Helper function to retrieve a TW_STRING from a twInfoTable.
Definition: twInfoTable.c:795
struct twInfoTable twInfoTable
Info table base structure.
twInfoTable * twInfoTable_ZeroCopy(twInfoTable *it)
Creates a new twInfoTable structure which inherits all pointers of an existing twInfoTable structure ...
Definition: twInfoTable.c:610
twInfoTable * twInfoTable_CreateFromStream(twStream *s)
Creates a new twInfoTable from data in a twStream.
Definition: twInfoTable.c:555
Location primitive structure.
Definition: twBaseTypes.h:181
int twInfoTable_GetPrimitive(twInfoTable *it, const char *name, int32_t row, twPrimitive **value)
Helper function to retrieve a twPrimitive from a twInfoTable.
Definition: twInfoTable.c:788
Definition: cJSON.h:43
uint32_t twInfoTableRow_GetLength(twInfoTableRow *row)
Gets the length of a twInfoTableRow.
Definition: twInfoTable.c:470
twInfoTableRow * twInfoTableRow_CreateFromStream(twStream *s)
Creates a new twInfoTableRow from data in a twStream.
Definition: twInfoTable.c:403
int twDataShape_AddEntry(struct twDataShape *ds, struct twDataShapeEntry *entry)
Adds a new twDataShapeEntry to a twDataShape.
Definition: twInfoTable.c:305
BaseType
Definition: twDefinitions.h:155
twInfoTableRow * twInfoTable_GetEntry(twInfoTable *it, int index)
Retrieves the twInfoTableRow from a twInfoTable at the specified (zero based) index.
Definition: twInfoTable.c:684
BaseType primitive structure.
Definition: twBaseTypes.h:207
Data shape aspect structure definition.
Definition: twInfoTable.h:31
enum BaseType type
Definition: twInfoTable.h:87
int twInfoTable_GetBlob(twInfoTable *it, const char *name, int32_t row, char **value, int32_t *length)
Helper function to retrieve a TW_BLOB from a twInfoTable.
Definition: twInfoTable.c:825
twInfoTable * twInfoTable_Create(twDataShape *shape)
Creates a new twInfoTable.
Definition: twInfoTable.c:532
char * description
Definition: twInfoTable.h:86