/Users/huttone/Devel/sedflux-new/sedflux/trunk/ew/utils/eh_dlm_file.h File Reference

#include <glib.h>
#include <utils/eh_symbol_table.h>
#include <utils/eh_grid.h>

Go to the source code of this file.

Functions

double ** eh_dlm_read (const gchar *file, gchar *delims, gint *n_rows, gint *n_cols, GError **error)
double ** eh_dlm_read_swap (const gchar *file, gchar *delims, gint *n_rows, gint *n_cols, GError **error)
double *** eh_dlm_read_full (const gchar *file, gchar *delims, gint **n_rows, gint **n_cols, gchar ***rec_data, gint max_records, GError **err)
double *** eh_dlm_read_full_swap (const gchar *file, gchar *delims, gint **n_rows, gint **n_cols, gchar ***rec_data, gint max_records, GError **err)
gint eh_str_count_chr (gchar *str, gchar *end, gint delim)
gchar * eh_dlm_remove_empty_lines (gchar *content)
gchar * eh_str_remove_to_eol_comments (gchar *content, gchar *com_start)
gchar * eh_str_remove_c_style_comments (gchar *content)
gchar * eh_str_remove_comments (gchar *content, const gchar *start_str, const gchar *end_str, gchar ***comments)
gchar ** eh_strv_append (gchar ***str_l, gchar *new_str)
Eh_symbol_table eh_str_parse_key_value (gchar *str, gchar *delim_1, gchar *delim_2)
gchar * eh_str_replace (gchar *str, gchar old_c, gchar new_c)
gchar * eh_str_remove (gchar *str, gchar *start, gint n)
gchar * eh_str_remove_blocks (gchar *str, gchar **block_start, gchar **block_end)
gint eh_dlm_print (const gchar *file, const gchar *delim, const double **data, const gint n_rows, const gint n_cols, GError **error)
gint eh_dlm_print_swap (const gchar *file, const gchar *delim, const double **data, const gint n_rows, const gint n_cols, GError **error)
gint eh_dlm_print_full (const gchar *file, const gchar *delim, const double **data, const gint n_rows, const gint n_cols, gboolean swap, GError **error)
gint eh_dlm_print_dbl_grid (const gchar *file, const gchar *delim, Eh_dbl_grid g, GError **error)


Function Documentation

gint eh_dlm_print ( const gchar *  file,
const gchar *  delim,
const double **  data,
const gint  n_rows,
const gint  n_cols,
GError **  error 
)

Definition at line 530 of file eh_dlm_file.c.

References eh_dlm_print_full().

Referenced by _print_sediment_column(), bio_print_layers(), and eh_dlm_print_dbl_grid().

gint eh_dlm_print_dbl_grid ( const gchar *  file,
const gchar *  delim,
Eh_dbl_grid  g,
GError **  error 
)

Definition at line 596 of file eh_dlm_file.c.

References eh_dbl_grid_data(), eh_dlm_print(), eh_grid_n_x(), eh_grid_n_y(), eh_require, and eh_return_val_if_fail.

Referenced by main().

gint eh_dlm_print_full ( const gchar *  file,
const gchar *  delim,
const double **  data,
const gint  n_rows,
const gint  n_cols,
gboolean  swap,
GError **  error 
)

Definition at line 542 of file eh_dlm_file.c.

References eh_fopen_error(), eh_require, and eh_return_val_if_fail.

Referenced by eh_dlm_print(), and eh_dlm_print_swap().

gint eh_dlm_print_swap ( const gchar *  file,
const gchar *  delim,
const double **  data,
const gint  n_rows,
const gint  n_cols,
GError **  error 
)

Definition at line 536 of file eh_dlm_file.c.

References eh_dlm_print_full().

Referenced by bio_print_output().

double** eh_dlm_read ( const gchar *  file,
gchar *  delims,
gint *  n_rows,
gint *  n_cols,
GError **  err 
)

Read a delimited file

Read data from the ASCII file file. Data are written row-by-row with each column delimited by any of the characters contained in delims. The number of columns is determined by the line with the largest number of elements. Rows with fewer columns are padded with zeros.

Parameters:
file The name of the data file
delims A string of possible delimeters
n_rows Location to put the number of rows read
n_cols Location to put the number of columns read
err Retrun location for a GError, or NULL
Returns:
A 2d array of the data scanned from the file. Use eh_free_2 to free.
See also:
eh_dlm_read_swap

Definition at line 67 of file eh_dlm_file.c.

References eh_dlm_read_full(), eh_free, and eh_return_val_if_fail.

Referenced by _scan_sediment_column(), avulsion_full(), eh_dlm_read_swap(), and sed_bathy_grid_scan_2d_ascii().

double*** eh_dlm_read_full ( const gchar *  file,
gchar *  delims,
gint **  n_rows,
gint **  n_cols,
gchar ***  rec_data,
gint  max_records,
GError **  err 
)

Read multiple records from a text delimited file

Similar to eh_dlm_read except that multiple records can be present within the text file. Records begin with a head that is enclosed by square brackets. The data are read with the same format as that used by eh_dlm_read.

Parameters:
file The name of the data file
delims A string of possible delimeters
n_rows Location to put the array of number of rows read
n_cols Location to put the array of number of columns read
rec_data Location to hold a NULL-terminated array header strings
max_records If greater than 0, the maximum number of records to scan. If less than 0, all of the records will be scanned.
err Retrun location for a GError, or NULL
Returns:
A 2d array of the data scanned from the file. Use eh_free_2 to free.
See also:
eh_dlm_read, eh_dlm_read_full_swap

Definition at line 181 of file eh_dlm_file.c.

References eh_dlm_prepare(), eh_dlm_read_data(), eh_dlm_split_records(), eh_free, eh_new, and eh_return_val_if_fail.

Referenced by eh_dlm_read(), and eh_dlm_read_full_swap().

double*** eh_dlm_read_full_swap ( const gchar *  file,
gchar *  delims,
gint **  n_rows,
gint **  n_cols,
gchar ***  rec_data,
gint  max_records,
GError **  err 
)

Read multiple records from a text delimited file and swap rows and columns

Same as eh_dlm_read_full except that the rows and columns of the output matrices are swapped.

Parameters:
file The name of the data file
delims A string of possible delimeters
n_rows Location to put the array of number of rows read
n_cols Location to put the array of number of columns read
rec_data Location to hold a NULL-terminated array header strings
max_records If greater than 0, the maximum number of records to scan. If less than 0, all of the records will be scanned.
err Retrun location for a GError, or NULL
Returns:
A 2d array of the data scanned from the file. Use eh_free_2 to free.
See also:
eh_dlm_read_swap, eh_dlm_read_full

Definition at line 255 of file eh_dlm_file.c.

References eh_dlm_read_full(), eh_free, eh_free_2, eh_new, eh_new_2, eh_return_val_if_fail, and EH_SWAP_PTR.

Referenced by sed_get_floor_sequence_2().

double** eh_dlm_read_swap ( const gchar *  file,
gchar *  delims,
gint *  n_rows,
gint *  n_cols,
GError **  err 
)

Read a delimited file and swap rows and columns

Same as eh_dlm_read except that the rows and columns are swapped. That is, what were columns in the file are now rows in the returned matrix.

Parameters:
file The name of the data file
delims A string of possible delimeters
n_rows Location to put the number of rows read
n_cols Location to put the number of columns read
err Retrun location for a GError, or NULL
Returns:
A 2d array of the data scanned from the file. Use eh_free_2 to free.
See also:
eh_dlm_read

Definition at line 119 of file eh_dlm_file.c.

References eh_dlm_read(), eh_free_2, eh_new_2, and eh_return_val_if_fail.

Referenced by bio_scan_column_file(), eh_input_val_set(), inflow_scan_bathy_file(), sakura_scan_bathy_file(), sed_bathy_grid_scan_1d_ascii(), and sed_scan_sea_level_curve().

gchar* eh_dlm_remove_empty_lines ( gchar *  str  ) 

Remove empty lines from a string

This function does not allocate or reallocate any memory. It modifies str in place. The pointer to str is returned to allow the nesting of functions.

Parameters:
str A string to remove empty lines from.
Returns:
str

Definition at line 414 of file eh_dlm_file.c.

References eh_free, eh_new0, and eh_str_remove_blocks().

Referenced by eh_dlm_prepare().

gint eh_str_count_chr ( gchar *  str,
gchar *  end,
gint  delim 
)

Count the number of occurances of a character in a string

Count the number of times delim occurs from str up to and including end.

Parameters:
str The start of the string
end The end of the string
delim The character to look for
Returns:
The number of occurances of the character in the string

Definition at line 581 of file eh_str.c.

Referenced by eh_dlm_find_n_cols(), and eh_dlm_find_n_rows().

Eh_symbol_table eh_str_parse_key_value ( gchar *  str,
gchar *  delim_1,
gchar *  delim_2 
)

Parse a string into key-value pairs

Key-value pairs are separated by the delimiter, delim_2. The keys and values are separated by delim_1. A Eh_symbol_table is created that holds all of the key-value pairs.

Parameters:
str A string to parse.
delim_1 The delimiter that separates keys from values.
delim_2 The delimiter that separates key-value pairs from one another.
Returns:
A Eh_symbol_table of key-value pairs. Use eh_symbol_table_destroy to free.

Definition at line 531 of file eh_str.c.

Referenced by sed_get_floor_sequence_2().

gchar* eh_str_remove ( gchar *  str,
gchar *  start,
gint  n 
)

Definition at line 484 of file eh_str.c.

gchar* eh_str_remove_blocks ( gchar *  str,
gchar **  block_start,
gchar **  block_end 
)

Definition at line 495 of file eh_str.c.

Referenced by eh_dlm_remove_empty_lines().

gchar* eh_str_remove_c_style_comments ( gchar *  str  ) 

Remove c-style comments from a string

Remove comments that begin with '\/\*' and end with '\*\/' This function does not allocate or reallocate any memory. It modifies str in place. The pointer to str is returned to allow the nesting of functions.

Parameters:
str A string to remove comments from.
Returns:
str

Definition at line 626 of file eh_str.c.

Referenced by eh_dlm_prepare().

gchar* eh_str_remove_comments ( gchar *  str,
const gchar *  start_str,
const gchar *  end_str,
gchar ***  comments 
)

Remove comments from a string

Remove comments that begin with start_str and end with end_str. If end_str is NULL, then each comment is assumed to end at the end of the line. This function does not allocate or reallocate any memory. It modifies str in place. The pointer to str is returned to allow the nesting of functions.

If non-NULL, the parameter comments will contain a (newly-allocated) string array of the comments that were removed. Use g_strfreev to free when no longer in use.

Parameters:
str A string to remove comments from.
start_str A string that indicates the start of a comment.
end_str A string that indicates the end of a comment (or NULL if the comment terminates at the end of its line).
comments Location to put a string array that contains the comments that were removed (or NULL).
Returns:
str

Definition at line 653 of file eh_str.c.

Referenced by eh_str_parse_key_value(), eh_str_remove_c_style_comments(), and eh_str_remove_to_eol_comments().

gchar* eh_str_remove_to_eol_comments ( gchar *  str,
gchar *  com_start 
)

Remove comments that run to the end of a line

Remove comments that begin with com_start and continue until the end of the line. This function does not allocate or reallocate any memory. It modifies str in place. The pointer to str is returned to allow the nesting of functions.

Parameters:
str A string to remove comments from.
com_start A string that marks the start of a comment.
Returns:
str

Definition at line 609 of file eh_str.c.

Referenced by eh_dlm_prepare().

gchar* eh_str_replace ( gchar *  str,
gchar  old_c,
gchar  new_c 
)

Definition at line 470 of file eh_str.c.

Referenced by eh_dlm_prepare().

gchar** eh_strv_append ( gchar ***  str_l,
gchar *  new_str 
)

Append a string to the end of an array of strings.

If str_l points to NULL, a new string array will be allocated. The location of new_str is appended to str_l rather than a copy. Thus, new_str should not be freed before str_l.

Parameters:
str_l The location of a string array, or NULL.
new_str The string to append.
Returns:
The input string_array.

Definition at line 411 of file eh_str.c.

Referenced by eh_check_to_s(), eh_dlm_split_records(), eh_key_file_scan_from_template(), eh_render_command_str(), eh_str_to_dbl_range_piecewise(), eh_str_to_time_range_piecewise(), eh_strv_concat(), eh_symbol_table_require_labels(), main(), sed_cube_all_rivers(), sed_cube_all_trunks(), sed_hydro_process_records(), sed_process_append_child(), sed_process_queue_set_families(), sed_process_queue_validate(), sed_process_render_flag_str(), sed_river_branches_helper(), and sed_river_leaves_helper().


Generated on Fri Jan 4 18:04:18 2008 for sedflux by  doxygen 1.5.2