LibreDWG API  0.13.3
LibreDWG API - The DWG Library
dynapi.c File Reference
#include "config.h"
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "common.h"
#include "dynapi.h"
#include "logging.h"
#include "decode.h"
#include "dwg.h"
#include "bits.h"

Data Structures

struct  _name_type_fields
 
struct  _name_subclass_fields
 
struct  _name_subclasses
 
struct  _name
 

Macros

#define DWG_LOGLEVEL   loglevel
 
#define NUM_NAME_TYPES   ARRAY_SIZE(dwg_name_types)
 
#define NUM_SUBCLASSES   ARRAY_SIZE(dwg_list_subclasses)
 
#define SET_HDR_FLAGS(name, bit, inverse)
 

Functions

Dwg_Objectdwg_obj_generic_to_object (const void *restrict obj, int *restrict error)
 
bool is_dwg_entity (const char *name)
 
bool is_dwg_object (const char *name)
 
const Dwg_DYNAPI_fielddwg_dynapi_entity_fields (const char *name)
 
const Dwg_DYNAPI_fielddwg_dynapi_subclass_fields (const char *restrict name)
 
const Dwg_DYNAPI_fielddwg_dynapi_common_entity_fields (void)
 
const Dwg_DYNAPI_fielddwg_dynapi_common_object_fields (void)
 
const Dwg_DYNAPI_fielddwg_dynapi_entity_field (const char *restrict name, const char *restrict field)
 
const Dwg_DYNAPI_fielddwg_dynapi_subclass_field (const char *restrict name, const char *restrict field)
 
const Dwg_DYNAPI_fielddwg_dynapi_header_field (const char *restrict fieldname)
 
const Dwg_DYNAPI_fielddwg_dynapi_common_entity_field (const char *restrict fieldname)
 
const Dwg_DYNAPI_fielddwg_dynapi_common_object_field (const char *restrict fieldname)
 
const Dwg_DYNAPI_fielddwg_dynapi_field_dxf (const Dwg_DYNAPI_field *restrict fields, const int dxf, int *restrict unique)
 
int dwg_dynapi_entity_size (const char *restrict name)
 
int dwg_dynapi_subclass_size (const char *restrict name)
 
bool dwg_dynapi_entity_value (void *restrict _obj, const char *restrict name, const char *restrict fieldname, void *restrict out, Dwg_DYNAPI_field *restrict fp)
 
bool dwg_dynapi_entity_utf8text (void *restrict _obj, const char *restrict name, const char *restrict fieldname, char **restrict out, int *isnew, Dwg_DYNAPI_field *restrict fp)
 
bool dwg_dynapi_header_value (const Dwg_Data *restrict dwg, const char *restrict fieldname, void *restrict out, Dwg_DYNAPI_field *restrict fp)
 
bool dwg_dynapi_header_utf8text (const Dwg_Data *restrict dwg, const char *restrict fieldname, char **restrict out, int *isnew, Dwg_DYNAPI_field *restrict fp)
 
bool dwg_dynapi_common_value (void *restrict _obj, const char *restrict fieldname, void *restrict out, Dwg_DYNAPI_field *restrict fp)
 
bool dwg_dynapi_common_utf8text (void *restrict _obj, const char *restrict fieldname, char **restrict out, int *isnew, Dwg_DYNAPI_field *restrict fp)
 
bool dwg_dynapi_entity_set_value (void *restrict _obj, const char *restrict name, const char *restrict fieldname, const void *restrict value, const bool is_utf8)
 
bool dwg_dynapi_header_set_value (Dwg_Data *restrict dwg, const char *restrict fieldname, const void *restrict value, const bool is_utf8)
 
bool dwg_dynapi_common_set_value (void *restrict _obj, const char *restrict fieldname, const void *restrict value, const bool is_utf8)
 
bool dwg_dynapi_subclass_value (const void *restrict ptr, const char *restrict subclass, const char *restrict fieldname, void *restrict out, Dwg_DYNAPI_field *restrict fp)
 
bool dwg_dynapi_subclass_set_value (Dwg_Data *restrict dwg, const void *restrict ptr, const char *restrict subclass, const char *restrict fieldname, const void *restrict value, const bool is_utf8)
 
bool dwg_dynapi_field_get_value (const void *restrict ptr, const Dwg_DYNAPI_field *restrict field, void *restrict out)
 
bool dwg_dynapi_field_set_value (const Dwg_Data *restrict dwg, void *restrict ptr, const Dwg_DYNAPI_field *restrict field, const void *restrict value, const bool is_utf8)
 
char * dwg_dynapi_handle_name (const Dwg_Data *restrict dwg, Dwg_Object_Ref *restrict hdl, int *alloced)
 
int _fields_size_sum (const Dwg_DYNAPI_field *restrict fields)
 
int dwg_dynapi_fields_size (const char *restrict name)
 
char * dwg_dynapi_subclass_name (const char *restrict type)
 
bool dwg_has_subclass (const char *restrict classname, const char *restrict subclass)
 
bool dwg_dynapi_is_angle (const char *restrict name, const char *restrict fieldname)
 
bool dwg_dynapi_is_float (const Dwg_DYNAPI_field *f)
 

Macro Definition Documentation

◆ DWG_LOGLEVEL

#define DWG_LOGLEVEL   loglevel

◆ NUM_NAME_TYPES

#define NUM_NAME_TYPES   ARRAY_SIZE(dwg_name_types)

◆ NUM_SUBCLASSES

#define NUM_SUBCLASSES   ARRAY_SIZE(dwg_list_subclasses)

◆ SET_HDR_FLAGS

#define SET_HDR_FLAGS (   name,
  bit,
  inverse 
)
Value:
else if (strEQc (fieldname, #name)) \
{ \
if (dwg->header_vars.name && !inverse) \
dwg->header_vars.FLAGS |= bit; \
else \
dwg->header_vars.FLAGS &= ~bit; \
}
#define strEQc(s1, s2)
Definition: common.h:577

Function Documentation

◆ _fields_size_sum()

int _fields_size_sum ( const Dwg_DYNAPI_field *restrict  fields)

◆ dwg_dynapi_common_entity_field()

const Dwg_DYNAPI_field* dwg_dynapi_common_entity_field ( const char *restrict  fieldname)

◆ dwg_dynapi_common_entity_fields()

const Dwg_DYNAPI_field* dwg_dynapi_common_entity_fields ( void  )

◆ dwg_dynapi_common_object_field()

const Dwg_DYNAPI_field* dwg_dynapi_common_object_field ( const char *restrict  fieldname)

◆ dwg_dynapi_common_object_fields()

const Dwg_DYNAPI_field* dwg_dynapi_common_object_fields ( void  )

◆ dwg_dynapi_common_set_value()

bool dwg_dynapi_common_set_value ( void *restrict  _obj,
const char *restrict  fieldname,
const void *restrict  value,
const bool  is_utf8 
)

Sets the common ENTITY or OBJECT.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.

◆ dwg_dynapi_common_utf8text()

bool dwg_dynapi_common_utf8text ( void *restrict  _obj,
const char *restrict  fieldname,
char **restrict  out,
int *  isnew,
Dwg_DYNAPI_field *restrict  fp 
)

◆ dwg_dynapi_common_value()

bool dwg_dynapi_common_value ( void *restrict  _obj,
const char *restrict  fieldname,
void *restrict  out,
Dwg_DYNAPI_field *restrict  fp 
)

Returns the common ENTITY|OBJECT.fieldname value in out. _obj is the Dwg_Entity_ENTITY or Dwg_Object_OBJECT struct with the specific fields. The optional Dwg_DYNAPI_field *fp is filled with the field types from dynapi.c

◆ dwg_dynapi_entity_field()

const Dwg_DYNAPI_field* dwg_dynapi_entity_field ( const char *restrict  name,
const char *restrict  field 
)

◆ dwg_dynapi_entity_fields()

const Dwg_DYNAPI_field* dwg_dynapi_entity_fields ( const char *  name)

◆ dwg_dynapi_entity_set_value()

bool dwg_dynapi_entity_set_value ( void *restrict  entity,
const char *restrict  dxfname,
const char *restrict  fieldname,
const void *restrict  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.

◆ dwg_dynapi_entity_size()

int dwg_dynapi_entity_size ( const char *restrict  name)

◆ dwg_dynapi_entity_utf8text()

bool dwg_dynapi_entity_utf8text ( void *restrict  entity,
const char *restrict  name,
const char *restrict  fieldname,
char **restrict  textp,
int *  isnewp,
Dwg_DYNAPI_field *restrict  fp 
)

Returns the ENTITY|OBJECT.fieldname text value in textp as utf-8. entity is the Dwg_Entity_ENTITY or Dwg_Object_OBJECT struct with the specific fields. The optional Dwg_DYNAPI_field *fp is filled with the field types from dynapi.c With DWG's since r2007+ creates a fresh UTF-8 conversion from the UTF-16 wchar value (which needs to be free'd), with older DWG's or with TV, TF or TFF returns the unconverted text value. Only valid for text fields. isnew is set to 1 if textp is freshly malloced (r2007+), otherwise 0

◆ dwg_dynapi_entity_value()

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

Returns the ENTITY|OBJECT.fieldname value in out. entity is the Dwg_Entity_ENTITY or Dwg_Object_OBJECT struct with the specific fields. The optional Dwg_DYNAPI_field *fp is filled with the field types from dynapi.c.

◆ dwg_dynapi_field_dxf()

const Dwg_DYNAPI_field* dwg_dynapi_field_dxf ( const Dwg_DYNAPI_field *restrict  fields,
const int  dxf,
int *restrict  unique 
)

◆ dwg_dynapi_field_get_value()

bool dwg_dynapi_field_get_value ( const void *restrict  ptr,
const Dwg_DYNAPI_field *restrict  field,
void *restrict  out 
)

◆ dwg_dynapi_field_set_value()

bool dwg_dynapi_field_set_value ( const Dwg_Data *restrict  dwg,
void *restrict  ptr,
const Dwg_DYNAPI_field *restrict  field,
const void *restrict  value,
const bool  is_utf8 
)

◆ dwg_dynapi_fields_size()

int dwg_dynapi_fields_size ( const char *restrict  name)

The sum of the size of all fields, by entity or subclass name

◆ dwg_dynapi_handle_name()

char* dwg_dynapi_handle_name ( const Dwg_Data *restrict  dwg,
Dwg_Object_Ref *restrict  hdl,
int *  alloced 
)

Checks if the handle hdl points an object or entity with a name field, and returns it if so. Converted to UTF8 for r2007+ wide-strings. Sets alloced if the returned string is freshly malloc'd.

◆ dwg_dynapi_header_field()

const Dwg_DYNAPI_field* dwg_dynapi_header_field ( const char *restrict  fieldname)

Return the field for custom type checks.

◆ dwg_dynapi_header_set_value()

bool dwg_dynapi_header_set_value ( Dwg_Data *restrict  dwg,
const char *restrict  fieldname,
const void *restrict  value,
const bool  is_utf8 
)

Sets the HEADER.fieldname to a value. A malloc'ed struct or string is passed by ptr, not by the content. A non-malloc'ed struct is set by content. If is_utf8 is set, the given value is a UTF-8 string, and will be converted to TV or TU.

◆ dwg_dynapi_header_utf8text()

bool dwg_dynapi_header_utf8text ( const Dwg_Data *restrict  dwg,
const char *restrict  fieldname,
char **restrict  out,
int *  isnew,
Dwg_DYNAPI_field *restrict  fp 
)

◆ dwg_dynapi_header_value()

bool dwg_dynapi_header_value ( const Dwg_Data *restrict  dwg,
const char *restrict  fieldname,
void *restrict  out,
Dwg_DYNAPI_field *restrict  fp 
)

Returns the HEADER.fieldname value in out. The optional Dwg_DYNAPI_field *fp is filled with the field types from dynapi.c

◆ dwg_dynapi_is_angle()

bool dwg_dynapi_is_angle ( const char *restrict  name,
const char *restrict  fieldname 
)

◆ dwg_dynapi_is_float()

bool dwg_dynapi_is_float ( const Dwg_DYNAPI_field f)

◆ dwg_dynapi_subclass_field()

const Dwg_DYNAPI_field* dwg_dynapi_subclass_field ( const char *restrict  name,
const char *restrict  field 
)

◆ dwg_dynapi_subclass_fields()

const Dwg_DYNAPI_field* dwg_dynapi_subclass_fields ( const char *restrict  name)

Find the fields for this subclass. See dwg.h

◆ dwg_dynapi_subclass_name()

char* dwg_dynapi_subclass_name ( const char *restrict  type)

◆ dwg_dynapi_subclass_set_value()

bool dwg_dynapi_subclass_set_value ( Dwg_Data *restrict  dwg,
const void *restrict  ptr,
const char *restrict  subclass,
const char *restrict  fieldname,
const void *restrict  value,
const bool  is_utf8 
)

◆ dwg_dynapi_subclass_size()

int dwg_dynapi_subclass_size ( const char *restrict  name)

◆ dwg_dynapi_subclass_value()

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

Returns the common OBJECT.subclass.fieldname value in out. ptr points to the subclass field. The optional Dwg_DYNAPI_field *fp is filled with the field types from dynapi.c

◆ dwg_has_subclass()

bool dwg_has_subclass ( const char *restrict  classname,
const char *restrict  subclass 
)

◆ dwg_obj_generic_to_object()

Dwg_Object* dwg_obj_generic_to_object ( const void *restrict  _vobj,
int *restrict  error 
)

Returns dwg_object* from any dwg_obj_*

Usage: dwg_object* obj = dwg_obj_generic_to_object(_obj, &error);
dwg_object * dwg_obj_generic_to_object(const void *restrict obj, int *restrict error)
Definition: dwg_api.c:21880
Definition: dwg.h:8968
Parameters
[in]_vobjdwg_obj_generic* (layer, block_header, xrecord, ...)
[out]errorint*, is set to 0 for ok, 1 on error

◆ is_dwg_entity()

bool is_dwg_entity ( const char *  name)

Check if the name is a valid ENTITY name, not an OBJECT.

◆ is_dwg_object()

bool is_dwg_object ( const char *  name)

Check if the name is a valid OBJECT name, not an ENTITY.