navit
0.5.3-trunk
|
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <glib.h>
#include "debug.h"
#include "item.h"
#include "coord.h"
#include "transform.h"
#include "color.h"
#include "navigation.h"
Data Structures | |
struct | attr_name |
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... | |
static int | attr_match (enum attr_type search, enum attr_type found) |
char * | attr_to_name (enum attr_type attr) |
Converts an attr_type to a string. More... | |
struct attr * | attr_new_from_text (const char *name, const char *value) |
Creates an attribute from text information. More... | |
static char * | flags_to_text (int flags) |
Converts access flags to a human-readable string. 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 attr * | attr_search (struct attr **attrs, struct attr *last, 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) |
static void | attr_free_content_do (struct attr *attr) |
void | attr_free_content (struct attr *attr) |
void | attr_free (struct attr *attr) |
void | attr_dup_content (struct attr *src, struct attr *dst) |
struct attr * | attr_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... | |
int | attr_from_line (char *line, char *name, int *pos, char *val_ret, char *name_ret) |
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... | |
Variables | |
static struct attr_name | attr_names [] |
static GHashTable * | attr_hash |
void attr_create_hash | ( | void | ) |
References attr_hash, attr_names, and attr_name::name.
Referenced by config_load().
void* attr_data_get | ( | struct attr * | attr | ) |
References attr::data, attr::num, attr::range, attr::type, and attr::u.
Referenced by attr_bin_write_attr(), and binfile_attr_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().
void attr_data_set_le | ( | struct attr * | attr, |
void * | data | ||
) |
References attr::data, data, le16_to_cpu, le32_to_cpu, range::max, range::min, attr::num, attr::range, attr::type, and attr::u.
Referenced by binfile_attr_get().
int attr_data_size | ( | struct attr * | attr | ) |
References attr_to_name(), attr::attr_types, attr::color, attr::coord_geo, dbg, attr::item_types, lvl_error, attr::num, attr::num64, attr::numd, attr::range, attr::str, attr::type, and attr::u.
Referenced by attr_bin_write_attr(), attr_dup_content(), and binfile_attr_set().
void attr_destroy_hash | ( | void | ) |
References attr_hash.
Referenced by config_load().
References attr_dup_content().
Referenced by attr_generic_add_attr(), attr_generic_prepend_attr(), attr_generic_set_attr(), attr_list_dup(), csv_attr_set(), gui_internal_cmd_escape(), gui_internal_set_click_coord(), gui_internal_set_position_coord(), map_search_new_mg(), navit_cmd_get_attr_var(), navit_cmd_get_int_var(), navit_cmd_set_attr_var(), quadtree_data_dup(), search_list_search(), and tracking_get_attr().
References attr_data_size(), attr::data, HAS_OBJECT_FUNC, attr::item_type, attr::num, size, attr::type, and attr::u.
Referenced by attr_dup(), command_call_function(), command_object_get_attr(), navit_cmd_map_add_curr_pos(), navit_cmd_push_int(), navit_cmd_set_int_var(), and tm_attr_get().
void attr_free | ( | struct attr * | attr | ) |
References attr_free_content_do().
Referenced by attr_destroy_py(), attr_generic_remove_attr(), attr_generic_set_attr(), attr_list_free(), attr_resolve(), csv_attr_set(), gui_internal_html_submit_set(), gui_internal_set_click_coord(), gui_internal_set_position_coord(), map_rect_destroy_shapefile(), map_search_destroy_mg(), navit_cmd_set_attr_var(), navit_destroy(), osd_marker_init(), quadtree_item_free_do(), search_list_search_free(), tracking_destroy(), and tracking_get_attr().
void attr_free_content | ( | struct attr * | attr | ) |
References attr_free_content_do().
Referenced by result_free().
|
static |
References attr::data, HAS_OBJECT_FUNC, attr::type, and attr::u.
Referenced by attr_free(), and attr_free_content().
int attr_from_line | ( | char * | line, |
char * | name, | ||
int * | pos, | ||
char * | val_ret, | ||
char * | name_ret | ||
) |
References dbg, lvl_debug, p, and startup::pos.
Referenced by attr_resolve(), map_rect_get_item_shapefile(), map_rect_get_item_textfile(), parse_option(), and textfile_attr_get().
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.
name | The attribute name |
References attr_hash, attr_match(), and attr_names.
Referenced by attr_new_from_text(), attr_type_get_from_message(), command_attr_type(), command_call_function(), decode_attr_type_from_iter(), NGQProxy::getAttr(), NGQProxyNavit::getAttrList(), navit_cmd_map_item_set_attr(), navit_get_attr_py(), osd_text_prepare(), parse_filter(), NGQProxy::setAttr(), start_element(), textfile_attr_get(), and variant_to_attr_type().
Generic add function.
This function will insert a new attribute into the list.
attrs | Points to the array of attribute pointers to be updated |
attr | The new attribute. |
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(), maps_new(), 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().
References attr_generic_add_attr(), and attr::attrs.
Referenced by config_new().
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.
attrs | Points to the array of attribute pointers to be searched |
def_attrs | Points 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. |
type | The attribute type to search for |
attr | Points to a struct attr |
iter | An iterator. This parameter may be NULL. |
References attr_match(), and attr::attrs.
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().
References attr_dup(), and attr::attrs.
Referenced by navit_object_add_attr(), osd_new(), and search_list_common_addattr().
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.
attrs | The attribute list |
attr | The attribute to remove from the list |
References attr_free(), attr::attrs, attr::data, type, attr::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().
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.
attrs | Points to the array of attribute pointers to be updated (if NULL, this function will create a new list containing only the new attribute) |
attr | The new attribute. |
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(), speech_set_attr(), tm_add_item(), vehicle_set_attr(), vehicle_set_default_name(), and vehicleprofile_set_attr().
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.
attrs | The attribute list to copy |
References attr_dup().
Referenced by announcement_new(), graphics_new(), gui_new(), log_new(), map_new(), maps_new(), mapset_new(), navit_new(), navit_object_new(), osd_new(), profile_option_new(), roadprofile_dup(), roadprofile_new(), script_new(), tm_add_item(), vehicle_new(), and vehicleprofile_new().
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.
attrs | The attribute list to free |
References attr_free().
Referenced by command_call_function(), config_destroy(), eval_list(), graphics_free(), gui_internal_dbus_signal(), layer_destroy(), log_destroy(), map_destroy(), maps_new(), mapset_destroy(), navit_destroy(), navit_object_destroy(), osd_destroy(), osd_new(), profile_option_destroy(), roadprofile_destroy(), script_destroy(), search_list_common_destroy(), tm_add_item(), tm_item_destroy(), and vehicle_destroy().
Referenced by attr_from_name(), and attr_generic_get_attr().
struct attr* attr_new_from_text | ( | const char * | name, |
const char * | value | ||
) |
Creates an attribute from text information.
This function creates an attribute from two strings specifying the name and the value.
name | The name of the new attribute |
value | The value of the new attribute |
References color::a, attr_name::attr, attr_from_name(), ATTR_REL_MAXABS, ATTR_REL_MAXREL, ATTR_REL_MINABS, ATTR_REL_MINREL, ATTR_REL_RELSHIFT, attr::attr_types, color::b, attr::color, attr::coord_geo, coord_parse(), attr::dash, dbg, color::g, item_from_name(), attr::item_type, attr::item_types, lvl_debug, lvl_error, range::max, max, range::min, attr::num, startup::pos, projection_mg, color::r, attr::range, attr::str, transform_to_geo(), attr::type, and attr::u.
Referenced by attr_new_py(), attr_resolve(), command_set_attr(), convert_to_attrs(), gui_internal_html_submit_set(), osd_marker_init(), and parse_option().
int attr_rel2real | ( | int | attrval, |
int | whole, | ||
int | treat_neg_as_rel | ||
) |
Derive absolute value from relative attribute, given value of the whole range.
attrval | Value of u.num member of attribute capable of holding relative values. |
whole | Range counted as 100%. |
treat_neg_as_rel | Replace negative absolute values with whole+attr.u.num. |
References ATTR_REL_MAXABS, and ATTR_REL_RELSHIFT.
Referenced by osd_std_calculate_sizes().
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.
attrs | Points to the array of attribute pointers to be searched |
last | Not used |
attr_type | The attribute type to search for. Generic types (such as attr_any or attr_any_xml) are NOT supported. |
References attr::attrs, dbg, lvl_debug, and lvl_info.
Referenced by announcement_new(), coord_new_from_attrs(), cursor_new(), debug_new(), element_set_background_color(), element_set_circle_radius(), element_set_circle_width(), element_set_color(), element_set_polyline_dash(), element_set_polyline_directed(), element_set_polyline_offset(), element_set_polyline_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_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(), maps_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(), 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_new(), vehicle_file_new_file(), vehicle_gpsd_new_gpsd(), vehicle_gpsd_position_attr_get(), vehicle_gypsy_new_gypsy(), vehicle_gypsy_position_attr_get(), vehicle_iphone_new(), vehicle_log_gpx(), vehicle_maemo_new_maemo(), vehicle_maemo_position_attr_get(), vehicle_new(), vehicle_qt5_position_attr_get(), vehicle_set_default_name(), vehicle_wince_new(), and vehicleprofile_new().
char* attr_to_name | ( | enum attr_type | attr | ) |
Converts an attr_type to a string.
attr | The attribute type to be converted. |
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_call_function(), command_evaluate_to_attr(), command_get_attr(), command_object_get_attr(), config_new(), dump(), 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(), gui_qml_set_attr(), housenumber_attr_get(), invoke(), item_bin_dump(), item_dump_attr(), itemgra_add_attr(), map_search_get_item_mg(), 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(), point_attr_get(), 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(), textfile_attr_get(), tm_dump_item_to_textfile(), town_attr_get(), tracking_get_attr(), traffic_new(), vehicle_android_position_attr_get(), vehicle_demo_set_attr_do(), vehicle_null_position_attr_get(), vehicle_qt5_position_attr_get(), vehicleprofile_apply_attrs(), and vehicleprofile_set_attr_do().
Converts an attribute to a string that can be displayed.
This function is just a wrapper around
.
attr | The attribute to convert |
map | The translation map, see |
pretty | Not 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_spawn(), navit_cmd_strjoin(), osd_text_format_attr(), popup_show_attr_val(), route_get_destination_description(), save_vehicle_xml(), and tm_dump_item_to_textfile().
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.
attr | The attribute to be formatted |
sep | The separator to insert between a numeric value and its unit. If NULL, nothing will be inserted. |
fmt | Set to if is of type attr_destination_length attr_destination_time |
def_fmt | Not used |
map | The 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 is NULL, the string will be returned unchanged. |
References color::a, attr_format_with_units, attr_to_name(), attr_to_text_ext(), attr::attrs, color::b, attr::color, 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, color::r, attr::str, item::type, type, attr::type, and attr::u.
Referenced by attr_to_text(), attr_to_text_ext(), and gui_internal_populate_route_table().
Checks if an enumeration of attribute types contains a specific attribute.
types | Points to a NULL-terminated array of pointers to enum attr_type |
type | The attr_type to be searched for |
Referenced by attr_types_contains_default().
Check if an enumeration of attribute types contains a specific attribute.
This function is mostly identical to
but returns the supplied default value if
is empty.
types | Points to a NULL-terminated array of pointers to enum attr_type |
type | The attr_type to be searched for |
deflt | The default value to return if is empty. |
References attr_types_contains().
Referenced by vehicle_log_gpx().
|
static |
Converts access flags to a human-readable string.
flags | The flags as a number |
References AF_ALL, AF_BIKE, AF_CAR, AF_DANGEROUS_GOODS, AF_DELIVERY_TRUCK, AF_EMERGENCY_VEHICLES, AF_FORD, AF_HIGH_OCCUPANCY_CAR, AF_HORSE, AF_MOPED, AF_MOTORCYCLE, AF_MOTORIZED_FAST, AF_ONEWAY, AF_ONEWAY_EXCEPTION, AF_ONEWAYREV, AF_PEDESTRIAN, AF_PUBLIC_BUS, AF_RESERVED1, AF_ROUNDABOUT, AF_ROUNDABOUT_VALID, AF_SEASONAL, AF_SEGMENTED, AF_SIZE_OR_WEIGHT_LIMIT, AF_SPEED_LIMIT, AF_TAXI, AF_THROUGH_TRAFFIC_LIMIT, AF_TOLL, AF_TRANSPORT_TRUCK, AF_UNDERGROUND, AF_UNPAVED, and g_strconcat_printf().
Referenced by attr_to_text_ext().
|
static |
Referenced by attr_create_hash(), attr_destroy_hash(), and attr_from_name().
|
static |
List of attr_types with their names as strings.
Referenced by attr_create_hash(), attr_from_name(), and attr_to_name().