Next: , Previous: , Up: Functions   [Contents][Index]


7.4 dynapi

The new dynapi replaced the old dwg_api functions to access each object field. The old dwg_api functions were deprecated, and need to be re-enabled by defining CFLAGS="-DUSE_DEPRECATED_API". See see Objects for an description of each object and its fields..

For each of header, entity, common or subclass there is a function to get and set the value of any type, or converted utf8 string.

Function: bool dwg_dynapi_entity_value (void *entity, const char *dxfname, const char *fieldname, void *out, Dwg_DYNAPI_field *fp)

entity is of type dwg_ent_generic, that is the pointer to the object specific struct. dxfname is the dxfname of the object, fieldname is the field or property name of the field to be read from, *out the result pointer and the optiona *fp is filled by the information for this field.

Function: bool dwg_dynapi_common_value (void *entity, const char *fieldname, void *out, Dwg_DYNAPI_field *fp)

This accesses the common Dwg_Object_Object* or Dwg_Object_Entity* fields.

Function: bool dwg_dynapi_header_value (void *dwg, const char *fieldname, void *out, Dwg_DYNAPI_field *fp)

This accesses the Header (or sometimes also called Database) fields.

Function: bool dwg_dynapi_subclass_value (void *ptr, const char *subclass, const char *fieldname, void *out, Dwg_DYNAPI_field *fp)

This accesses a subclass, a structure within the object.

The utf8text functions convert version-specific text strings to UTF-8 strings. Internally the dwg stores strings as TU (unicode) or TV (single-byte codepage). The API treats all strings as UTF-8, as with JSON, DXF or the add API.

Function: bool dwg_dynapi_entity_utf8text (void *entity, const char *dxfname, const char *fieldname, char *textp, int *isnewp, Dwg_DYNAPI_field *fp)

isnewp is set to 1 f the string is a fresh copy, for unicode strings.

Function: bool dwg_dynapi_common_utf8text (void *entity, const char *fieldname, char *textp, int *isnewp, Dwg_DYNAPI_field *fp)
Function: bool dwg_dynapi_header_utf8text (void *dwg, const char *fieldname, char *textp, int *isnewp, Dwg_DYNAPI_field *fp)

This accesses the Header (or sometimes also called Database) fields.

Function: bool dwg_dynapi_subclass_utf8text (void *ptr, const char *subclass, const char *fieldname, char *textp, int *isnewp, Dwg_DYNAPI_field *fp)

This accesses a subclass, a structure within the object.

The setters don’t differentiate between common values and strings.

Function: bool dwg_dynapi_entity_set_value (dwg_ent_generic *_obj, const char *fieldname, const void *value, const bool is_utf8)

Sets the ENTITY.fieldname to a value. A malloc’ed struct is passed by ptr, not by the content. A non-malloc’ed struct is set by content. Arrays or strings must be malloced before. We just set the new pointer, the old value will be freed. If is_utf8 is set, the given value is a UTF-8 string, and will be converted to TV or TU

Function: bool dwg_dynapi_header_set_value (Dwg_Data *dwg, const char *fieldname, const void *value, const bool is_utf8)
Function: bool dwg_dynapi_common_set_value (dwg_ent_generic *_obj, const char *fieldname, const void *value, const bool is_utf8)

See the sourcecode of the importers or programs for the usage of the API’s.


Next: strings, Previous: add api, Up: Functions   [Contents][Index]