[glom] DbUtis: Some const improvements.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] DbUtis: Some const improvements.
- Date: Wed, 3 Apr 2013 00:22:43 +0000 (UTC)
commit d357f8ba5e706fae0523826aea05696bcb78abb2
Author: Murray Cumming <murrayc murrayc com>
Date: Wed Apr 3 01:29:35 2013 +0200
DbUtis: Some const improvements.
* glom/libglom/db_utils.cc: Make the Document* const
where possible.
ChangeLog | 7 +++++++
glom/libglom/db_utils.cc | 18 +++++++++---------
glom/libglom/db_utils.h | 25 ++++++++++++++++++-------
3 files changed, 34 insertions(+), 16 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d813a3c..99bde7e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2013-04-03 Murray Cumming <murrayc murrayc com>
+ DbUtis: Some const improvements.
+
+ * glom/libglom/db_utils.cc: Make the Document* const
+ where possible.
+
+2013-04-03 Murray Cumming <murrayc murrayc com>
+
Document: Use DocumentTableInfo by sharedptr<>.
* glom/glom/libglom/document/document.[h|cc]:
diff --git a/glom/libglom/db_utils.cc b/glom/libglom/db_utils.cc
index 7b9b16f..c566c0b 100644
--- a/glom/libglom/db_utils.cc
+++ b/glom/libglom/db_utils.cc
@@ -335,7 +335,7 @@ bool recreate_database_from_document(Document* document, const sigc::slot<void>&
}
-SystemPrefs get_database_preferences(Document* document)
+SystemPrefs get_database_preferences(const Document* document)
{
//if(get_userlevel() == AppState::USERLEVEL_DEVELOPER)
// add_standard_tables(document);
@@ -455,7 +455,7 @@ void set_database_preferences(Document* document, const SystemPrefs& prefs)
}
-bool add_standard_tables(Document* document)
+bool add_standard_tables(const Document* document)
{
try
{
@@ -637,7 +637,7 @@ bool add_standard_groups(Document* document)
return true;
}
-bool add_groups_from_document(Document* document)
+bool add_groups_from_document(const Document* document)
{
Glib::RefPtr<Gnome::Gda::Connection> gda_connection = get_connection();
if(!gda_connection)
@@ -678,12 +678,12 @@ bool add_groups_from_document(Document* document)
return true;
}
-bool set_table_privileges_groups_from_document(Document* document)
+bool set_table_privileges_groups_from_document(const Document* document)
{
Glib::RefPtr<Gnome::Gda::Connection> gda_connection = get_connection();
if(!gda_connection)
{
- std::cerr << G_STRFUNC << ": add_standard_groups(): No connection yet." << std::endl;
+ std::cerr << G_STRFUNC << ": No connection yet." << std::endl;
}
// If the connection doesn't support users we can skip this step
@@ -697,7 +697,7 @@ bool set_table_privileges_groups_from_document(Document* document)
const Document::type_list_groups document_groups = document->get_groups();
//Get the list of tables:
- const Document::type_listTableInfo table_list = document->get_tables();
+ //const Document::type_listConstTableInfo table_list = document->get_tables();
bool result = true;
@@ -1572,7 +1572,7 @@ void remove_auto_increment(const Glib::ustring& table_name, const Glib::ustring&
std::cerr << G_STRFUNC << ": UPDATE failed." << std::endl;
}
-bool insert_example_data(Document* document, const Glib::ustring& table_name)
+bool insert_example_data(const Document* document, const Glib::ustring& table_name)
{
//TODO_Performance: Avoid copying:
const Document::type_example_rows example_rows = document->get_table_example_data(table_name);
@@ -1850,7 +1850,7 @@ bool query_execute(const Glib::RefPtr<const Gnome::Gda::SqlBuilder>& builder)
return (exec_retval >= 0);
}
-void layout_item_fill_field_details(Document* document, const Glib::ustring& parent_table_name,
sharedptr<LayoutItem_Field>& layout_item)
+void layout_item_fill_field_details(const Document* document, const Glib::ustring& parent_table_name,
sharedptr<LayoutItem_Field>& layout_item)
{
if(!document)
{
@@ -2251,7 +2251,7 @@ void set_fake_connection()
connection_pool->set_fake_connection();
}
-Gnome::Gda::Value get_lookup_value(Document* document, const Glib::ustring& /* table_name */, const
sharedptr<const Relationship>& relationship, const sharedptr<const Field>& source_field, const
Gnome::Gda::Value& key_value)
+Gnome::Gda::Value get_lookup_value(const Document* document, const Glib::ustring& /* table_name */, const
sharedptr<const Relationship>& relationship, const sharedptr<const Field>& source_field, const
Gnome::Gda::Value& key_value)
{
Gnome::Gda::Value result;
diff --git a/glom/libglom/db_utils.h b/glom/libglom/db_utils.h
index 3d05c17..f3b5fab 100644
--- a/glom/libglom/db_utils.h
+++ b/glom/libglom/db_utils.h
@@ -30,25 +30,36 @@ namespace Glom
namespace DbUtils
{
+/**
+ * This also saves the connection port in the document if self-hosting.
+ */
bool create_database(Document* document, const Glib::ustring& database_name, const Glib::ustring& title,
const sigc::slot<void>& progress);
//TODO: Use this in Glom::AppWindow?
/** Create the database on an already-connected server.
+ * This also saves some details in the document.
*/
bool recreate_database_from_document(Document* document, const sigc::slot<void>& progress);
/** This creates the standard tables if necessary,
* filling them with some information from the document.
*/
-SystemPrefs get_database_preferences(Document* document);
+SystemPrefs get_database_preferences(const Document* document);
+/**
+ * This also saves the preferences in the document.
+ */
void set_database_preferences(Document* document, const SystemPrefs& prefs);
-bool add_standard_tables(Document* document);
+bool add_standard_tables(const Document* document);
+/**
+ * This also saves the groups in the document.
+ */
bool add_standard_groups(Document* document);
-bool add_groups_from_document(Document* document);
-bool set_table_privileges_groups_from_document(Document* document);
+
+bool add_groups_from_document(const Document* document);
+bool set_table_privileges_groups_from_document(const Document* document);
typedef std::vector< sharedptr<Field> > type_vec_fields;
type_vec_fields get_fields_for_table_from_database(const Glib::ustring& table_name, bool
including_system_fields = false);
@@ -95,7 +106,7 @@ bool drop_column(const Glib::ustring& table_name, const Glib::ustring& field_nam
/** Insert example data, from the document, into the table on the database server.
*/
-bool insert_example_data(Document* document, const Glib::ustring& table_name);
+bool insert_example_data(const Document* document, const Glib::ustring& table_name);
/** Execute a SQL Select command, returning the result.
* @param builder The finished SqlBuilder object.
@@ -133,7 +144,7 @@ Gnome::Gda::Value get_next_auto_increment_value(const Glib::ustring& table_name,
*/
void remove_auto_increment(const Glib::ustring& table_name, const Glib::ustring& field_name);
-void layout_item_fill_field_details(Document* document, const Glib::ustring& parent_table_name,
sharedptr<LayoutItem_Field>& layout_item);
+void layout_item_fill_field_details(const Document* document, const Glib::ustring& parent_table_name,
sharedptr<LayoutItem_Field>& layout_item);
//TODO: It would be nice to use sharedptr<const Relationship>& instead of sharedptr<Relationship>&,
@@ -206,7 +217,7 @@ bool remove_user_from_group(const Glib::ustring& user, const Glib::ustring& grou
/** Get the value of the @a source_field from the @a relationship, using the @a key_value.
*/
-Gnome::Gda::Value get_lookup_value(Document* document, const Glib::ustring& table_name, const
sharedptr<const Relationship>& relationship, const sharedptr<const Field>& source_field, const
Gnome::Gda::Value & key_value);
+Gnome::Gda::Value get_lookup_value(const Document* document, const Glib::ustring& table_name, const
sharedptr<const Relationship>& relationship, const sharedptr<const Field>& source_field, const
Gnome::Gda::Value & key_value);
/** Allow a fake connection, so sqlbuilder_get_full_query() can work.
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]