settings.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2011, Dirk Thomas, TU Darmstadt
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  *   * Redistributions of source code must retain the above copyright
00010  *     notice, this list of conditions and the following disclaimer.
00011  *   * Redistributions in binary form must reproduce the above
00012  *     copyright notice, this list of conditions and the following
00013  *     disclaimer in the documentation and/or other materials provided
00014  *     with the distribution.
00015  *   * Neither the name of the TU Darmstadt nor the names of its
00016  *     contributors may be used to endorse or promote products derived
00017  *     from this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00020  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00022  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00023  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00024  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00025  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00026  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00027  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00028  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00029  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00030  * POSSIBILITY OF SUCH DAMAGE.
00031  */
00032 
00033 #include <qt_gui_cpp/settings.h>
00034 
00035 #include <stdexcept>
00036 
00037 namespace qt_gui_cpp {
00038 
00039 Settings::Settings(QObject* obj)
00040   : proxy_(obj)
00041 {}
00042 
00043 Settings Settings::getSettings(const QString& prefix)
00044 {
00045   Settings settings(proxy_.proxiedObject());
00046   bool rc = proxy_.invokeMethodWithReturn("get_settings", Q_RETURN_ARG(Settings, settings), Q_ARG(QString, prefix));
00047   if (!rc) throw std::runtime_error("Settings::get_settings() invoke method failed");
00048   return settings;
00049 }
00050 
00051 QStringList Settings::allKeys() const
00052 {
00053   QStringList list;
00054   bool rc = const_cast<Settings*>(this)->proxy_.invokeMethodWithReturn("all_keys", Q_RETURN_ARG(QStringList, list));
00055   if (!rc) throw std::runtime_error("Settings::all_keys() invoke method failed");
00056   return list;
00057 }
00058 
00059 QStringList Settings::childGroups() const
00060 {
00061   QStringList list;
00062   bool rc = const_cast<Settings*>(this)->proxy_.invokeMethodWithReturn("child_groups", Q_RETURN_ARG(QStringList, list));
00063   if (!rc) throw std::runtime_error("Settings::child_groups() invoke method failed");
00064   return list;
00065 }
00066 
00067 QStringList Settings::childKeys() const
00068 {
00069   QStringList list;
00070   bool rc = const_cast<Settings*>(this)->proxy_.invokeMethodWithReturn("child_keys", Q_RETURN_ARG(QStringList, list));
00071   if (!rc) throw std::runtime_error("Settings::child_keys() invoke method failed");
00072   return list;
00073 }
00074 
00075 bool Settings::contains(const QString& key) const
00076 {
00077   bool flag = false;
00078   bool rc = const_cast<Settings*>(this)->proxy_.invokeMethodWithReturn("contains", Q_RETURN_ARG(bool, flag), Q_ARG(QString, key));
00079   if (!rc) throw std::runtime_error("Settings::contains() invoke method failed");
00080   return flag;
00081 }
00082 
00083 void Settings::remove(const QString& key)
00084 {
00085   bool rc = proxy_.invokeMethod("remove", Q_ARG(QString, key));
00086   if (!rc) throw std::runtime_error("Settings::remove() invoke method failed");
00087 }
00088 
00089 void Settings::setValue(const QString& key, const QVariant& value)
00090 {
00091   bool rc = proxy_.invokeMethod("set_value", Q_ARG(QString, key), Q_ARG(QVariant, value));
00092   if (!rc) throw std::runtime_error("Settings::set_value() invoke method failed");
00093 }
00094 
00095 QVariant Settings::value(const QString& key, const QVariant& defaultValue) const
00096 {
00097   QVariant val;
00098   bool rc = const_cast<Settings*>(this)->proxy_.invokeMethodWithReturn("value", Q_RETURN_ARG(QVariant, val), Q_ARG(QString, key), Q_ARG(QVariant, defaultValue));
00099   if (!rc) throw std::runtime_error("Settings::value() invoke method failed");
00100   return val;
00101 }
00102 
00103 } // namespace


qt_gui_cpp
Author(s): Dirk Thomas
autogenerated on Thu Jun 6 2019 18:07:36