Commit f9651ac3 authored by Murray Cumming's avatar Murray Cumming Committed by Murray Cumming
Browse files

GlomUtils to Glom::Utils. GlomConversions to Glom::Conversions. GlomPrivs

2006-05-27  Murray Cumming  <murrayc@murrayc.com>

        * Changed namespaces:
        GlomUtils to Glom::Utils.
        GlomConversions to Glom::Conversions.
        GlomPrivs to Glom::Privs.
parent ad20cdb5
2006-05-27 Murray Cumming <murrayc@murrayc.com>
* Changed namespaces:
GlomUtils to Glom::Utils.
GlomConversions to Glom::Conversions.
GlomPrivs to Glom::Privs.
2006-05-27 Murray Cumming <murrayc@murrayc.com>
Almost all files: Put everthing in the Glom namespace.
......
......@@ -679,7 +679,7 @@ bool App_Glom::offer_new_or_existing()
//Set suitable defaults:
const Glib::ustring filename = document->get_name(); //Get the filename without the path and extension.
dialog->set_input( GlomUtils::title_from_string( filename ) ); //Start with something suitable.
dialog->set_input( Utils::title_from_string( filename ) ); //Start with something suitable.
bool keep_asking = true;
while(keep_asking)
......@@ -693,7 +693,7 @@ bool App_Glom::offer_new_or_existing()
//Create a database name based on the title.
//The user will (almost) never see this anyway but it's nicer than using a random number:
Glib::ustring db_name = GlomUtils::create_name_from_title(db_title);
Glib::ustring db_name = Utils::create_name_from_title(db_title);
//Prefix glom_ to the database name, so it's more obvious
//for the system administrator.
......@@ -1002,7 +1002,7 @@ void App_Glom::fill_menu_tables()
ui_description += "<menuitem action='" + action_name + "' />";
Glib::RefPtr<Gtk::Action> refAction = Gtk::Action::create(action_name, GlomUtils::string_escape_underscores(table_info->get_title_or_name()));
Glib::RefPtr<Gtk::Action> refAction = Gtk::Action::create(action_name, Utils::string_escape_underscores(table_info->get_title_or_name()));
m_refNavTablesActionGroup->add(refAction,
sigc::bind( sigc::mem_fun(*m_pFrame, &Frame_Glom::on_box_tables_selected), table_info->get_name()) );
......@@ -1065,7 +1065,7 @@ void App_Glom::fill_menu_reports(const Glib::ustring& table_name)
ui_description += "<menuitem action='" + action_name + "' />";
Glib::RefPtr<Gtk::Action> refAction = Gtk::Action::create( action_name, GlomUtils::string_escape_underscores(report->get_title_or_name()));
Glib::RefPtr<Gtk::Action> refAction = Gtk::Action::create( action_name, Utils::string_escape_underscores(report->get_title_or_name()));
m_refNavReportsActionGroup->add(refAction,
sigc::bind( sigc::mem_fun(*m_pFrame, &Frame_Glom::on_menu_report_selected), report->get_name()) );
......
......@@ -644,7 +644,7 @@ bool Base_DB::add_standard_groups()
//Add the glom_developer group if it does not exist:
const Glib::ustring devgroup = GLOM_STANDARD_GROUP_NAME_DEVELOPER;
const type_vecStrings vecGroups = GlomPrivs::get_database_groups();
const type_vecStrings vecGroups = Privs::get_database_groups();
type_vecStrings::const_iterator iterFind = std::find(vecGroups.begin(), vecGroups.end(), devgroup);
if(iterFind == vecGroups.end())
{
......@@ -683,7 +683,7 @@ bool Base_DB::add_standard_groups()
{
const Glib::ustring table_name = table_info->get_name();
if(get_table_exists_in_database(table_name)) //Maybe the table has not been created yet.
GlomPrivs::set_table_privileges(devgroup, table_name, priv_devs, true /* developer privileges */);
Privs::set_table_privileges(devgroup, table_name, priv_devs, true /* developer privileges */);
}
}
......@@ -702,7 +702,7 @@ Gnome::Gda::Value Base_DB::auto_increment_insert_first_if_necessary(const Glib::
Gnome::Gda::Value value;
//Check that the user is allowd to view and edit this table:
Privileges table_privs = GlomPrivs::get_current_privs(GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME);
Privileges table_privs = Privs::get_current_privs(GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME);
if(!table_privs.m_view || !table_privs.m_edit)
{
//This should not happen:
......@@ -732,7 +732,7 @@ Gnome::Gda::Value Base_DB::auto_increment_insert_first_if_necessary(const Glib::
//GdaNumeric is a pain, so we take a short-cut:
bool success = false;
value = GlomConversions::parse_value(Field::TYPE_NUMERIC, "0", success, true /* iso_format */);
value = Conversions::parse_value(Field::TYPE_NUMERIC, "0", success, true /* iso_format */);
}
else
{
......@@ -755,11 +755,11 @@ void Base_DB::recalculate_next_auto_increment_value(const Glib::ustring& table_n
{
//Increment it:
const Gnome::Gda::Value value_max = datamodel->get_value_at(0, 0);
long num_max = GlomUtils::decimal_from_string(value_max.to_string()); //TODO: Is this sensible? Probably not.
long num_max = Utils::decimal_from_string(value_max.to_string()); //TODO: Is this sensible? Probably not.
++num_max;
//Set it in the glom system table:
const Gnome::Gda::Value next_value = GlomConversions::parse_value(num_max);
const Gnome::Gda::Value next_value = Conversions::parse_value(num_max);
const Glib::ustring sql_query = "UPDATE \"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME "\" SET "
"\"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_NEXT_VALUE "\" = " + next_value.to_string() + //TODO: Don't use to_string().
" WHERE \"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_TABLE_NAME "\" = '" + table_name + "' AND "
......@@ -781,12 +781,12 @@ Gnome::Gda::Value Base_DB::get_next_auto_increment_value(const Glib::ustring& ta
{
const Gnome::Gda::Value result = auto_increment_insert_first_if_necessary(table_name, field_name);
long num_result = 0;
num_result = GlomUtils::decimal_from_string(result.to_string()); //TODO: Is this sensible? Probably not.
num_result = Utils::decimal_from_string(result.to_string()); //TODO: Is this sensible? Probably not.
//Increment the next_value:
++num_result;
const Gnome::Gda::Value next_value = GlomConversions::parse_value(num_result);
const Gnome::Gda::Value next_value = Conversions::parse_value(num_result);
const Glib::ustring sql_query = "UPDATE \"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME "\" SET "
"\"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_NEXT_VALUE "\" = " + next_value.to_string() +
......@@ -810,7 +810,7 @@ SystemPrefs Base_DB::get_database_preferences() const
SystemPrefs result;
//Check that the user is allowd to even view this table:
Privileges table_privs = GlomPrivs::get_current_privs(GLOM_STANDARD_TABLE_PREFS_TABLE_NAME);
Privileges table_privs = Privs::get_current_privs(GLOM_STANDARD_TABLE_PREFS_TABLE_NAME);
if(!table_privs.m_view)
return result;
......@@ -833,14 +833,14 @@ SystemPrefs Base_DB::get_database_preferences() const
Glib::RefPtr<Gnome::Gda::DataModel> datamodel = query_execute(sql_query);
if(datamodel && (datamodel->get_n_rows() != 0))
{
result.m_name = GlomConversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(0, 0));
result.m_org_name = GlomConversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(1, 0));
result.m_org_address_street = GlomConversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(2, 0));
result.m_org_address_street2 = GlomConversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(3, 0));
result.m_org_address_town = GlomConversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(4, 0));
result.m_org_address_county = GlomConversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(5, 0));
result.m_org_address_country = GlomConversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(6, 0));
result.m_org_address_postcode = GlomConversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(7, 0));
result.m_name = Conversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(0, 0));
result.m_org_name = Conversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(1, 0));
result.m_org_address_street = Conversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(2, 0));
result.m_org_address_street2 = Conversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(3, 0));
result.m_org_address_town = Conversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(4, 0));
result.m_org_address_county = Conversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(5, 0));
result.m_org_address_country = Conversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(6, 0));
result.m_org_address_postcode = Conversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(7, 0));
//We need to be more clever about these column indexes if we add more new fields:
if(optional_org_logo)
......@@ -1006,7 +1006,7 @@ bool Base_DB::insert_example_data(const Glib::ustring& table_name) const
}
//Actually insert the data:
type_vecStrings vec_rows = GlomUtils::string_separate(example_rows, "\n");
type_vecStrings vec_rows = Utils::string_separate(example_rows, "\n");
for(type_vecStrings::const_iterator iter = vec_rows.begin(); iter != vec_rows.end(); ++iter)
{
......@@ -1394,7 +1394,7 @@ void Base_DB::get_table_fields_to_show_for_sequence_add_group(const Glib::ustrin
//TODO_Performance: We do this once for each related field, even if there are 2 from the same table:
const Privileges privs_related = GlomPrivs::get_current_privs(item_field->get_table_used(table_name));
const Privileges privs_related = Privs::get_current_privs(item_field->get_table_used(table_name));
layout_item->m_priv_view = privs_related.m_view;
layout_item->m_priv_edit = privs_related.m_edit;
......@@ -1451,7 +1451,7 @@ Base_DB::type_vecLayoutFields Base_DB::get_table_fields_to_show_for_sequence(con
//Get field definitions from the database, with corrections from the document:
type_vecFields all_fields = get_fields_for_table(table_name);
const Privileges table_privs = GlomPrivs::get_current_privs(table_name);
const Privileges table_privs = Privs::get_current_privs(table_name);
//Get fields that the document says we should show:
type_vecLayoutFields result;
......@@ -1560,7 +1560,7 @@ void Base_DB::calculate_field_in_all_records(const Glib::ustring& table_name, co
for(int row = 0; row < rows_count; ++row)
{
const Gnome::Gda::Value primary_key_value = data_model->get_value_at(0, row);
if(!GlomConversions::value_is_empty(primary_key_value))
if(!Conversions::value_is_empty(primary_key_value))
{
field_in_record.m_key_value = primary_key_value;
......@@ -1593,7 +1593,7 @@ void Base_DB::calculate_field(const LayoutFieldInRecord& field_in_record)
if(refCalcProgress.m_calc_in_progress)
{
//g_warning(" Box_Data::calculate_field(): Circular calculation detected. field_name=%s", field_name.c_str());
//refCalcProgress.m_value = GlomConversions::get_empty_value(field->get_glom_type()); //Give up.
//refCalcProgress.m_value = Conversions::get_empty_value(field->get_glom_type()); //Give up.
}
else if(refCalcProgress.m_calc_finished)
{
......@@ -1710,11 +1710,11 @@ Base_DB::type_map_fields Base_DB::get_record_field_values_for_calculation(const
fieldsToGet.push_back(layout_item);
}
if(!GlomConversions::value_is_empty(primary_key_value))
if(!Conversions::value_is_empty(primary_key_value))
{
//sharedptr<const Field> fieldPrimaryKey = get_field_primary_key();
const Glib::ustring query = GlomUtils::build_sql_select_with_key(table_name, fieldsToGet, primary_key, primary_key_value);
const Glib::ustring query = Utils::build_sql_select_with_key(table_name, fieldsToGet, primary_key, primary_key_value);
Glib::RefPtr<Gnome::Gda::DataModel> data_model = query_execute(query);
if(data_model && data_model->get_n_rows())
......@@ -1730,7 +1730,7 @@ Base_DB::type_map_fields Base_DB::get_record_field_values_for_calculation(const
//Never give a NULL-type value to the python calculation for types that don't use them:
//to prevent errors:
if(value.get_value_type() == Gnome::Gda::VALUE_TYPE_NULL)
value = GlomConversions::get_empty_value(field->get_glom_type());
value = Conversions::get_empty_value(field->get_glom_type());
field_values[field->get_name()] = value;
++col_index;
......@@ -1748,7 +1748,7 @@ Base_DB::type_map_fields Base_DB::get_record_field_values_for_calculation(const
for(Document_Glom::type_vecFields::const_iterator iter = fields.begin(); iter != fields.end(); ++iter)
{
sharedptr<const Field> field = *iter;
field_values[field->get_name()] = GlomConversions::get_empty_value(field->get_glom_type());
field_values[field->get_name()] = Conversions::get_empty_value(field->get_glom_type());
}
}
}
......@@ -1857,7 +1857,7 @@ Gnome::Gda::Value Base_DB::get_field_value_in_database(const LayoutFieldInRecord
type_vecConstLayoutFields list_fields;
sharedptr<const LayoutItem_Field> layout_item = field_in_record.m_field;
list_fields.push_back(layout_item);
const Glib::ustring sql_query = GlomUtils::build_sql_select_with_key(field_in_record.m_table_name,
const Glib::ustring sql_query = Utils::build_sql_select_with_key(field_in_record.m_table_name,
list_fields, field_in_record.m_key, field_in_record.m_key_value);
Glib::RefPtr<Gnome::Gda::DataModel> data_model = query_execute(sql_query);
......@@ -2048,7 +2048,7 @@ void Base_DB::do_lookups(const LayoutFieldInRecord& field_in_record, const Gtk::
{
const Gnome::Gda::Value value = get_lookup_value(field_in_record.m_table_name, iter->second /* relationship */, field_source /* the field to look in to get the value */, field_value /* Value of to and from fields */);
const Gnome::Gda::Value value_converted = GlomConversions::convert_value(value, layout_item->get_glom_type());
const Gnome::Gda::Value value_converted = Conversions::convert_value(value, layout_item->get_glom_type());
LayoutFieldInRecord field_in_record_to_set(layout_item, field_in_record.m_table_name /* parent table */, field_in_record.m_key, field_in_record.m_key_value);
......@@ -2123,7 +2123,7 @@ Gnome::Gda::Value Base_DB::get_lookup_value(const Glib::ustring& table_name, con
if(to_key_field)
{
//Convert the value, in case the from and to fields have different types:
const Gnome::Gda::Value value_to_key_field = GlomConversions::convert_value(key_value, to_key_field->get_glom_type());
const Gnome::Gda::Value value_to_key_field = Conversions::convert_value(key_value, to_key_field->get_glom_type());
Glib::ustring strQuery = "SELECT \"" + relationship->get_to_table() + "\".\"" + source_field->get_name() + "\" FROM \"" + relationship->get_to_table() + "\"";
strQuery += " WHERE \"" + to_key_field->get_name() + "\" = " + to_key_field->sql(value_to_key_field);
......
......@@ -94,7 +94,7 @@ void Dialog_Database_Preferences::on_treeview_cell_edited_next_value(const Glib:
const Glib::ustring table_name = row[m_columns.m_col_table];
const Glib::ustring field_name = row[m_columns.m_col_field];
const Gnome::Gda::Value next_value = GlomConversions::parse_value(new_value);
const Gnome::Gda::Value next_value = Conversions::parse_value(new_value);
const Glib::ustring sql_query = "UPDATE \"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME "\" SET "
"\"" GLOM_STANDARD_TABLE_AUTOINCREMENTS_FIELD_NEXT_VALUE "\" = " + next_value.to_string() +
......@@ -150,8 +150,8 @@ void Dialog_Database_Preferences::load_from_document()
{
Gtk::TreeModel::iterator iter = m_model_autoincrements->append();
Gtk::TreeModel::Row row = *iter;
row[m_columns.m_col_table] = GlomConversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(0, i), numeric_format);
row[m_columns.m_col_field] = GlomConversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(1, i), numeric_format);
row[m_columns.m_col_table] = Conversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(0, i), numeric_format);
row[m_columns.m_col_field] = Conversions::get_text_for_gda_value(Field::TYPE_TEXT, datamodel->get_value_at(1, i), numeric_format);
//TODO: Careful of locale:
row[m_columns.m_col_next_value] = atol(datamodel->get_value_at(2, i).to_string().c_str());
......
......@@ -63,7 +63,7 @@ void Dialog_InvalidData::set_example_data(Field::glom_field_type glom_type)
date.day = 31;
date.month = 1;
date.year = 2005;
example_text = GlomConversions::get_text_for_gda_value(glom_type, Gnome::Gda::Value(date));
example_text = Conversions::get_text_for_gda_value(glom_type, Gnome::Gda::Value(date));
break;
}
case(Field::TYPE_TIME):
......@@ -72,13 +72,13 @@ void Dialog_InvalidData::set_example_data(Field::glom_field_type glom_type)
time.hour = 13;
time.minute = 02;
time.second = 03;
example_text = GlomConversions::get_text_for_gda_value(glom_type, Gnome::Gda::Value(time));
example_text = Conversions::get_text_for_gda_value(glom_type, Gnome::Gda::Value(time));
break;
}
case(Field::TYPE_NUMERIC):
{
Gnome::Gda::Value gda_value(12345678.91);
example_text = GlomConversions::get_text_for_gda_value(glom_type, gda_value);
example_text = Conversions::get_text_for_gda_value(glom_type, gda_value);
break;
}
case(Field::TYPE_TEXT):
......
......@@ -474,7 +474,7 @@ void Frame_Glom::on_menu_userlevel_Developer(const Glib::RefPtr<Gtk::RadioAction
//Check whether the current user has developer privileges:
const ConnectionPool* connection_pool = ConnectionPool::get_instance();
bool test = GlomPrivs::get_user_is_in_group(connection_pool->get_user(), GLOM_STANDARD_GROUP_NAME_DEVELOPER);
bool test = Privs::get_user_is_in_group(connection_pool->get_user(), GLOM_STANDARD_GROUP_NAME_DEVELOPER);
if(test)
{
std::cout << "DEBUG: User=" << connection_pool->get_user() << " _is_ in the developer group on the server." << std::endl;
......@@ -531,7 +531,7 @@ void Frame_Glom::on_menu_file_export()
g_assert(pWindowApp);
//Do not try to export the data if the user may not view it:
Privileges table_privs = GlomPrivs::get_current_privs(m_table_name);
Privileges table_privs = Privs::get_current_privs(m_table_name);
if(!table_privs.m_view)
{
show_ok_dialog(_("Export Not Allowed."), _("You do not have permission to view the data in this table, so you may not export the data."), *pWindowApp, Gtk::MESSAGE_ERROR);
......@@ -574,7 +574,7 @@ void Frame_Glom::export_data_to_string(Glib::ustring& the_string, const FoundSet
if(fieldsSequence.empty())
return;
const Glib::ustring query = GlomUtils::build_sql_select_with_where_clause(found_set.m_table_name, fieldsSequence, found_set.m_where_clause, found_set.m_sort_clause);
const Glib::ustring query = Utils::build_sql_select_with_where_clause(found_set.m_table_name, fieldsSequence, found_set.m_where_clause, found_set.m_sort_clause);
//TODO: Lock the database (prevent changes) during export.
Glib::RefPtr<Gnome::Gda::DataModel> result = query_execute(query, get_app_window());
......@@ -623,7 +623,7 @@ void Frame_Glom::export_data_to_stream(std::ostream& the_stream, const FoundSet&
if(fieldsSequence.empty())
return;
const Glib::ustring query = GlomUtils::build_sql_select_with_where_clause(found_set.m_table_name, fieldsSequence, found_set.m_where_clause, found_set.m_sort_clause);
const Glib::ustring query = Utils::build_sql_select_with_where_clause(found_set.m_table_name, fieldsSequence, found_set.m_where_clause, found_set.m_sort_clause);
//TODO: Lock the database (prevent changes) during export.
Glib::RefPtr<Gnome::Gda::DataModel> result = query_execute(query, get_app_window());
......@@ -655,7 +655,7 @@ void Frame_Glom::export_data_to_stream(std::ostream& the_stream, const FoundSet&
if(layout_item->get_glom_type() == Field::TYPE_IMAGE) //This is too much data.
{
if(!GlomConversions::value_is_empty(value))
if(!Conversions::value_is_empty(value))
std::cout << " field name=" << layout_item->get_name() << ", image value not empty=" << std::endl;
}
//std::cout << " field name=" << layout_item->get_name() << ", value=" << layout_item->m_field.sql(value) << std::endl;
......@@ -1473,7 +1473,7 @@ bool Frame_Glom::create_database(const Glib::ustring& database_name, const Glib:
void Frame_Glom::on_menu_report_selected(const Glib::ustring& report_name)
{
const Privileges table_privs = GlomPrivs::get_current_privs(m_table_name);
const Privileges table_privs = Privs::get_current_privs(m_table_name);
//Don't try to print tables that the user can't view.
if(!table_privs.m_view)
......
......@@ -187,11 +187,11 @@ sharedptr<Field> GlomPostgres::postgres_change_column_extras(const Glib::ustring
GlomPostgres::type_vecStrings GlomPostgres::pg_list_separate(const Glib::ustring& str)
{
//Remove the first { and the last }:
Glib::ustring without_brackets = GlomUtils::string_trim(str, "{");
without_brackets = GlomUtils::string_trim(without_brackets, "}");
Glib::ustring without_brackets = Utils::string_trim(str, "{");
without_brackets = Utils::string_trim(without_brackets, "}");
//Get the comma-separated items:
return GlomUtils::string_separate(without_brackets, ",");
return Utils::string_separate(without_brackets, ",");
}
} //namespace Glom
......@@ -24,7 +24,7 @@
namespace Glom
{
GlomPrivs::type_vecStrings GlomPrivs::get_database_groups()
Privs::type_vecStrings Privs::get_database_groups()
{
type_vecStrings result;
......@@ -44,7 +44,7 @@ GlomPrivs::type_vecStrings GlomPrivs::get_database_groups()
return result;
}
GlomPrivs::type_vecStrings GlomPrivs::get_database_users(const Glib::ustring& group_name)
Privs::type_vecStrings Privs::get_database_users(const Glib::ustring& group_name)
{
type_vecStrings result;
......@@ -100,7 +100,7 @@ GlomPrivs::type_vecStrings GlomPrivs::get_database_users(const Glib::ustring& gr
return result;
}
void GlomPrivs::set_table_privileges(const Glib::ustring& group_name, const Glib::ustring& table_name, const Privileges& privs, bool developer_privs)
void Privs::set_table_privileges(const Glib::ustring& group_name, const Glib::ustring& table_name, const Privileges& privs, bool developer_privs)
{
if(group_name.empty() || table_name.empty())
return;
......@@ -171,7 +171,7 @@ void GlomPrivs::set_table_privileges(const Glib::ustring& group_name, const Glib
}
}
Privileges GlomPrivs::get_table_privileges(const Glib::ustring& group_name, const Glib::ustring& table_name)
Privileges Privs::get_table_privileges(const Glib::ustring& group_name, const Glib::ustring& table_name)
{
Privileges result;
......@@ -200,7 +200,7 @@ Privileges GlomPrivs::get_table_privileges(const Glib::ustring& group_name, cons
for(type_vecStrings::const_iterator iterItems = vecItems.begin(); iterItems != vecItems.end(); ++iterItems)
{
Glib::ustring item = *iterItems;
item = GlomUtils::string_trim(item, "\""); //Remove quotes from front and back.
item = Utils::string_trim(item, "\""); //Remove quotes from front and back.
//Find group permissions, ignoring user permissions:
const Glib::ustring strgroup = "group ";
......@@ -211,7 +211,7 @@ Privileges GlomPrivs::get_table_privileges(const Glib::ustring& group_name, cons
item = item.substr(strgroup.size());
//Get the parts before and after the =:
const type_vecStrings vecParts = GlomUtils::string_separate(item, "=");
const type_vecStrings vecParts = Utils::string_separate(item, "=");
if(vecParts.size() == 2)
{
const Glib::ustring this_group_name = vecParts[0];
......@@ -220,7 +220,7 @@ Privileges GlomPrivs::get_table_privileges(const Glib::ustring& group_name, cons
Glib::ustring group_permissions = vecParts[1];
//Get the part before the /user_who_granted_the_privileges:
const type_vecStrings vecParts = GlomUtils::string_separate(group_permissions, "/");
const type_vecStrings vecParts = Utils::string_separate(group_permissions, "/");
if(!vecParts.empty())
group_permissions = vecParts[0];
......@@ -255,7 +255,7 @@ Privileges GlomPrivs::get_table_privileges(const Glib::ustring& group_name, cons
}
Glib::ustring GlomPrivs::get_user_visible_group_name(const Glib::ustring& group_name)
Glib::ustring Privs::get_user_visible_group_name(const Glib::ustring& group_name)
{
Glib::ustring result = group_name;
......@@ -267,7 +267,7 @@ Glib::ustring GlomPrivs::get_user_visible_group_name(const Glib::ustring& group_
return result;
}
Base_DB::type_vecStrings GlomPrivs::get_groups_of_user(const Glib::ustring& user)
Base_DB::type_vecStrings Privs::get_groups_of_user(const Glib::ustring& user)
{
//TODO_Performance
......@@ -288,14 +288,14 @@ Base_DB::type_vecStrings GlomPrivs::get_groups_of_user(const Glib::ustring& user
return result;
}
bool GlomPrivs::get_user_is_in_group(const Glib::ustring& user, const Glib::ustring& group)
bool Privs::get_user_is_in_group(const Glib::ustring& user, const Glib::ustring& group)
{
const type_vecStrings users = get_database_users(group);
type_vecStrings::const_iterator iterFind = std::find(users.begin(), users.end(), user);
return (iterFind != users.end());
}
Privileges GlomPrivs::get_current_privs(const Glib::ustring& table_name)
Privileges Privs::get_current_privs(const Glib::ustring& table_name)
{
//TODO_Performance: There's lots of database access here.
//We could maybe replace some with the postgres has_table_* function().
......
......@@ -28,7 +28,7 @@
namespace Glom
{
class GlomPrivs : public GlomPostgres
class Privs : public GlomPostgres
{
public:
......
......@@ -108,7 +108,7 @@ void Box_Formatting::set_formatting(const FieldFormatting& format, const Glib::u
for(FieldFormatting::type_list_values::const_iterator iter = list_choice_values.begin(); iter != list_choice_values.end(); ++iter)
{
//Display the value in the choices list as it would be displayed in the format:
Glib::ustring value_text = GlomConversions::get_text_for_gda_value(field->get_glom_type(), *iter, format.m_numeric_format);
Glib::ustring value_text = Conversions::get_text_for_gda_value(field->get_glom_type(), *iter, format.m_numeric_format);
Gtk::TreeModel::iterator iter = m_adddel_choices_custom->add_item(value_text);
m_adddel_choices_custom->set_value(iter, m_col_index_custom_choices, value_text);
}
......@@ -152,7 +152,7 @@ bool Box_Formatting::get_formatting(FieldFormatting& format) const
if(!text.empty())
{
bool success = false;
Gnome::Gda::Value value = GlomConversions::parse_value(m_field->get_glom_type(), text, m_format.m_numeric_format, success);
Gnome::Gda::Value value = Conversions::parse_value(m_field->get_glom_type(), text, m_format.m_numeric_format, success);
if(success)
list_choice_values.push_back(value);
......
......@@ -83,7 +83,7 @@ void Dialog_ButtonScript::on_button_test()
for(Document_Glom::type_vecFields::const_iterator iter = fields.begin(); iter != fields.end(); ++iter)
{
const sharedptr<const Field> field = *iter;
const Gnome::Gda::Value example_value = GlomConversions::get_example_value(field->get_glom_type());
const Gnome::Gda::Value example_value = Conversions::get_example_value(field->get_glom_type());
field_values[field->get_name()] = example_value;
}
}
......
......@@ -226,7 +226,7 @@ static std::string glom_escape_text(const std::string src)
//Also escape any ";" characters, because these also cause problems, at least with libgda:
//See bug #326325.
escaped = GlomUtils::string_replace(escaped, ";", "\\073");
escaped = Utils::string_replace(escaped, ";", "\\073");
return ("'" + escaped + "'"); //Add single-quotes. Actually escape it
//std::cout << "glom_escape_text: escaped and quoted: " << str << std::endl;
......@@ -288,7 +288,7 @@ Glib::ustring Field::sql(const Gnome::Gda::Value& value) const
case(TYPE_TIME):
{
NumericFormat format_ignored; //Because we use ISO format.
str = GlomConversions::get_text_for_gda_value(m_glom_type, value, std::locale() /* SQL uses the C locale */, format_ignored, true /* ISO standard */);
str = Conversions::get_text_for_gda_value(m_glom_type, value, std::locale() /* SQL uses the C locale */, format_ignored, true /* ISO standard */);
if(str != "NULL")
str = "'" + str + "'"; //Add single-quotes.
......@@ -296,7 +296,7 @@ Glib::ustring Field::sql(const Gnome::Gda::Value& value) const
}
case(TYPE_NUMERIC):
{
str = GlomConversions::get_text_for_gda_value(m_glom_type, value, std::locale() /* SQL uses the C locale */); //No quotes for numbers.
str = Conversions::get_text_for_gda_value(m_glom_type, value, std::locale() /* SQL uses the C locale */); //No quotes for numbers.
break;
}
case(TYPE_BOOLEAN):
......@@ -321,7 +321,7 @@ Glib::ustring Field::sql(const Gnome::Gda::Value& value) const
str = glom_escape_text(escaped_binary_data) /* has quotes */ + "::bytea";
//Use this when libgda unescapes the binary data internally, as it should:
//str = "'" + GlomConversions::get_escaped_binary_data((guint8*)buffer, buffer_size) + "'::bytea";
//str = "'" + Conversions::get_escaped_binary_data((guint8*)buffer, buffer_size) + "'::bytea";
}
}
else
......
......@@ -33,13 +33,13 @@
namespace Glom
{
Glib::ustring GlomConversions::format_time(const tm& tm_data)
Glib::ustring Conversions::format_time(const tm& tm_data)
{
return format_time( tm_data, std::locale("") /* the user's current locale */ ); //Get the current locale.
}
Glib::ustring GlomConversions::format_time(const tm& tm_data, const std::locale& locale, bool iso_format)
Glib::ustring Conversions::format_time(const tm& tm_data, const std::locale& locale, bool iso_format)
{
if(iso_format)
{
......@@ -49,7 +49,7 @@ Glib::ustring GlomConversions::format_time(const tm& tm_data, const std::locale&
return format_tm(tm_data, locale, _("%X") /* time */);
}
Glib::ustring GlomConversions::format_date(const tm& tm_data)
Glib::ustring Conversions::format_date(const tm& tm_data)
{
return format_date( tm_data, std::locale("") /* the user's current locale */ ); //Get the current locale.
}
......@@ -62,7 +62,7 @@ static const char* glom_get_locale_date_format()
return _("%x");
}
Glib::ustring GlomConversions::format_date(const tm& tm_data, const std::locale& locale, bool iso_format)
Glib::ustring Conversions::format_date(const tm& tm_data, const std::locale& locale, bool iso_format)
{
if(iso_format)
return format_tm(tm_data, locale, "%F" /* iso-format date */);
......@@ -74,7 +74,7 @@ Glib::ustring GlomConversions::format_date(const tm& tm_data, const std::locale&
}
Glib::ustring GlomConversions::format_tm(const tm& tm_data, const std::locale& locale, const char* format)
Glib::ustring Conversions::format_tm(const tm& tm_data, const std::locale& locale, const char* format)
{
//This is based on docs found here:
//http://www.roguewave.com/support/docs/sourcepro/stdlibref/time-put.html
......@@ -127,7 +127,7 @@ Glib::ustring GlomConversions::format_tm(const tm& tm_data, const std::locale& l
while((bufsize *= 2) <= 65536);
// This error is quite unlikely (unless strftime is buggy).
g_warning("GlomConversions::format_time(): maximum size of strftime buffer exceeded, giving up");
g_warning("Conversions::format_time(): maximum size of strftime buffer exceeded, giving up");
return Glib::ustring();
*/
......@@ -156,12 +156,12 @@ class numpunct_no_thousands_separator: public std::numpunct<char>
} //anonymous namespace
Glib::ustring GlomConversions::get_text_for_gda_value(Field::glom_field_type glom_type, const Gnome::Gda::Value& value, const NumericFormat& numeric_format)
Glib::ustring Conversions::get_text_for_gda_value(Field::glom_field_type glom_type, const Gnome::Gda::Value& value, const NumericFormat& numeric_format)
{
return get_text_for_gda_value(glom_type, value, std::locale("") /* the user's current locale */, numeric_format); //Get the current locale.
}
Glib::ustring GlomConversions::get_text_for_gda_value(Field::glom_field_type glom_type, const Gnome::Gda::Value& value, const std::locale& locale, const NumericFormat& numeric_format, bool iso_format)
Glib::ustring Conversions::get_text_for_gda_value(Field::glom_field_type glom_type, const Gnome::Gda::Value& value, const std::locale& locale, const NumericFormat& numeric_format, bool iso_format)
{
if(value.get_value_type() == Gnome::Gda::VALUE_TYPE_NULL) //The type can be null for any of the actual field types.
{
......@@ -261,7 +261,7 @@ Glib::ustring GlomConversions::get_text_for_gda_value(Field::glom_field_type glo
}
}
Gnome::Gda::Value GlomConversions::parse_value(double number)
Gnome::Gda::Value Conversions::parse_value(double number)
{
//This is just a way to get a NUMERIC Gda::Value from a numeric type:
//Try to parse the inputted number, according to the current locale.
......@@ -285,13 +285,13 @@ Gnome::Gda::Value GlomConversions::parse_value(double number)
return Gnome::Gda::Value(&gda_numeric);
}