libgeda

o_attrib.c File Reference

utility functions for attributes More...

#include <config.h>
#include <missing.h>
#include <stdio.h>
#include <math.h>
#include "libgeda_priv.h"
Include dependency graph for o_attrib.c:

Go to the source code of this file.

Data Structures

struct  AttribsChangedHook

Functions

void o_attrib_add (TOPLEVEL *toplevel, OBJECT *object, OBJECT *item)
 Add an attribute to an existing attribute list.
gboolean o_attrib_is_attached (TOPLEVEL *toplevel, OBJECT *attrib, OBJECT *object)
 Check whether a attrib is attached to another object.
void o_attrib_attach (TOPLEVEL *toplevel, OBJECT *attrib, OBJECT *object, int set_color)
 Attach existing attribute to an object.
void o_attrib_attach_list (TOPLEVEL *toplevel, GList *attr_list, OBJECT *object, int set_color)
 Attach list of existing attributes to an object.
void o_attrib_detach_all (TOPLEVEL *toplevel, OBJECT *object)
 Detach all attribute items in a list.
void o_attrib_print (GList *attributes)
 Print all attributes to a Postscript document.
void o_attrib_remove (TOPLEVEL *toplevel, GList **list, OBJECT *remove)
 Remove an attribute item from an attribute list.
GList * o_read_attribs (TOPLEVEL *toplevel, OBJECT *object_to_get_attribs, TextBuffer *tb, unsigned int release_ver, unsigned int fileformat_ver, GError **err)
 Read attributes from a buffer.
gboolean o_attrib_string_get_name_value (const gchar *string, gchar **name_ptr, gchar **value_ptr)
 Get name and value from an attribute 'name=value' string.
gboolean o_attrib_get_name_value (OBJECT *attrib, gchar **name_ptr, gchar **value_ptr)
 Get name and value from an attribute OBJECT.
GList * o_attrib_find_floating_attribs (const GList *list)
 Find all floating attributes in the given object list.
OBJECTo_attrib_find_attrib_by_name (const GList *list, char *name, int count)
 Find an attribute in a list.
static char * o_attrib_search_attrib_list_by_name (const GList *list, char *name, int counter)
 Search attribute list by name.
char * o_attrib_search_floating_attribs_by_name (const GList *list, char *name, int counter)
 Search floating attribute by name.
char * o_attrib_search_attached_attribs_by_name (OBJECT *object, char *name, int counter)
 Search attached attributes by name.
char * o_attrib_search_inherited_attribs_by_name (OBJECT *object, char *name, int counter)
 Search inherited attribute by name.
char * o_attrib_search_object_attribs_by_name (OBJECT *object, char *name, int counter)
 Search attributes of object by name.
GList * o_attrib_return_attribs (OBJECT *object)
 Get all attached attributes of the specified OBJECT.
int o_attrib_is_inherited (OBJECT *attrib)
 Query whether a given attribute OBJECT is "inherited".
void o_attrib_append_attribs_changed_hook (TOPLEVEL *toplevel, AttribsChangedFunc func, void *data)
static void call_attribs_changed_hook (gpointer data, gpointer user_data)
void o_attrib_emit_attribs_changed (TOPLEVEL *toplevel, OBJECT *object)
void o_attrib_freeze_hooks (TOPLEVEL *toplevel, OBJECT *object)
void o_attrib_thaw_hooks (TOPLEVEL *toplevel, OBJECT *object)

Detailed Description

Attributes are normal text objects. An attribute is a text object that has a text string that is delimited by an equal "=" character. The part before the equal character is called name the part of the string behind the equal character is called value

Attributes are attached to OBJECTs (st_object). Each attribute has a reference to the object it is attached to. Each object that has attributes has a list of pionters to its attributes.

o_attrib_overview.png
Note:
Be sure in o_copy o_move o_delete you maintain the attributes delete is a bare, because you will have to unattach the other end and in o_save o_read as well and in o_select when selecting objects, select the attributes

Definition in file o_attrib.c.


Function Documentation

void o_attrib_add ( TOPLEVEL toplevel,
OBJECT object,
OBJECT item 
)
Function Description
Add an attribute to an existing attribute list.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in]objectThe OBJECT we're adding the attribute to.
[in]itemThe item you want to add as an attribute.
Returns:
nothing.

Definition at line 68 of file o_attrib.c.

Here is the call graph for this function:

gboolean o_attrib_is_attached ( TOPLEVEL toplevel,
OBJECT attrib,
OBJECT object 
)
Function Description
This function checks whether the object attrib is attached to the object.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in]attribThe attribute to be checket.
[in]objectThe object where you want to add item as an attribute.
Returns:
TRUE if attrib is an attribute of object, FALSE otherwise

Definition at line 88 of file o_attrib.c.

void o_attrib_attach ( TOPLEVEL toplevel,
OBJECT attrib,
OBJECT object,
int  set_color 
)
Function Description
Attach existing attribute to an object.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in]attribThe attribute to be added.
[out]objectThe object where you want to add item as an attribute.
[in]set_colorWhether or not we should set the new attribute's color.

Definition at line 110 of file o_attrib.c.

Here is the call graph for this function:

void o_attrib_attach_list ( TOPLEVEL toplevel,
GList *  attr_list,
OBJECT object,
int  set_color 
)
Function Description
Attach list of existing attributes to an object.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in]attr_listThe list of attributes to be added.
[out]objectThe object where you want to add item as an attribute.
[in]set_colorWhether or not we should set the new attribute's color.

Definition at line 149 of file o_attrib.c.

Here is the call graph for this function:

void o_attrib_detach_all ( TOPLEVEL toplevel,
OBJECT object 
)
Function Description
Detach all attributes from an object.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in,out]objectThe object whos attributes to detach.

Definition at line 166 of file o_attrib.c.

Here is the call graph for this function:

void o_attrib_print ( GList *  attributes)
Function Description
Print all attributes to a Postscript document.
Parameters:
[in]attributesList of attributes to print.

Definition at line 194 of file o_attrib.c.

void o_attrib_remove ( TOPLEVEL toplevel,
GList **  list,
OBJECT remove 
)
Todo:
Finish function.
Function Description
This function removes the given attribute from an attribute list. This function should be used when detaching an attribute.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in]listThe attribute list to remove attribute from.
[in]removeThe OBJECT to remove from list.

Definition at line 222 of file o_attrib.c.

Here is the call graph for this function:

GList* o_read_attribs ( TOPLEVEL toplevel,
OBJECT object_to_get_attribs,
TextBuffer tb,
unsigned int  release_ver,
unsigned int  fileformat_ver,
GError **  err 
)
Function Description
Read attributes from a TextBuffer.
Parameters:
[in]toplevelThe TOPLEVEL object.
[in]object_to_get_attribsObject which gets these attribs.
[in]tbThe text buffer to read from.
[in]release_verlibgeda release version number.
[in]fileformat_verfile format version number.
Returns:
GList of attributes read, or NULL on error.

Definition at line 247 of file o_attrib.c.

Here is the call graph for this function:

gboolean o_attrib_string_get_name_value ( const gchar *  string,
gchar **  name_ptr,
gchar **  value_ptr 
)
Function Description
This function parses the character string string expected to be an attribute string of the form 'name=value'.

It returns TRUE if it has been able to parse the string into the name and value parts of an attribute. Otherwise it returns FALSE, in that case *name_ptr and *value_ptr are set to NULL.

name_ptr and/or value_ptr can be NULL. If not NULL, the caller must g_free these returned strings.

Note:
If you get an invalid attribute (improper) with a name and no value, then it is NOT an attribute. Also, there cannot be any spaces beside the equals sign
Parameters:
[in]stringString to split into name/value pair.
[out]name_ptrThe return location for the name, or NULL.
[out]value_ptrThe return location for the value, or NULL.
Returns:
TRUE on success, FALSE otherwise.

Definition at line 379 of file o_attrib.c.

gboolean o_attrib_get_name_value ( OBJECT attrib,
gchar **  name_ptr,
gchar **  value_ptr 
)
Function Description
See o_attrib_string_get_name_value() for more details
Parameters:
[in]attribThe attribute OBJECT whos name/value to return.
[out]name_ptrThe return location for the name, or NULL.
[out]value_ptrThe return location for the value, or NULL.
Returns:
TRUE on success, FALSE otherwise.

Definition at line 424 of file o_attrib.c.

Here is the call graph for this function:

GList* o_attrib_find_floating_attribs ( const GList *  list)
Function Description
Find all floating attributes in the given object list.
Parameters:
[in]listGList of OBJECTs to search for floating attributes.
Returns:
GList of floating attributes from the input list
Warning:
Caller must g_list_free returned list.

Definition at line 443 of file o_attrib.c.

Here is the call graph for this function:

OBJECT* o_attrib_find_attrib_by_name ( const GList *  list,
char *  name,
int  count 
)
Function Description
Search for attribute by name.

Counter is the n'th occurance of the attribute, and starts searching from zero. Zero is the first occurance of an attribute.

Parameters:
[in]listGList of attributes to search.
[in]nameCharacter string with attribute name to search for.
[in]countWhich occurance to return.
Returns:
The n'th attribute object in the given list with the given name.

Definition at line 479 of file o_attrib.c.

Here is the call graph for this function:

static char* o_attrib_search_attrib_list_by_name ( const GList *  list,
char *  name,
int  counter 
) [static]
Function Description
Search for attribute by name.

Counter is the n'th occurance of the attribute, and starts searching from zero. Zero is the first occurance of an attribute.

Parameters:
[in]listGList of attributes to search.
[in]nameCharacter string with attribute name to search for.
[in]counterWhich occurance to return.
Returns:
Character string with attribute value, NULL otherwise.

Definition at line 521 of file o_attrib.c.

Here is the call graph for this function:

char* o_attrib_search_floating_attribs_by_name ( const GList *  list,
char *  name,
int  counter 
)
Function Description
Search for attribute by name.

Counter is the n'th occurance of the attribute, and starts searching from zero. Zero is the first occurance of an attribute.

Parameters:
[in]listGList of OBJECTs to search for floating attributes.
[in]nameCharacter string with attribute name to search for.
[in]counterWhich occurance to return.
Returns:
Character string with attribute value, NULL otherwise.
Warning:
Caller must g_free returned character string.

Definition at line 550 of file o_attrib.c.

Here is the call graph for this function:

char* o_attrib_search_attached_attribs_by_name ( OBJECT object,
char *  name,
int  counter 
)
Function Description
Search for attribute by name.

Counter is the n'th occurance of the attribute, and starts searching from zero. Zero is the first occurance of an attribute.

Parameters:
[in]objectThe OBJECT whos attached attributes to search.
[in]nameCharacter string with attribute name to search for.
[in]counterWhich occurance to return.
Returns:
Character string with attribute value, NULL otherwise.
Warning:
Caller must g_free returned character string.

Definition at line 578 of file o_attrib.c.

Here is the call graph for this function:

char* o_attrib_search_inherited_attribs_by_name ( OBJECT object,
char *  name,
int  counter 
)
Function Description
Search for attribute by name.

Counter is the n'th occurance of the attribute, and starts searching from zero. Zero is the first occurance of an attribute.

Parameters:
[in]objectThe OBJECT whos inherited attributes to search.
[in]nameCharacter string with attribute name to search for.
[in]counterWhich occurance to return.
Returns:
Character string with attribute value, NULL otherwise.
Warning:
Caller must g_free returned character string.

Definition at line 599 of file o_attrib.c.

Here is the call graph for this function:

char* o_attrib_search_object_attribs_by_name ( OBJECT object,
char *  name,
int  counter 
)
Function Description
Search for attribute by name.

Counter is the n'th occurance of the attribute, and starts searching from zero. Zero is the first occurance of an attribute.

Parameters:
[in]objectOBJECT who's attributes to search.
[in]nameCharacter string with attribute name to search for.
[in]counterWhich occurance to return.
Returns:
Character string with attribute value, NULL otherwise.
Warning:
Caller must g_free returned character string.

Definition at line 623 of file o_attrib.c.

Here is the call graph for this function:

GList* o_attrib_return_attribs ( OBJECT object)
Function Description
This function returns all attributes of the specified object.

The returned GList should be freed using the #g_list_free().

This function aggregates the attached and inherited attributes belonging to a given OBJECT. (inherited attributes are those which live as toplevel un-attached attributes inside in a complex OBJECT's prim_objs).

Parameters:
[in]objectOBJECT whos attributes to return.
Returns:
A GList of attributes belinging to the passed object.

Definition at line 650 of file o_attrib.c.

Here is the call graph for this function:

int o_attrib_is_inherited ( OBJECT attrib)
Function Description
This function returns TRUE if the given attribute OBJECT is a toplevel un-attached attribute inside a complex's prim_objs.
Parameters:
[in]attribOBJECT who's status to query.
Returns:
TRUE if the given attribute is inside a symbol

Definition at line 698 of file o_attrib.c.

void o_attrib_append_attribs_changed_hook ( TOPLEVEL toplevel,
AttribsChangedFunc  func,
void *  data 
)

Definition at line 711 of file o_attrib.c.

static void call_attribs_changed_hook ( gpointer  data,
gpointer  user_data 
) [static]

Definition at line 726 of file o_attrib.c.

void o_attrib_emit_attribs_changed ( TOPLEVEL toplevel,
OBJECT object 
)

Definition at line 735 of file o_attrib.c.

Here is the call graph for this function:

void o_attrib_freeze_hooks ( TOPLEVEL toplevel,
OBJECT object 
)

Definition at line 750 of file o_attrib.c.

void o_attrib_thaw_hooks ( TOPLEVEL toplevel,
OBJECT object 
)

Definition at line 755 of file o_attrib.c.

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines