navit  0.5.3-trunk
attr.h File Reference
#include "projection.h"
#include "attr_def.h"

Go to the source code of this file.

Data Structures

struct  range
 
struct  attr
 

Macros

#define ATTR2(x, y)   attr_##y=x,
 
#define ATTR(x)   attr_##x,
 
#define ATTR_UNUSED   ATTR_UNUSED_L(__LINE__)
 
#define ATTR_UNUSED_L(x)   ATTR_UNUSED_WITH_LINE_NUMBER(x)
 
#define ATTR_UNUSED_WITH_LINE_NUMBER(x)   ATTR_UNUSED_##x,
 
#define AF_ONEWAY   (1<<0)
 
#define AF_ONEWAYREV   (1<<1)
 
#define AF_NOPASS   (AF_ONEWAY|AF_ONEWAYREV)
 
#define AF_ONEWAYMASK   (AF_ONEWAY|AF_ONEWAYREV)
 
#define AF_SEGMENTED   (1<<2)
 
#define AF_ROUNDABOUT   (1<<3)
 
#define AF_ROUNDABOUT_VALID   (1<<4)
 
#define AF_ONEWAY_EXCEPTION   (1<<5)
 
#define AF_SPEED_LIMIT   (1<<6)
 
#define AF_RESERVED1   (1<<7)
 
#define AF_SIZE_OR_WEIGHT_LIMIT   (1<<8)
 
#define AF_THROUGH_TRAFFIC_LIMIT   (1<<9)
 
#define AF_TOLL   (1<<10)
 
#define AF_SEASONAL   (1<<11)
 
#define AF_UNPAVED   (1<<12)
 
#define AF_FORD   (1<<13)
 
#define AF_UNDERGROUND   (1<<14)
 
#define AF_HIGH_OCCUPANCY_CAR_ONLY   (1<<18)
 
#define AF_DANGEROUS_GOODS   (1<<19)
 
#define AF_EMERGENCY_VEHICLES   (1<<20)
 
#define AF_TRANSPORT_TRUCK   (1<<21)
 
#define AF_DELIVERY_TRUCK   (1<<22)
 
#define AF_PUBLIC_BUS   (1<<23)
 
#define AF_TAXI   (1<<24)
 
#define AF_HIGH_OCCUPANCY_CAR   (1<<25)
 
#define AF_CAR   (1<<26)
 
#define AF_MOTORCYCLE   (1<<27)
 
#define AF_MOPED   (1<<28)
 
#define AF_HORSE   (1<<29)
 
#define AF_BIKE   (1<<30)
 
#define AF_PEDESTRIAN   (1<<31)
 
#define AF_PBH   (AF_PEDESTRIAN|AF_BIKE|AF_HORSE)
 
#define AF_MOTORIZED_FAST   (AF_MOTORCYCLE|AF_CAR|AF_HIGH_OCCUPANCY_CAR|AF_TAXI|AF_PUBLIC_BUS|AF_DELIVERY_TRUCK|AF_TRANSPORT_TRUCK|AF_EMERGENCY_VEHICLES)
 
#define AF_ALL   (AF_PBH|AF_MOPED|AF_MOTORIZED_FAST)
 
#define AF_DISTORTIONMASK   (AF_ALL|AF_ONEWAYMASK)
 
#define AF_DG_ANY   (1<<0)
 
#define AF_DG_WATER_HARMFUL   (1<<1)
 
#define AF_DG_EXPLOSIVE   (1<<2)
 
#define AF_DG_FLAMMABLE   (1<<3)
 
#define ATTR_REL_MINABS   -0x40000000
 
#define ATTR_REL_MAXABS   0x40000000
 
#define ATTR_REL_MINREL   -0x1FFFFFFF
 
#define ATTR_REL_MAXREL   0x20000000
 
#define ATTR_REL_RELSHIFT   0x60000000
 
#define ATTR_IS_INT(x)   ((x) >= attr_type_int_begin && (x) <= attr_type_int_end)
 
#define ATTR_IS_DOUBLE(x)   ((x) >= attr_type_double_begin && (x) <= attr_type_double_end)
 
#define ATTR_IS_STRING(x)   ((x) >= attr_type_string_begin && (x) <= attr_type_string_end)
 
#define ATTR_IS_OBJECT(x)   ((x) >= attr_type_object_begin && (x) <= attr_type_object_end)
 
#define ATTR_IS_ITEM(x)   ((x) >= attr_type_item_begin && (x) <= attr_type_item_end)
 
#define ATTR_IS_COORD_GEO(x)   ((x) >= attr_type_coord_geo_begin && (x) <= attr_type_coord_geo_end)
 
#define ATTR_IS_NUMERIC(x)   (ATTR_IS_INT(x) || ATTR_IS_DOUBLE(x))
 
#define ATTR_IS_COLOR(x)   ((x) >= attr_type_color_begin && (x) <= attr_type_color_end)
 
#define ATTR_IS_PCOORD(x)   ((x) >= attr_type_pcoord_begin && (x) <= attr_type_pcoord_end)
 
#define ATTR_IS_COORD(x)   ((x) >= attr_type_coord_begin && (x) <= attr_type_coord_end)
 
#define ATTR_IS_GROUP(x)   ((x) >= attr_type_group_begin && (x) <= attr_type_group_end)
 
#define ATTR_INT(x, y)   ((struct attr){attr_##x,{.num=y}})
 
#define ATTR_OBJECT(x, y)   ((struct attr){attr_##x,{.navit=y}})
 

Enumerations

enum  attr_type
 
enum  attr_format { attr_format_default =0 , attr_format_with_units =1 }
 
enum  attr_position_valid {
  attr_position_valid_invalid , attr_position_valid_static , attr_position_valid_extrapolated_time , attr_position_valid_extrapolated_spatial ,
  attr_position_valid_valid
}
 

Functions

void attr_create_hash (void)
 
void attr_destroy_hash (void)
 
enum attr_type attr_from_name (const char *name)
 Converts a string to an attr_type. More...
 
char * attr_to_name (enum attr_type attr)
 Converts an attr_type to a string. More...
 
struct attrattr_new_from_text (const char *name, const char *value)
 Creates an attribute from text information. More...
 
char * attr_to_text_ext (struct attr *attr, char *sep, enum attr_format fmt, enum attr_format def_fmt, struct map *map)
 Converts attribute data to human-readable text. More...
 
char * attr_to_text (struct attr *attr, struct map *map, int pretty)
 Converts an attribute to a string that can be displayed. More...
 
struct attrattr_search (struct attr **attrs, enum attr_type attr)
 Searches for an attribute of a given type. More...
 
int attr_generic_get_attr (struct attr **attrs, struct attr **def_attrs, enum attr_type type, struct attr *attr, struct attr_iter *iter)
 Generic get function. More...
 
struct attr ** attr_generic_set_attr (struct attr **attrs, struct attr *attr)
 Generic set function. More...
 
struct attr ** attr_generic_add_attr (struct attr **attrs, struct attr *attr)
 Generic add function. More...
 
struct attr ** attr_generic_add_attr_list (struct attr **attrs, struct attr **add)
 
struct attr ** attr_generic_prepend_attr (struct attr **attrs, struct attr *attr)
 
struct attr ** attr_generic_remove_attr (struct attr **attrs, struct attr *attr)
 Removes an attribute from an attribute list. More...
 
enum attr_type attr_type_begin (enum attr_type type)
 
int attr_data_size (struct attr *attr)
 
void * attr_data_get (struct attr *attr)
 
void attr_data_set (struct attr *attr, void *data)
 
void attr_data_set_le (struct attr *attr, void *data)
 
void attr_free_content (struct attr *attr)
 
void attr_free (struct attr *attr)
 
void attr_free_g (struct attr *attr, void *unused)
 
void attr_dup_content (struct attr *src, struct attr *dst)
 
struct attrattr_dup (struct attr *attr)
 
void attr_list_free (struct attr **attrs)
 Frees a list of attributes. More...
 
struct attr ** attr_list_dup (struct attr **attrs)
 Duplicates a list of attributes. More...
 
struct attr ** attr_list_append (struct attr **attrs, struct attr *attr)
 
int attr_from_line (const char *line, const char *name, int *pos, char *val_ret, char *name_ret)
 Retrieves an attribute from a line in textfile format. More...
 
int attr_types_contains (enum attr_type *types, enum attr_type type)
 Checks if an enumeration of attribute types contains a specific attribute. More...
 
int attr_types_contains_default (enum attr_type *types, enum attr_type type, int deflt)
 Check if an enumeration of attribute types contains a specific attribute. More...
 
int attr_rel2real (int attrval, int whole, int treat_neg_as_rel)
 Derive absolute value from relative attribute, given value of the whole range. More...
 

Macro Definition Documentation

◆ AF_ALL

#define AF_ALL   (AF_PBH|AF_MOPED|AF_MOTORIZED_FAST)

◆ AF_BIKE

#define AF_BIKE   (1<<30)

◆ AF_CAR

#define AF_CAR   (1<<26)

◆ AF_DANGEROUS_GOODS

#define AF_DANGEROUS_GOODS   (1<<19)

◆ AF_DELIVERY_TRUCK

#define AF_DELIVERY_TRUCK   (1<<22)

◆ AF_DG_ANY

#define AF_DG_ANY   (1<<0)

◆ AF_DG_EXPLOSIVE

#define AF_DG_EXPLOSIVE   (1<<2)

◆ AF_DG_FLAMMABLE

#define AF_DG_FLAMMABLE   (1<<3)

◆ AF_DG_WATER_HARMFUL

#define AF_DG_WATER_HARMFUL   (1<<1)

◆ AF_DISTORTIONMASK

#define AF_DISTORTIONMASK   (AF_ALL|AF_ONEWAYMASK)

◆ AF_EMERGENCY_VEHICLES

#define AF_EMERGENCY_VEHICLES   (1<<20)

◆ AF_FORD

#define AF_FORD   (1<<13)

◆ AF_HIGH_OCCUPANCY_CAR

#define AF_HIGH_OCCUPANCY_CAR   (1<<25)

◆ AF_HIGH_OCCUPANCY_CAR_ONLY

#define AF_HIGH_OCCUPANCY_CAR_ONLY   (1<<18)

◆ AF_HORSE

#define AF_HORSE   (1<<29)

◆ AF_MOPED

#define AF_MOPED   (1<<28)

◆ AF_MOTORCYCLE

#define AF_MOTORCYCLE   (1<<27)

◆ AF_MOTORIZED_FAST

◆ AF_NOPASS

#define AF_NOPASS   (AF_ONEWAY|AF_ONEWAYREV)

◆ AF_ONEWAY

#define AF_ONEWAY   (1<<0)

◆ AF_ONEWAY_EXCEPTION

#define AF_ONEWAY_EXCEPTION   (1<<5)

◆ AF_ONEWAYMASK

#define AF_ONEWAYMASK   (AF_ONEWAY|AF_ONEWAYREV)

◆ AF_ONEWAYREV

#define AF_ONEWAYREV   (1<<1)

◆ AF_PBH

#define AF_PBH   (AF_PEDESTRIAN|AF_BIKE|AF_HORSE)

◆ AF_PEDESTRIAN

#define AF_PEDESTRIAN   (1<<31)

◆ AF_PUBLIC_BUS

#define AF_PUBLIC_BUS   (1<<23)

◆ AF_RESERVED1

#define AF_RESERVED1   (1<<7)

◆ AF_ROUNDABOUT

#define AF_ROUNDABOUT   (1<<3)

◆ AF_ROUNDABOUT_VALID

#define AF_ROUNDABOUT_VALID   (1<<4)

◆ AF_SEASONAL

#define AF_SEASONAL   (1<<11)

◆ AF_SEGMENTED

#define AF_SEGMENTED   (1<<2)

◆ AF_SIZE_OR_WEIGHT_LIMIT

#define AF_SIZE_OR_WEIGHT_LIMIT   (1<<8)

◆ AF_SPEED_LIMIT

#define AF_SPEED_LIMIT   (1<<6)

◆ AF_TAXI

#define AF_TAXI   (1<<24)

◆ AF_THROUGH_TRAFFIC_LIMIT

#define AF_THROUGH_TRAFFIC_LIMIT   (1<<9)

◆ AF_TOLL

#define AF_TOLL   (1<<10)

◆ AF_TRANSPORT_TRUCK

#define AF_TRANSPORT_TRUCK   (1<<21)

◆ AF_UNDERGROUND

#define AF_UNDERGROUND   (1<<14)

◆ AF_UNPAVED

#define AF_UNPAVED   (1<<12)

◆ ATTR

#define ATTR (   x)    attr_##x,

◆ ATTR2

#define ATTR2 (   x,
 
)    attr_##y=x,

◆ ATTR_INT

#define ATTR_INT (   x,
 
)    ((struct attr){attr_##x,{.num=y}})

◆ ATTR_IS_COLOR

#define ATTR_IS_COLOR (   x)    ((x) >= attr_type_color_begin && (x) <= attr_type_color_end)

◆ ATTR_IS_COORD

#define ATTR_IS_COORD (   x)    ((x) >= attr_type_coord_begin && (x) <= attr_type_coord_end)

◆ ATTR_IS_COORD_GEO

#define ATTR_IS_COORD_GEO (   x)    ((x) >= attr_type_coord_geo_begin && (x) <= attr_type_coord_geo_end)

◆ ATTR_IS_DOUBLE

#define ATTR_IS_DOUBLE (   x)    ((x) >= attr_type_double_begin && (x) <= attr_type_double_end)

◆ ATTR_IS_GROUP

#define ATTR_IS_GROUP (   x)    ((x) >= attr_type_group_begin && (x) <= attr_type_group_end)

◆ ATTR_IS_INT

#define ATTR_IS_INT (   x)    ((x) >= attr_type_int_begin && (x) <= attr_type_int_end)

◆ ATTR_IS_ITEM

#define ATTR_IS_ITEM (   x)    ((x) >= attr_type_item_begin && (x) <= attr_type_item_end)

◆ ATTR_IS_NUMERIC

#define ATTR_IS_NUMERIC (   x)    (ATTR_IS_INT(x) || ATTR_IS_DOUBLE(x))

◆ ATTR_IS_OBJECT

#define ATTR_IS_OBJECT (   x)    ((x) >= attr_type_object_begin && (x) <= attr_type_object_end)

◆ ATTR_IS_PCOORD

#define ATTR_IS_PCOORD (   x)    ((x) >= attr_type_pcoord_begin && (x) <= attr_type_pcoord_end)

◆ ATTR_IS_STRING

#define ATTR_IS_STRING (   x)    ((x) >= attr_type_string_begin && (x) <= attr_type_string_end)

◆ ATTR_OBJECT

#define ATTR_OBJECT (   x,
 
)    ((struct attr){attr_##x,{.navit=y}})

◆ ATTR_REL_MAXABS

#define ATTR_REL_MAXABS   0x40000000

Maximum value for an absolute attribute value.

◆ ATTR_REL_MAXREL

#define ATTR_REL_MAXREL   0x20000000

Maximum value for an relative attribute value (without value shift).

◆ ATTR_REL_MINABS

#define ATTR_REL_MINABS   -0x40000000

Minimum value for an absolute attribute value.

◆ ATTR_REL_MINREL

#define ATTR_REL_MINREL   -0x1FFFFFFF

Minimum value for an relative attribute value (without value shift).

◆ ATTR_REL_RELSHIFT

#define ATTR_REL_RELSHIFT   0x60000000

Value shift for relative values. This value is added to an attribute values to indicate a relative value.

◆ ATTR_UNUSED

#define ATTR_UNUSED   ATTR_UNUSED_L(__LINE__)

◆ ATTR_UNUSED_L

#define ATTR_UNUSED_L (   x)    ATTR_UNUSED_WITH_LINE_NUMBER(x)

◆ ATTR_UNUSED_WITH_LINE_NUMBER

#define ATTR_UNUSED_WITH_LINE_NUMBER (   x)    ATTR_UNUSED_##x,

Enumeration Type Documentation

◆ attr_format

Enumerator
attr_format_default 
attr_format_with_units 

◆ attr_position_valid

Indicates whether a position is valid

Enumerator
attr_position_valid_invalid 

The position is invalid and should be discarded.

attr_position_valid_static 

The position is valid but the vehicle is not moving, or moving very slowly. Calculations that involve the difference between two consecutive positions, such as bearing, may therefore be inaccurate.

attr_position_valid_extrapolated_time 

FIXME: this description is just my (mvglasow) guess; this value is not used anywhere as of r5957. The position is the vehicle's last known position, and the consumer of the information should be aware that the vehicle may have moved since.

attr_position_valid_extrapolated_spatial 

FIXME: this description is just my (mvglasow) guess; this value is not used anywhere as of r5957. The position is a prediction of the vehicle's current position, based on its last known position, the time elapsed since it was obtained and possibly other factors. This would be used for positions obtained through inertial navigation.

attr_position_valid_valid 

The position is valid and can be used for all purposes.

◆ attr_type

enum attr_type

Attribute type values, created using macro magic.

Function Documentation

◆ attr_create_hash()

void attr_create_hash ( void  )

References attr_hash, attr_names, and name.

Referenced by config_load().

◆ attr_data_get()

void* attr_data_get ( struct attr attr)

◆ attr_data_set()

void attr_data_set ( struct attr attr,
void *  data 
)

References attr::data, data, attr::num, attr::type, and attr::u.

Referenced by item_bin_dump().

◆ attr_data_set_le()

void attr_data_set_le ( struct attr attr,
void *  data 
)

◆ attr_data_size()

◆ attr_destroy_hash()

void attr_destroy_hash ( void  )

References attr_hash.

Referenced by config_load().

◆ attr_dup()

◆ attr_dup_content()

◆ attr_free()

◆ attr_free_content()

void attr_free_content ( struct attr attr)

References attr_free_content_do().

Referenced by navit_destroy(), and result_free().

◆ attr_free_g()

void attr_free_g ( struct attr attr,
void *  unused 
)

References attr_free().

Referenced by navit_destroy().

◆ attr_from_line()

int attr_from_line ( const char *  line,
const char *  name,
int *  pos,
char *  val_ret,
char *  name_ret 
)

Retrieves an attribute from a line in textfile format.

If name is NULL, this function returns the first attribute found; otherwise it looks for an attribute named name.

If pos is specified, it acts as an offset pointer: Any data in line before *pos will be skipped. When the function returns, the value pointed to by pos will be incremented by the number of characters parsed. This can be used to iteratively retrieve all attributes: declare a local variable, set it to zero, then iteratively call this function with a pointer to the same variable until it returns false.

val_ret must be allocated (and later freed) by the caller, and have sufficient capacity to hold the parsed value including the terminating NULL character. The minimum safe size is strlen(line) - strlen(name) - *pos (assuming zero for NULL pointers).

Parameters
[in]lineThe line to parse, must be non-NULL and pointing to a NUL terminated string
[in]nameThe name of the attribute to retrieve; can be NULL (see description)
[in,out]posAs input, if pointer is non-NULL, this argument contains the character index inside line from which to start the search (see description)
[out]val_retPoints to a buffer which will receive the value as text
[out]name_retPoints to a buffer which will receive the actual name of the attribute found in the line, if NULL this argument won't be used. Note that the buffer provided here should be long enough to contain the attribute name + a terminating NUL character
Returns
true if successful, false in case of failure

References dbg, lvl_debug, lvl_warning, name, p, startup::pos, and strncpy_unescape().

Referenced by attr_resolve(), map_rect_get_item_shapefile(), map_rect_get_item_textfile(), parse_option(), and traffic_message_restore_segments().

◆ attr_from_name()

enum attr_type attr_from_name ( const char *  name)

Converts a string to an attr_type.

This function reads a string and returns the corresponding attr_type.

Parameters
nameThe attribute name
Returns
The corresponding
attr_type
Definition: attr.h:34
, or
attr_none
if the string specifies a nonexistent or invalid attribute type.

Referenced by attr_new_from_text(), command_call_function(), NGQProxy::getAttr(), NGQProxyNavit::getAttrList(), navit_cmd_map_item_set_attr(), navit_get_attr_py(), osd_text_prepare(), parse_filter(), NGQProxy::setAttr(), and start_element().

◆ attr_generic_add_attr()

struct attr** attr_generic_add_attr ( struct attr **  attrs,
struct attr attr 
)

Generic add function.

This function will insert a new attribute into the list.

Parameters
attrsPoints to the array of attribute pointers to be updated
attrThe new attribute.
Returns
Pointer to the updated attribute list

References attr_dup(), attr_to_name(), attr::attrs, dbg, lvl_debug, and attr::type.

Referenced by announcement_add_attr(), attr_generic_add_attr_list(), cursor_add_attr(), eval_list(), graphics_new(), gui_internal_cmd_escape(), gui_internal_dbus_signal(), gui_internal_get_data(), gui_new(), layout_add_attr(), mapset_add_attr(), navit_add_attr(), navit_cmd_fmt_coordinates(), navit_cmd_strjoin(), navit_object_add_attr(), roadprofile_add_attr(), tm_item_update_attrs(), vehicle_add_attr(), and vehicleprofile_add_attr().

◆ attr_generic_add_attr_list()

struct attr** attr_generic_add_attr_list ( struct attr **  attrs,
struct attr **  add 
)

◆ attr_generic_get_attr()

int attr_generic_get_attr ( struct attr **  attrs,
struct attr **  def_attrs,
enum attr_type  type,
struct attr attr,
struct attr_iter iter 
)

Generic get function.

This function searches an attribute list for an attribute of a given type and stores it in the attr parameter. If no match is found in attrs and the def_attrs argument is supplied, def_attrs is searched for the attribute type and the first match (if any) is returned.

Searching for attr_any or attr_any_xml is supported, but def_attrs will not be searched in that case.

An iterator can be specified to get multiple attributes of the same type: The first call will return the first match from attr; each subsequent call with the same iterator will return the next match. After obtaining the last match from attr, def_attrs is searched in the same manner. If no more matching attributes are found in either of them, false is returned.

Parameters
attrsPoints to the array of attribute pointers to be searched
def_attrsPoints to a list of pointers to default attributes. If an attribute is not found in attrs, the function will return the first match from def_attrs. This parameter may be NULL.
typeThe attribute type to search for
attrPoints to a
struct attr
Definition: attr.h:157
which will receive the attribute
iterAn iterator. This parameter may be NULL.
Returns
True if a matching attribute was found, false if not.

References attr_match(), attr::attrs, and type.

Referenced by announcement_get_attr(), config_get_attr(), get_string_from_attr_list(), graphics_get_attr(), gui_get_attr(), log_get_attr(), map_get_attr(), messagelist_new(), navit_get_attr(), navit_object_get_attr(), roadprofile_get_attr(), route_new(), speech_get_attr(), tm_find_item(), tracking_new(), vehicle_get_attr(), and vehicleprofile_get_attr().

◆ attr_generic_prepend_attr()

struct attr** attr_generic_prepend_attr ( struct attr **  attrs,
struct attr attr 
)

◆ attr_generic_remove_attr()

struct attr** attr_generic_remove_attr ( struct attr **  attrs,
struct attr attr 
)

Removes an attribute from an attribute list.

If attrs contains attr, a new attribute list is created (which contains all attributes, except for attr) and both attrs (the original attribute list) and attr are freed.

If attrs does not contain attr, this function is a no-op.

Attributes are matched based on their type and u.data members, thus attr can be a shallow copy of the attribute, and can match multiple attributes in the list. The attr argument itself is not changed.

Parameters
attrsThe attribute list
attrThe attribute to remove from the list
Returns
The new attribute list

References attr_free(), attr::attrs, attr::data, attr::type, type, and attr::u.

Referenced by announcement_remove_attr(), mapset_remove_attr(), navit_object_remove_attr(), navit_remove_attr(), roadprofile_remove_attr(), tm_item_update_attrs(), vehicle_remove_attr(), and vehicleprofile_remove_attr().

◆ attr_generic_set_attr()

struct attr** attr_generic_set_attr ( struct attr **  attrs,
struct attr attr 
)

Generic set function.

This function will search the list for the first attribute of the same type as the supplied new one and replace it with that. If the list does not contain an attribute whose type matches that of the new one, the new attribute is inserted into the list.

Parameters
attrsPoints to the array of attribute pointers to be updated (if NULL, this function will create a new list containing only the new attribute)
attrThe new attribute.
Returns
Pointer to the updated attribute list

References attr_dup(), attr_free(), attr_to_name(), attr::attrs, dbg, lvl_debug, and attr::type.

Referenced by announcement_set_attr(), gui_set_attr(), map_set_attr(), navit_object_set_attr(), roadprofile_set_attr(), tm_add_item(), vehicle_set_attr(), vehicle_set_default_name(), and vehicleprofile_set_attr().

◆ attr_list_append()

struct attr** attr_list_append ( struct attr **  attrs,
struct attr attr 
)

◆ attr_list_dup()

struct attr** attr_list_dup ( struct attr **  attrs)

Duplicates a list of attributes.

This creates a deep copy, i.e. the attributes in the list are copied as well.

It is safe to call this function with a NULL argument; in this case, NULL will be returned.

Parameters
attrsThe attribute list to copy
Returns
The copy of the attribute list

References attr_dup(), and attr::attrs.

Referenced by announcement_new(), graphics_new(), gui_new(), log_new(), map_new(), mapset_new(), navit_new(), navit_object_new(), osd_new(), profile_option_new(), roadprofile_dup(), roadprofile_new(), script_new(), tm_add_item(), traffic_message_restore_segments(), vehicle_new(), and vehicleprofile_new().

◆ attr_list_free()

void attr_list_free ( struct attr **  attrs)

Frees a list of attributes.

This frees the pointer array as well as the attributes referenced by the pointers.

It is safe to call this function with a NULL argument; doing so is a no-op.

Parameters
attrsThe attribute list to free

References attr_free(), and attr::attrs.

Referenced by command_call_function(), config_destroy(), eval_list(), graphics_free(), gui_internal_dbus_signal(), layer_destroy(), log_destroy(), map_destroy(), mapset_destroy(), navit_destroy(), navit_object_destroy(), osd_destroy(), osd_new(), parsed_item_destroy(), profile_option_destroy(), roadprofile_destroy(), script_destroy(), search_list_common_destroy(), tm_add_item(), tm_item_destroy(), traffic_destroy(), and vehicle_destroy().

◆ attr_new_from_text()

struct attr* attr_new_from_text ( const char *  name,
const char *  value 
)

◆ attr_rel2real()

int attr_rel2real ( int  attrval,
int  whole,
int  treat_neg_as_rel 
)

Derive absolute value from relative attribute, given value of the whole range.

Parameters
attrvalValue of u.num member of attribute capable of holding relative values.
wholeRange counted as 100%.
treat_neg_as_relReplace negative absolute values with whole+attr.u.num.
Returns
Absolute value corresponding to given relative value.

Referenced by osd_std_calculate_sizes().

◆ attr_search()

struct attr* attr_search ( struct attr **  attrs,
enum attr_type  attr 
)

Searches for an attribute of a given type.

This function searches an array of pointers to attributes for a given attribute type and returns the first match.

Parameters
attrsPoints to the array of attribute pointers to be searched
attr_typeThe attribute type to search for. Generic types (such as attr_any or attr_any_xml) are NOT supported.
Returns
Pointer to the first matching attribute, or NULL if no match was found.

References attr::attrs, dbg, lvl_debug, and lvl_info.

Referenced by announcement_new(), coord_new_from_attrs(), cursor_new(), debug_new(), element_set_arrows_width(), element_set_background_color(), element_set_circle_radius(), element_set_circle_width(), element_set_color(), element_set_oneway(), element_set_polyline_dash(), element_set_polyline_directed(), element_set_polyline_offset(), element_set_polyline_width(), element_set_spikes_distance(), element_set_spikes_width(), element_set_text_size(), espeak_new(), file_create(), gmap_new(), graphics_android_new(), graphics_gtk_drawing_area_new(), graphics_new(), graphics_null_new(), graphics_opengl_new(), graphics_qt5_new(), graphics_qt_qpainter_new(), graphics_sdl_new(), graphics_svg_debug_new(), graphics_win32_new(), gui_gtk_new(), gui_internal_add_vehicle_profile(), gui_internal_command_init(), gui_internal_new(), gui_new(), gui_qml_new(), gui_qt5_qml_new(), icon_new(), itemgra_new(), layout_new(), log_new(), map_filter_new(), map_new(), map_new_binfile(), map_new_csv(), map_new_garmin_img(), map_new_mg(), map_new_shapefile(), map_new_textfile(), map_route_occluded_new(), navigation_map_new(), navigation_new(), osd_button_new(), osd_cmd_interface_new(), osd_compass_new(), osd_gps_status_new(), osd_image_new(), osd_j1850_new(), osd_nav_next_turn_new(), osd_nav_toggle_announcer_new(), osd_navigation_status_new(), osd_new(), osd_odometer_new(), osd_route_guard_new(), osd_set_std_attr(), osd_speed_cam_new(), osd_speed_warner_new(), osd_stopwatch_new(), osd_text_new(), osd_volume_new(), plugin_new(), polygon_new(), qt5_espeak_init_espeak(), qt5_espeak_init_language(), route_map_new_helper(), script_run(), seg_data_equals(), speech_android_new(), speech_new(), speechd_new(), tm_item_update_attrs(), tracking_map_new(), traffic_map_new(), traffic_new(), vehicle_file_new_file(), vehicle_gpsd_new_gpsd(), vehicle_gypsy_new_gypsy(), vehicle_iphone_new(), vehicle_log_gpx(), vehicle_new(), vehicle_qt5_position_attr_get(), vehicle_set_default_name(), vehicle_wince_new(), and vehicleprofile_new().

◆ attr_to_name()

char* attr_to_name ( enum attr_type  attr)

Converts an attr_type to a string.

Parameters
attrThe attribute type to be converted.
Returns
The attribute name, or NULL if an invalid value was passed as . The calling function should create a copy of the string if it needs to alter it or relies on the string being available permanently.

References attr_names, and attr_name::name.

Referenced by android_search_idle(), attr_data_size(), attr_generic_add_attr(), attr_generic_set_attr(), attr_resolve(), attr_to_text_ext(), binfile_attr_get(), command_attr_type(), command_call_function(), command_get_attr(), command_object_get_attr(), encode_attr(), get_int_bool(), NGQPoint::getInformation(), getProperty(), gui_internal_append_attr(), gui_internal_cmd_debug(), gui_internal_cmd_view_attributes(), gui_internal_set_attr(), housenumber_attr_get(), invoke(), item_bin_dump(), item_dump_attr(), itemgra_add_attr(), map_search_new_mg(), map_search_setup(), navigation_get_attr(), navit_get_attr(), navit_object_add_attr(), navit_object_ref(), navit_object_set_attr(), navit_object_unref(), navit_set_attr_do(), osd_text_draw(), pedestrian_navit_init(), popup_show_attr_val(), route_set_attr(), rp_attr_get(), save_map_csv(), save_vehicle_xml(), search_attr_get(), search_by_address_attr(), search_list_level(), search_list_search(), street_name_attr_get(), tm_item_dump_to_file(), town_attr_get(), tracking_get_attr(), traffic_new(), vehicle_demo_set_attr_do(), vehicle_null_position_attr_get(), vehicle_qt5_position_attr_get(), vehicleprofile_apply_attrs(), and vehicleprofile_set_attr_do().

◆ attr_to_text()

char* attr_to_text ( struct attr attr,
struct map map,
int  pretty 
)

Converts an attribute to a string that can be displayed.

This function is just a wrapper around

char * attr_to_text_ext(struct attr *attr, char *sep, enum attr_format fmt, enum attr_format def_fmt, struct map *map)
Converts attribute data to human-readable text.
Definition: attr.c:363

.

Parameters
attrThe attribute to convert
mapThe translation map, see
prettyNot used

References attr_format_default, and attr_to_text_ext().

Referenced by encode_attr(), get_string(), NGQPoint::getInformation(), gui_internal_cmd_debug(), gui_internal_cmd_match_expand(), gui_internal_cmd_view_attributes(), item_bin_dump(), item_dump_attr(), navit_cmd_strjoin(), osd_text_format_attr(), popup_show_attr_val(), route_get_destination_description(), save_vehicle_xml(), and tm_item_dump_to_file().

◆ attr_to_text_ext()

char* attr_to_text_ext ( struct attr attr,
char *  sep,
enum attr_format  fmt,
enum attr_format  def_fmt,
struct map map 
)

Converts attribute data to human-readable text.

Parameters
attrThe attribute to be formatted
sepThe separator to insert between a numeric value and its unit. If NULL, nothing will be inserted.
fmtSet to
@ attr_format_with_units
Definition: attr.h:56
if is of type
attr_destination_length
or
attr_destination_time
or a group type which might contain attributes of those types. Ignored for all other attribute types.
def_fmtNot used
mapThe translation map. This is only needed for string type attributes or group type attributes which might contain strings. It can be NULL for other attribute types. If a string type attribute is encountered and
Definition: map.c:55
is NULL, the string will be returned unchanged.
Returns
The attribute data in human-readable form. The caller is responsible for calling
g_free()
on the result when it is no longer needed.

References color::a, attr_format_with_units, attr_to_name(), attr::attrs, color::b, attr::color, poly_hole::coord_count, attr::coord_geo, attr::data, data, flags_to_text(), color::g, g_strconcat_printf(), item::id_hi, item::id_lo, attr::item, item_to_name(), attr::item_types, coord_geo::lat, coord_geo::lng, LONGLONG_FMT, item::map, map_convert_free(), map_convert_string(), map_get_attr(), nav_status_to_text(), attr::num, attr::num64, attr::numd, attr::poly_hole, color::r, attr::str, attr::type, item::type, type, and attr::u.

Referenced by attr_to_text(), and gui_internal_populate_route_table().

◆ attr_type_begin()

enum attr_type attr_type_begin ( enum attr_type  type)

◆ attr_types_contains()

int attr_types_contains ( enum attr_type types,
enum attr_type  type 
)

Checks if an enumeration of attribute types contains a specific attribute.

Parameters
typesPoints to a NULL-terminated array of pointers to
enum attr_type
, which will be searched
typeThe attr_type to be searched for
Returns
True if the attribute type was found, false if it was not found or if
unsigned char types
Definition: garmin_img.c:1
is empty

References type, and types.

Referenced by attr_types_contains_default().

◆ attr_types_contains_default()

int attr_types_contains_default ( enum attr_type types,
enum attr_type  type,
int  deflt 
)

Check if an enumeration of attribute types contains a specific attribute.

This function is mostly identical to

int attr_types_contains(enum attr_type *types, enum attr_type type)
Checks if an enumeration of attribute types contains a specific attribute.
Definition: attr.c:1020

but returns the supplied default value if

is empty.

Parameters
typesPoints to a NULL-terminated array of pointers to
enum attr_type
, which will be searched
typeThe attr_type to be searched for
defltThe default value to return if is empty.
Returns
True if the attribute type was found, false if it was not found,
deflt
if types is empty.

References attr_types_contains(), type, and types.

Referenced by vehicle_log_gpx().