Map between gfsmLabelIds and external objects.
More...
#include <gfsmCommon.h>
#include <gfsmSet.h>
#include <gfsmIO.h>
Go to the source code of this file.
Functions |
|
gpointer | gfsm_alphabet_string2key (gfsmAlphabet *a, GString *gstr) |
void | gfsm_alphabet_key2string (gfsmAlphabet *a, gpointer key, GString *gstr) |
gboolean | gfsm_alphabet_load_handle (gfsmAlphabet *a, gfsmIOHandle *ioh, gfsmError **errp) |
gboolean | gfsm_alphabet_load_file (gfsmAlphabet *a, FILE *f, gfsmError **errp) |
gboolean | gfsm_alphabet_load_filename (gfsmAlphabet *a, const gchar *filename, gfsmError **errp) |
gboolean | gfsm_alphabet_save_handle (gfsmAlphabet *a, gfsmIOHandle *ioh, gfsmError **errp) |
gboolean | gfsm_alphabet_save_file (gfsmAlphabet *a, FILE *f, gfsmError **errp) |
gboolean | gfsm_alphabet_save_file_full (gfsmAlphabet *a, FILE *f, int zlevel, gfsmError **errp) |
gboolean | gfsm_alphabet_save_filename (gfsmAlphabet *a, const gchar *filename, gfsmError **errp) |
gboolean | gfsm_alphabet_save_filename_full (gfsmAlphabet *a, const gchar *filename, int zlevel, gfsmError **errp) |
gboolean | gfsm_alphabet_save_file_func (gfsmAlphabet *a, gpointer key, gfsmLabelVal lab, gfsmAlphabetSaveFileData *sfdata) |
Alphabet: Function Types |
typedef gpointer(* | gfsmAlphabetKeyDupFunc )(struct gfsmPointerAlphabet_ *a, gpointer key) |
typedef gfsmLabelVal(* | gfsmAlphabetKeyLookupFunc )(struct gfsmUserAlphabet_ *a, gconstpointer key) |
typedef gpointer(* | gfsmAlphabetLabLookupFunc )(struct gfsmUserAlphabet_ *a, gfsmLabelVal lab) |
typedef gfsmLabelVal(* | gfsmAlphabetInsertFunc )(struct gfsmUserAlphabet_ *a, gpointer key, gfsmLabelVal lab) |
typedef void(* | gfsmAlphabetKeyRemoveFunc )(struct gfsmUserAlphabet_ *a, gpointer key) |
typedef void(* | gfsmAlphabetLabRemoveFunc )(struct gfsmUserAlphabet_ *a, gfsmLabelVal lab) |
typedef gpointer(* | gfsmAlphabetKeyReadFunc )(struct gfsmUserAlphabet_ *a, GString *gstr) |
typedef void(* | gfsmAlphabetKeyWriteFunc )(struct gfsmUserAlphabet_ *a, gconstpointer key, GString *str) |
gfsmUserAlphabetMethods | gfsmUserAlphabetDefaultMethods |
| default methods for user-defined alphabets (dummy)
|
Constructors etc. |
#define | gfsm_identity_alphabet_new() gfsm_identity_alphabet_init((gfsmIdentityAlphabet*)gfsm_alphabet_new(gfsmATIdentity)) |
#define | gfsm_string_alphabet_new_full(docopy) gfsm_string_alphabet_init((gfsmStringAlphabet*)gfsm_alphabet_new(gfsmATString),(docopy)) |
#define | gfsm_string_alphabet_new() gfsm_string_alphabet_new_full(TRUE) |
#define | gfsm_range_alphabet_new() |
#define | gfsm_pointer_alphabet_new(key_dup_f, key_hash_f, key_eq_f, key_free_f) |
gfsmAlphabet * | gfsm_alphabet_new (gfsmAType type) |
gfsmAlphabet * | gfsm_alphabet_init (gfsmAlphabet *a) |
gfsmAlphabet * | gfsm_range_alphabet_init (gfsmRangeAlphabet *a, gfsmLabelVal min, gfsmLabelVal max) |
gfsmAlphabet * | gfsm_identity_alphabet_init (gfsmIdentityAlphabet *a) |
gfsmAlphabet * | gfsm_pointer_alphabet_init (gfsmPointerAlphabet *a, gfsmAlphabetKeyDupFunc key_dup_func, GHashFunc key_hash_func, GEqualFunc key_equal_func, GDestroyNotify key_destroy_func) |
gfsmAlphabet * | gfsm_string_alphabet_init (gfsmStringAlphabet *a, gboolean do_copy) |
gfsmAlphabet * | gfsm_user_alphabet_init (gfsmUserAlphabet *a, gfsmAlphabetKeyDupFunc key_dup_func, GHashFunc key_hash_func, GEqualFunc key_equal_func, GDestroyNotify key_destroy_func, gpointer user_data, gfsmUserAlphabetMethods *methods) |
void | gfsm_alphabet_clear (gfsmAlphabet *a) |
gboolean | gfsm_alphabet_foreach_remove_func (gfsmAlphabet *a, gpointer key, gfsmLabelVal lab, gpointer data) |
void | gfsm_alphabet_free (gfsmAlphabet *a) |
Accessors |
#define | gfsm_alphabet_get_label(a, key) gfsm_alphabet_get_full(a,key,gfsmNoLabel) |
gfsmLabelVal | gfsm_alphabet_size (gfsmAlphabet *a) |
gboolean | gfsm_alphabet_foreach_size_func (gfsmAlphabet *a, gpointer key, gfsmLabelVal lab, guint *np) |
gfsmLabelVal | gfsm_alphabet_insert (gfsmAlphabet *a, gpointer key, gfsmLabelVal label) |
gfsmLabelVal | gfsm_alphabet_get_full (gfsmAlphabet *a, gpointer key, gfsmLabelVal label) |
gfsmLabelVal | gfsm_alphabet_find_label (gfsmAlphabet *a, gconstpointer key) |
gpointer | gfsm_alphabet_find_key (gfsmAlphabet *a, gfsmLabelVal label) |
gpointer | gfsm_alphabet_get_key (gfsmAlphabet *a, gfsmLabelVal label) |
void | gfsm_alphabet_remove_key (gfsmAlphabet *a, gconstpointer key) |
void | gfsm_alphabet_remove_label (gfsmAlphabet *a, gfsmLabelVal label) |
gfsmAlphabet * | gfsm_alphabet_union (gfsmAlphabet *a1, gfsmAlphabet *a2) |
gboolean | gfsm_alphabet_foreach_union_func (gfsmAlphabet *src, gpointer src_key, gfsmLabelVal src_id, gfsmAlphabet *dst) |
void | gfsm_alphabet_labels_to_array (gfsmAlphabet *alph, GPtrArray *ary) |
String Alphabet Utilities |
#define | gfsm_alphabet_gstring_to_labels(abet, gstr, vec, warn) gfsm_alphabet_string_to_labels((abet),(gstr)->str,(vec),(warn)) |
gfsmLabelVector * | gfsm_alphabet_string_to_labels (gfsmAlphabet *abet, const gchar *str, gfsmLabelVector *vec, gboolean warn_on_undefined) |
gfsmLabelVector * | gfsm_alphabet_att_string_to_labels (gfsmAlphabet *abet, const gchar *str, gfsmLabelVector *vec, gboolean warn_on_undefined) |
gfsmLabelVector * | gfsm_alphabet_generic_string_to_labels (gfsmAlphabet *abet, const gchar *str, gfsmLabelVector *vec, gboolean warn_on_undefined, gboolean att_mode) |
GString * | gfsm_alphabet_labels_to_gstring (gfsmAlphabet *abet, gfsmLabelVector *vec, GString *gstr, gboolean warn_on_undefined, gboolean att_style) |
char * | gfsm_alphabet_labels_to_string (gfsmAlphabet *abet, gfsmLabelVector *vec, gboolean warn_on_undefined, gboolean att_style) |
void | gfsm_alphabet_label_to_gstring (gfsmAlphabet *abet, gfsmLabelVal lab, GString *gstr, gboolean warn_on_undefined, gboolean att_style, GString *gsym) |
Detailed Description
Macro Definition Documentation
Create and initialize a new identity alphabet. You do not need to call an init() function for the returned alphabet.
Create and initialize a new string alphabet. You do not need to call an init() function for the returned alphabet.
Create and initialize a new string alphabet which copies keys. You do not need to call an init() function for the returned alphabet.
#define gfsm_range_alphabet_new |
( |
| ) |
|
Value:
gfsmNoLabel, gfsmNoLabel)
Create and initialize a new range alphabet. You do not need to call an init() function for the returned alphabet.
#define gfsm_pointer_alphabet_new |
( |
|
key_dup_f, |
|
|
|
key_hash_f, |
|
|
|
key_eq_f, |
|
|
|
key_free_f |
|
) |
| |
Value:
key_dup_f, key_hash_f, key_eq_f, key_free_f)
Create and initialize a new pointer alphabet. You do not need to call an init() function for the returned alphabet.
Get label for key or assign a new one if none exists.
- Returns
- label for key
Convert an ASCII GString character-wise to a vector of (gfsmLabel)s. vec is not cleared – use g_ptr_array_set_size() for that.
- Returns
- vec if non-NULL, otherwise a new gfsmLabelVector. abet should be a gfsmStringAlphabet.
Typedef Documentation
Type for key-duplication functions
Type for alphabet (key->label) lookup functions
Type for alphabet (label->key) lookup functions
Type for alphabet insertion functions
Type for alphabet key removal functions (unused)
Type for alphabet label removal functions
typedef gpointer(* gfsmAlphabetKeyReadFunc)(struct gfsmUserAlphabet_ *a, GString *gstr) |
Type for alphabet string input functions (should return a static key)
typedef void(* gfsmAlphabetKeyWriteFunc)(struct gfsmUserAlphabet_ *a, gconstpointer key, GString *str) |
Type for alphabet string output functions (should write to )
Type for alphabet iterator functions. Functions should return TRUE to stop the traversal
Enumeration Type Documentation
Enumeration of builtin alphabet types
- Enumerator:
gfsmATUnknown |
unknown alphabet type
|
gfsmATRange |
alphabet type for label ranges
|
gfsmATIdentity |
alphabet type for sparse identity alphabets
|
gfsmATPointer |
pointer-hashing alphabet
|
gfsmATString |
string alphabet
|
gfsmATUser |
user-defined alphabet
|
Function Documentation
Create a new alphabet. The alphabet will be uninitialized until you call one of the gfsm_*_alphabet_init() functions.
- Parameters
-
type | Type of alphabet to create. |
Initialize a builtin alphabet (depending on a->type) This really only works well for identity, range, and string alphabets, as well as for literal pointer alphabets (without copy and/or free) and for user alphabets using literal pointers.
Initialize a range alphabet
Initialize a sparse identity alphabet
Initialize a pointer alphabet
Initialize a string alphabet
Initialize a user alphabet
foreach utility function to clear user alphabets
General iteration utility
gpointer gfsm_alphabet_strdup |
( |
gfsmAlphabet * |
a, |
|
|
const gchar * |
str |
|
) |
| |
dup function for string alphabets
Get number of elements in the alphabet
Utility for counting size of user alphabets (linear time)
Insert a (key,label) pair into the alphabet. If label is gfsmNoLabel, a new label will be assigned.
- Note
- No sanity checks are performed.
- Returns
- the new label for key
Get or assign a label for key. If label is gfsmNoLabel, a new label will be assigned for key if none exists.
- Returns
- label for key
Lookup label for key.
- Returns
- label for key, or gfsmNoLabel if none is defined.
Lookup key for label
- Returns
- pointer to key for label, or NULL if no key is defined.
Get key for label or assign gfsmNoKey if none exists.
- Returns
- key for label
void gfsm_alphabet_remove_key |
( |
gfsmAlphabet * |
a, |
|
|
gconstpointer |
key |
|
) |
| |
Remove mapping for key (and associated label, if any)
Remove mapping for label (and associated key, if any)
Add all keys from alphabet a2 to a1.
- Returns
- a1
foreach utility func for union()
void gfsm_alphabet_labels_to_array |
( |
gfsmAlphabet * |
alph, |
|
|
GPtrArray * |
ary |
|
) |
| |
Append all defined labels to a GPtrArray of (gfsmLabelVal)s
gpointer gfsm_alphabet_string2key |
( |
gfsmAlphabet * |
a, |
|
|
GString * |
gstr |
|
) |
| |
Convert a string to a temporary key, used by load(). If you allocate anything here, you need to free it yourself.
void gfsm_alphabet_key2string |
( |
gfsmAlphabet * |
a, |
|
|
gpointer |
key, |
|
|
GString * |
gstr |
|
) |
| |
Convert a key to a constant string, used by save()
Load a string alphabet from a stream. Returns true on success
Load a string alphabet from a stream. Returns true on success
Load a string alphabet from a named file
Save a string alphabet to a gfsmIOHandle*
Save a string alphabet to a stream (uncompressed)
Save a string alphabet to a (compressed) stream
Save a string alphabet to a named file (uncompressed)
gboolean gfsm_alphabet_save_filename_full |
( |
gfsmAlphabet * |
a, |
|
|
const gchar * |
filename, |
|
|
int |
zlevel, |
|
|
gfsmError ** |
errp |
|
) |
| |
Save a string alphabet to a (compressed) named file
Convert an ASCII string character-wise to a vector of (gfsmLabel)s. vec is not cleared – use g_ptr_array_set_size() for that.
- Returns
- vec if non-NULL, otherwise a new gfsmLabelVector. abet should be a gfsmStringAlphabet.
Convert an ASCII string in AT&T syntax to a vector of (gfsmLabel)s. vec is not cleared – use g_ptr_array_set_size() for that.
- Returns
- vec if non-NULL, otherwise a new gfsmLabelVector. abet should be a gfsmStringAlphabet.
GString* gfsm_alphabet_labels_to_gstring |
( |
gfsmAlphabet * |
abet, |
|
|
gfsmLabelVector * |
vec, |
|
|
GString * |
gstr, |
|
|
gboolean |
warn_on_undefined, |
|
|
gboolean |
att_style |
|
) |
| |
Convert a gfsmLabelVector to a GString. gstr is not cleared.
- Returns
- gstr if non-NULL, otherwise a new GString*. abet should be a gfsmStringAlphabet.
Convert a gfsmLabelVector to a new string. gstr is not cleared.
- Returns
- gstr if non-NULL, otherwise a new GString*. abet should be a gfsmStringAlphabet.
void gfsm_alphabet_label_to_gstring |
( |
gfsmAlphabet * |
abet, |
|
|
gfsmLabelVal |
lab, |
|
|
GString * |
gstr, |
|
|
gboolean |
warn_on_undefined, |
|
|
gboolean |
att_style, |
|
|
GString * |
gsym |
|
) |
| |
Append a single gfsmLabelVal to a GString*.
- gstr is not cleared.
- gsym is a temporary which may be overwritten by this function
- Returns
- gstr if non-NULL, otherwise a new GString*.
- Note
- abet should really be a gfsmStringAlphabet.
Variable Documentation