libglom-1.30: Glom::Utils Namespace Reference

libglom-1.30 1.30.4

- Main Page
- Namespaces
- Classes

- Namespace List
- Namespace Members

Typedefs | Functions
Glom::Utils Namespace Reference

## Typedefs
typedef std::vector< std::shared_ptr< LayoutItem_Field > > | type_vecLayoutFields
typedef std::vector< std::shared_ptr< const LayoutItem_Field > > | type_vecConstLayoutFields
typedef std::vector< Gnome::Gda::Value > | type_list_values
typedef std::vector< 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)
Glib::ustring | string_clean_for_xml (const Glib::ustring& src)
| Remove any characters that may not be in XML even when escaped. More...
Gnome::Gda::SqlExpr | build_simple_where_expression (const Glib::ustring& table_name, const std::shared_ptr< 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. More...
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 std::shared_ptr< const Relationship >& extra_join=std::shared_ptr< 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. More...
Glib::RefPtr< Gnome::Gda::SqlBuilder > | build_sql_select_with_where_clause (const Glib::ustring& table_name, const type_vecConstLayoutFields& fieldsToGet, const Gnome::Gda::SqlExpr& where_clause=Gnome::Gda::SqlExpr(), const std::shared_ptr< const Relationship >& extra_join=std::shared_ptr< const Relationship >(), const type_sort_clause& sort_clause=type_sort_clause(), guint limit=0)
| Just a version of build_sql_select_with_where_clause() that takes a list of const fields. More...
Glib::RefPtr< Gnome::Gda::SqlBuilder > | build_sql_select_with_key (const Glib::ustring& table_name, const type_vecLayoutFields& fieldsToGet, const std::shared_ptr< const Field >& key_field, const Gnome::Gda::Value& key_value, const type_sort_clause& sort_clause=type_sort_clause(), guint limit=0)
Glib::RefPtr< Gnome::Gda::SqlBuilder > | build_sql_select_with_key (const Glib::ustring& table_name, const type_vecConstLayoutFields& fieldsToGet, const std::shared_ptr< 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. More...
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. More...
Gnome::Gda::SqlExpr | get_find_where_clause_quick (const Document* document, const Glib::ustring& table_name, const Gnome::Gda::Value& quick_search)
Glib::RefPtr< Gnome::Gda::SqlBuilder > | build_sql_update_with_where_clause (const Glib::ustring& table_name, const std::shared_ptr< const Field >& field, const Gnome::Gda::Value& value, const Gnome::Gda::SqlExpr& where_clause)
| Generate a SQL statement to UPDATE field values,. More...
type_list_values_with_second | get_choice_values_all (const Document* document, const std::shared_ptr< const LayoutItem_Field >& field)
type_list_values_with_second | get_choice_values (const Document* document, const std::shared_ptr< const LayoutItem_Field >& field, const Gnome::Gda::Value& foreign_key_value)
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. More...
Glib::ustring | create_name_from_title (const Glib::ustring& title)
| Guess an appropriate identifier name based on a human-readable title. More...
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. More...
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",. More...
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. More...
Glib::ustring | title_from_string (const Glib::ustring& text)
| Create an appropriate title for an ID string. More...
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 | file_exists (const Glib::RefPtr< Gio::File >& file)
bool | delete_directory (const Glib::RefPtr< Gio::File >& directory)
| Delete a directory, if it exists, and its contents. More...
bool | delete_directory (const std::string& uri)
| Delete a directory, if it exists, and its contents. More...
bool | delete_file (const std::string& uri)
| Delete a file, if it exists. More...
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. More...
Glib::ustring | get_file_uri_without_extension (const Glib::ustring& uri)
| Get a URI with the extension (any extension, not just .glom) removed. More...
std::string | get_file_path_without_extension (const std::string& filepath)
| Get a filepath with the extension (any extension, not just .glom) removed. More...
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. More...
Glib::ustring | get_list_of_layout_items_for_display (const std::shared_ptr< const LayoutGroup >& layout_group)
| Get a string to display to the user, as a representation of a list of layout items. More...
Glib::ustring | get_list_of_sort_fields_for_display (const Formatting::type_list_sort_fields& sort_fields)
| Get a string to display to the user, as a representation of a sort order. More...
LayoutGroup::type_list_const_items | get_layout_items_plus_primary_key (const LayoutGroup::type_list_const_items& items, const Document* document, const Glib::ustring& table_name)
| This returns the provided list of layout items, plus the primary key, if the primary key is not already present in the list. More...
LayoutGroup::type_list_items | get_layout_items_plus_primary_key (const LayoutGroup::type_list_items& items, const Document* document, const Glib::ustring& table_name)
| This returns the provided list of layout items, plus the primary key, if the primary key is not already present in the list. More...
std::string | get_temp_file_path (const std::string& prefix=std::string(), const std::string& extension=std::string())
Glib::ustring | get_temp_file_uri (const std::string& prefix=std::string(), const std::string& extension=std::string())
std::string | get_temp_directory_path (const std::string& prefix=std::string())
| This actually creates the directory. More...
Glib::ustring | get_temp_directory_uri (const std::string& prefix=std::string())
| This actually creates the directory. More...
bool | script_check_for_pygtk2 (const Glib::ustring& script)
bool | get_resource_exists (const std::string& resource_path)
| This is simpler than catching the exception from Gio::Resource::get_info_global(). More...
template<typename E >
constexpr std::underlying_type< E >::type | to_utype (E enumerator) noexcept

## Typedef Documentation

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

typedef std::vector< 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< std::shared_ptr<const LayoutItem_Field> > Glom::Utils::type_vecConstLayoutFields

typedef std::vector< std::shared_ptr<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 std::shared_ptr< 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 std::shared_ptr< const Field >& | key_field,
|  | const Gnome::Gda::Value & | key_value,
|  | const type_sort_clause& | sort_clause = `type_sort_clause()`,
|  | guint | limit = `0`
| ) |  |

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_key | ( | const Glib::ustring & | table_name,
|  | const type_vecConstLayoutFields& | fieldsToGet,
|  | const std::shared_ptr< 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.

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 std::shared_ptr< const Relationship >& | extra_join = `std::shared_ptr< 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> Glom::Utils::build_sql_select_with_where_clause | ( | const Glib::ustring & | table_name,
|  | const type_vecConstLayoutFields& | fieldsToGet,
|  | const Gnome::Gda::SqlExpr & | where_clause = `Gnome::Gda::SqlExpr()`,
|  | const std::shared_ptr< const Relationship >& | extra_join = `std::shared_ptr< const Relationship >()`,
|  | const type_sort_clause& | sort_clause = `type_sort_clause()`,
|  | guint | limit = `0`
| ) |  |

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

Glib::RefPtr<Gnome::Gda::SqlBuilder> Glom::Utils::build_sql_update_with_where_clause | ( | const Glib::ustring & | table_name,
|  | const std::shared_ptr< const Field >& | field,
|  | const Gnome::Gda::Value & | value,
|  | const Gnome::Gda::SqlExpr & | where_clause
| ) |  |

Generate a SQL statement to UPDATE field values,.

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. See also delete_file().

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

Delete a file, if it exists.

See also delete_directory().

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

bool Glom::Utils::file_exists | ( | const Glib::RefPtr< Gio::File > & | file | ) |

type_list_values_with_second Glom::Utils::get_choice_values | ( | const Document* | document,
|  | const std::shared_ptr< 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 std::shared_ptr< 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.

std::string Glom::Utils::get_file_path_without_extension | ( | const std::string & | filepath | ) |

Get a filepath with the extension (any extension, not just .glom) removed.

Glib::ustring Glom::Utils::get_file_uri_without_extension | ( | const Glib::ustring & | uri | ) |

Get a URI with the extension (any extension, not just .glom) removed.

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

LayoutGroup::type_list_const_items Glom::Utils::get_layout_items_plus_primary_key | ( | const LayoutGroup::type_list_const_items& | items,
|  | const Document* | document,
|  | const Glib::ustring & | table_name
| ) |  |

This returns the provided list of layout items, plus the primary key, if the primary key is not already present in the list.

LayoutGroup::type_list_items Glom::Utils::get_layout_items_plus_primary_key | ( | const LayoutGroup::type_list_items& | items,
|  | const Document* | document,
|  | const Glib::ustring & | table_name
| ) |  |

This returns the provided list of layout items, plus the primary key, if the primary key is not already present in the list.

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::get_list_of_layout_items_for_display | ( | const std::shared_ptr< 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_sort_fields_for_display | ( | const Formatting::type_list_sort_fields& | sort_fields | ) |

Get a string to display to the user, as a representation of a sort order.

bool Glom::Utils::get_resource_exists | ( | const std::string & | resource_path | ) |

This is simpler than catching the exception from Gio::Resource::get_info_global().

Returns
  true if the GResource exists.

std::string Glom::Utils::get_temp_directory_path | ( | const std::string & | prefix = `std::string()` | ) |

This actually creates the directory.

Glib::ustring Glom::Utils::get_temp_directory_uri | ( | const std::string & | prefix = `std::string()` | ) |

This actually creates the directory.

std::string Glom::Utils::get_temp_file_path | ( | const std::string & | prefix = `std::string()`,
|  | const std::string & | extension = `std::string()`
| ) |  |

Glib::ustring Glom::Utils::get_temp_file_uri | ( | const std::string & | prefix = `std::string()`,
|  | const std::string & | extension = `std::string()`
| ) |  |

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.

bool Glom::Utils::script_check_for_pygtk2 | ( | const Glib::ustring & | script | ) |

Returns
  true if the script is OK, or false if the script uses pygtk2, which would cause a crash, because Glom itself uses GTK+ 3.

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_clean_for_xml | ( | const Glib::ustring & | src | ) |

Remove any characters that may not be in XML even when escaped.

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.

template <typename E >

constexpr std::underlying_type<E>::type Glom::Utils::to_utype | ( | E | enumerator | ) |
| noexcept

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