# Glom::Utils Namespace Reference

## Typedefs

typedef std::vector< sharedptr < LayoutItem_Field > > | type_vecLayoutFields
typedef std::vector< sharedptr < const LayoutItem_Field > > | type_vecConstLayoutFields
typedef std::list < Gnome::Gda::Value > | type_list_values
typedef std::list< std::pair < Gnome::Gda::Value, type_list_values > > | type_list_values_with_second
typedef std::vector < Glib::ustring > | type_vec_strings

## Functions

Glib::ustring | trim_whitespace (const Glib::ustring& text)
Glib::ustring | string_replace (const Glib::ustring& src, const Glib::ustring& search_for, const Glib::ustring& replace_with)
Gnome::Gda::SqlExpr | build_simple_where_expression (const Glib::ustring& table_name, const sharedptr< const Field >& key_field, const Gnome::Gda::Value& key_value)
Gnome::Gda::SqlExpr | build_combined_where_expression (const Gnome::Gda::SqlExpr& a, const Gnome::Gda::SqlExpr& b, Gnome::Gda::SqlOperatorType op)
void | build_sql_select_add_fields_to_get (const Glib::RefPtr< Gnome::Gda::SqlBuilder >& builder, const Glib::ustring& table_name, const type_vecConstLayoutFields& fieldsToGet, const type_sort_clause& sort_clause, bool extra_join)
| Generate a SQL statement to SELECT field values, even if the fields are in related (or doubly related) records.
Glib::RefPtr < Gnome::Gda::SqlBuilder > | build_sql_select_with_where_clause (const Glib::ustring& table_name, const type_vecLayoutFields& fieldsToGet, const Gnome::Gda::SqlExpr& where_clause=Gnome::Gda::SqlExpr(), const sharedptr< const Relationship >& extra_join=sharedptr< const Relationship >(), const type_sort_clause& sort_clause=type_sort_clause(), guint limit=0)
| Generate a SQL statement to SELECT field values, even if the fields are in related (or doubly related) records, narrowing the records down with a WHERE clause.
Glib::RefPtr < Gnome::Gda::SqlBuilder > | build_sql_select_with_key (const Glib::ustring& table_name, const type_vecConstLayoutFields& fieldsToGet, const sharedptr< const Field >& key_field, const Gnome::Gda::Value& key_value, const type_sort_clause& sort_clause=type_sort_clause(), guint limit=0)
| Just a version of build_sql_select_with_key() that takes a list of const fields.
Gnome::Gda::SqlExpr | get_find_where_clause_quick (const Document* document, const Glib::ustring& table_name, const Gnome::Gda::Value& quick_search)
type_list_values_with_second | get_choice_values_all (const Document* document, const sharedptr< const LayoutItem_Field >& field)
Glib::RefPtr < Gnome::Gda::SqlBuilder > | build_sql_select_count_rows (const Glib::RefPtr< const Gnome::Gda::SqlBuilder >& sql_query)
| Build a SQL query to discover how many rows a SQL query would return if it was run.
type_list_values_with_second | get_choice_values (const Document* document, const sharedptr< const LayoutItem_Field >& field, const Gnome::Gda::Value& foreign_key_value)
std::string | sqlbuilder_get_full_query (const Glib::RefPtr< Gnome::Gda::Connection >& connection, const Glib::ustring& query, const Glib::RefPtr< const Gnome::Gda::Set >& params)
| Get the full query string suitable for use with std::cout.
std::string | sqlbuilder_get_full_query (const Glib::RefPtr< const Gnome::Gda::SqlBuilder >& builder)
| Get the full query string suitable for use with std::cout.
Glib::ustring | create_name_from_title (const Glib::ustring& title)
| Guess an appropriate identifier name based on a human-readable title.
Glib::ustring | string_escape_underscores (const Glib::ustring& text)
Glib::ustring | locale_simplify (const Glib::ustring& locale_id)
| Get just the first part of a locale, such as de_DE, ignoring, for instance, .UTF-8 or @euro at the end.
Glib::ustring | locale_language_id (const Glib::ustring& locale_id)
| Get just the language ID part of a locale, such as de from "de_DE",.
Glib::ustring | create_local_image_uri (const Gnome::Gda::Value&value)
Glib::ustring | string_from_decimal (guint decimal)
| Get a decimal text representation of the number, in the current locale.
Glib::ustring | title_from_string (const Glib::ustring& text)
| Create an appropriate title for an ID string.
type_vec_strings | string_separate (const Glib::ustring& str, const Glib::ustring& separator, bool ignore_quoted_separator=false)
Glib::ustring | string_trim (const Glib::ustring& str, const Glib::ustring& to_remove)
Glib::ustring | string_remove_suffix (const Glib::ustring& str, const Glib::ustring& suffix, bool case_sensitive=true)
bool | file_exists (const Glib::ustring& uri)
bool | delete_directory (const Glib::RefPtr< Gio::File >& directory)
| Delete a directory, if it exists, and its contents.
bool | delete_directory (const std::string& uri)
| Delete a directory, if it exists, and its contents.
Glib::ustring | get_directory_child_with_suffix (const Glib::ustring& uri_directory, const std::string& suffix, bool recursive)
| For instance, to find the first file in the directory with a .glom extension.
Glib::ustring | get_list_of_layout_items_for_display (const LayoutGroup::type_list_items& list_layout_fields)
| Get a string to display to the user, as a representation of a list of layout items.
Glib::ustring | get_list_of_layout_items_for_display (const sharedptr< const LayoutGroup >& layout_group)
| Get a string to display to the user, as a representation of a list of layout items.

## Typedef Documentation

typedef std::list<Gnome::Gda::Value> Glom::Utils::type_list_values

typedef std::list< std::pair<Gnome::Gda::Value, type_list_values> > Glom::Utils::type_list_values_with_second

typedef std::vector<Glib::ustring> Glom::Utils::type_vec_strings

typedef std::vector< sharedptr<const LayoutItem_Field> > Glom::Utils::type_vecConstLayoutFields

typedef std::vector< sharedptr<LayoutItem_Field> > Glom::Utils::type_vecLayoutFields

## Function Documentation

Gnome::Gda::SqlExpr Glom::Utils::build_combined_where_expression | ( | const Gnome::Gda::SqlExpr & | a,
|  | const Gnome::Gda::SqlExpr & | b,
|  | Gnome::Gda::SqlOperatorType | op
| ) |  |

Gnome::Gda::SqlExpr Glom::Utils::build_simple_where_expression | ( | const Glib::ustring & | table_name,
|  | const sharedptr< const Field > & | key_field,
|  | const Gnome::Gda::Value & | key_value
| ) |  |

void Glom::Utils::build_sql_select_add_fields_to_get | ( | const Glib::RefPtr< Gnome::Gda::SqlBuilder > & | builder,
|  | const Glib::ustring & | table_name,
|  | const type_vecConstLayoutFields & | fieldsToGet,
|  | const type_sort_clause & | sort_clause,
|  | bool | extra_join
| ) |  |

Generate a SQL statement to SELECT field values, even if the fields are in related (or doubly related) records.

Glib::RefPtr<Gnome::Gda::SqlBuilder> Glom::Utils::build_sql_select_count_rows | ( | const Glib::RefPtr< const Gnome::Gda::SqlBuilder > & | sql_query ) |

Build a SQL query to discover how many rows a SQL query would return if it was run.

This uses a COUNT * on a the sql_query as a sub-statement. Be careful not to include ORDER BY clauses in the supplied SQL query, because that would make it unnecessarily slow.

A SQL query.

Returns:
  The number of rows.

Glib::RefPtr< Gnome::Gda::SqlBuilder > Glom::Utils::build_sql_select_with_key | ( | const Glib::ustring & | table_name,
|  | const type_vecLayoutFields & | fieldsToGet,
|  | const sharedptr< const Field > & | key_field,
|  | const Gnome::Gda::Value & | key_value,
|  | const type_sort_clause & | sort_clause = `type_sort_clause()`,
|  | guint | limit = `0`
| ) |  |

Just a version of build_sql_select_with_key() that takes a list of const fields.

Parameters:

  key_value | If this is empty then all records in the tables will be retrieved.

Glib::RefPtr< Gnome::Gda::SqlBuilder > Glom::Utils::build_sql_select_with_where_clause | ( | const Glib::ustring & | table_name,
|  | const type_vecLayoutFields & | fieldsToGet,
|  | const Gnome::Gda::SqlExpr & | where_clause = `Gnome::Gda::SqlExpr()`,
|  | const sharedptr< const Relationship > & | extra_join = `sharedptr< const Relationship >()`,
|  | const type_sort_clause & | sort_clause = `type_sort_clause()`,
|  | guint | limit = `0`
| ) |  |

Generate a SQL statement to SELECT field values, even if the fields are in related (or doubly related) records, narrowing the records down with a WHERE clause.

Just a version of build_sql_select_with_where_clause() that takes a list of const fields.

Glib::ustring Glom::Utils::create_local_image_uri | ( | const Gnome::Gda::Value & | value ) |

Glib::ustring Glom::Utils::create_name_from_title | ( | const Glib::ustring & | title ) |

Guess an appropriate identifier name based on a human-readable title.

bool Glom::Utils::delete_directory | ( | const Glib::RefPtr< Gio::File > & | directory ) |

Delete a directory, if it exists, and its contents.

Unlike g_file_delete(), this does not fail if the directory is not empty.

bool Glom::Utils::delete_directory | ( | const std::string & | uri ) |

Delete a directory, if it exists, and its contents.

Unlike g_file_delete(), this does not fail if the directory is not empty.

bool Glom::Utils::file_exists | ( | const Glib::ustring & | uri ) |

type_list_values_with_second Glom::Utils::get_choice_values | ( | const Document * | document,
|  | const sharedptr< const LayoutItem_Field > & | field,
|  | const Gnome::Gda::Value & | foreign_key_value
| ) |  |

type_list_values_with_second Glom::Utils::get_choice_values_all | ( | const Document * | document,
|  | const sharedptr< const LayoutItem_Field > & | field
| ) |  |

Glib::ustring Glom::Utils::get_directory_child_with_suffix | ( | const Glib::ustring & | uri_directory,
|  | const std::string & | suffix,
|  | bool | recursive
| ) |  |

For instance, to find the first file in the directory with a .glom extension.

Gnome::Gda::SqlExpr Glom::Utils::get_find_where_clause_quick | ( | const Document * | document,
|  | const Glib::ustring & | table_name,
|  | const Gnome::Gda::Value & | quick_search
| ) |  |

Glib::ustring Glom::Utils::get_list_of_layout_items_for_display | ( | const sharedptr< const LayoutGroup > & | layout_group ) |

Get a string to display to the user, as a representation of a list of layout items.

Glib::ustring Glom::Utils::get_list_of_layout_items_for_display | ( | const LayoutGroup::type_list_items & | list_layout_fields ) |

Get a string to display to the user, as a representation of a list of layout items.

Glib::ustring Glom::Utils::locale_language_id | ( | const Glib::ustring & | locale_id ) |

Get just the language ID part of a locale, such as de from "de_DE",.

Glib::ustring Glom::Utils::locale_simplify | ( | const Glib::ustring & | locale_id ) |

Get just the first part of a locale, such as de_DE, ignoring, for instance, .UTF-8 or @euro at the end.

std::string Glom::Utils::sqlbuilder_get_full_query | ( | const Glib::RefPtr< Gnome::Gda::Connection > & | connection,
|  | const Glib::ustring & | query,
|  | const Glib::RefPtr< const Gnome::Gda::Set > & | params
| ) |  |

Get the full query string suitable for use with std::cout.

std::string Glom::Utils::sqlbuilder_get_full_query | ( | const Glib::RefPtr< const Gnome::Gda::SqlBuilder > & | builder ) |

Get the full query string suitable for use with std::cout.

Glib::ustring Glom::Utils::string_escape_underscores | ( | const Glib::ustring & | text ) |

Glib::ustring Glom::Utils::string_from_decimal | ( | guint | decimal ) |

Get a decimal text representation of the number, in the current locale.

Glib::ustring Glom::Utils::string_remove_suffix | ( | const Glib::ustring & | str,
|  | const Glib::ustring & | suffix,
|  | bool | case_sensitive = `true`
| ) |  |

Glib::ustring Glom::Utils::string_replace | ( | const Glib::ustring & | src,
|  | const Glib::ustring & | search_for,
|  | const Glib::ustring & | replace_with
| ) |  |

type_vec_strings Glom::Utils::string_separate | ( | const Glib::ustring & | str,
|  | const Glib::ustring & | separator,
|  | bool | ignore_quoted_separator = `false`
| ) |  |

Glib::ustring Glom::Utils::string_trim | ( | const Glib::ustring & | str,
|  | const Glib::ustring & | to_remove
| ) |  |

Glib::ustring Glom::Utils::title_from_string | ( | const Glib::ustring & | text ) |

Create an appropriate title for an ID string.

For instance, date_of_birth would become Date Of Birth.

Glib::ustring Glom::Utils::trim_whitespace | ( | const Glib::ustring & | text ) |