r21487 - gnucash/trunk/src/optional/gtkmm - [Gtkmm] Add another predicate for the string_option of GncBook.
Christian Stimming
cstim at code.gnucash.org
Mon Oct 24 16:41:28 EDT 2011
Author: cstim
Date: 2011-10-24 16:41:28 -0400 (Mon, 24 Oct 2011)
New Revision: 21487
Trac: http://svn.gnucash.org/trac/changeset/21487
Modified:
gnucash/trunk/src/optional/gtkmm/gncmm/Book.cpp
gnucash/trunk/src/optional/gtkmm/gncmm/Book.hpp
gnucash/trunk/src/optional/gtkmm/test/test-book.cpp
Log:
[Gtkmm] Add another predicate for the string_option of GncBook.
Modified: gnucash/trunk/src/optional/gtkmm/gncmm/Book.cpp
===================================================================
--- gnucash/trunk/src/optional/gtkmm/gncmm/Book.cpp 2011-10-24 20:41:15 UTC (rev 21486)
+++ gnucash/trunk/src/optional/gtkmm/gncmm/Book.cpp 2011-10-24 20:41:28 UTC (rev 21487)
@@ -115,12 +115,12 @@
}
-void Book::set_string_option (const Glib::ustring& opt_name, const Glib::ustring& opt_val)
+void Book::string_option_set (const Glib::ustring& opt_name, const Glib::ustring& opt_val)
{
qof_book_set_string_option(gobj(), opt_name.c_str(), opt_val.c_str());
}
-Glib::ustring Book::get_string_option (const Glib::ustring& opt_name) const
+Glib::ustring Book::string_option_get (const Glib::ustring& opt_name) const
{
const char* r = qof_book_get_string_option(gobj(), opt_name.c_str());
if (r)
@@ -128,6 +128,14 @@
else
return "";
}
+bool Book::string_option_exists (const Glib::ustring& opt_name) const
+{
+ const char* r = qof_book_get_string_option(gobj(), opt_name.c_str());
+ if (r)
+ return true;
+ else
+ return false;
+}
// Account Book::get_root_account()
// {
Modified: gnucash/trunk/src/optional/gtkmm/gncmm/Book.hpp
===================================================================
--- gnucash/trunk/src/optional/gtkmm/gncmm/Book.hpp 2011-10-24 20:41:15 UTC (rev 21486)
+++ gnucash/trunk/src/optional/gtkmm/gncmm/Book.hpp 2011-10-24 20:41:28 UTC (rev 21487)
@@ -106,8 +106,9 @@
{
qof_book_mark_readonly(gobj());
}
- void set_string_option (const Glib::ustring& opt_name, const Glib::ustring& opt_val);
- Glib::ustring get_string_option (const Glib::ustring& opt_name) const;
+ void string_option_set (const Glib::ustring& opt_name, const Glib::ustring& opt_val);
+ Glib::ustring string_option_get (const Glib::ustring& opt_name) const;
+ bool string_option_exists (const Glib::ustring& opt_name) const;
};
} // END namespace gnc
Modified: gnucash/trunk/src/optional/gtkmm/test/test-book.cpp
===================================================================
--- gnucash/trunk/src/optional/gtkmm/test/test-book.cpp 2011-10-24 20:41:15 UTC (rev 21486)
+++ gnucash/trunk/src/optional/gtkmm/test/test-book.cpp 2011-10-24 20:41:28 UTC (rev 21487)
@@ -160,9 +160,11 @@
Glib::ustring opt_name_notset("Not Set");
Glib::RefPtr<gnc::Book> book = Glib::wrap(fixture->book, true); // "true" is important!
g_assert( book );
- book->set_string_option( opt_name, opt_value);
- g_assert_cmpstr( book->get_string_option( opt_name ).c_str(), == , opt_value.c_str());
- g_assert( book->get_string_option( opt_name_notset ).empty());
+ book->string_option_set( opt_name, opt_value);
+ g_assert_cmpstr( book->string_option_get( opt_name ).c_str(), == , opt_value.c_str());
+ g_assert( book->string_option_exists(opt_name) == true);
+ g_assert( book->string_option_get( opt_name_notset ).empty());
+ g_assert( book->string_option_exists( opt_name_notset ) == false);
}
void test_suite_gtkmm_book()
More information about the gnucash-changes
mailing list