summaryrefslogtreecommitdiff
path: root/src/QGlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/QGlib')
-rw-r--r--src/QGlib/String1
-rw-r--r--src/QGlib/closure.cpp3
-rw-r--r--src/QGlib/global.h1
-rw-r--r--src/QGlib/object.cpp6
-rw-r--r--src/QGlib/object.h11
-rw-r--r--src/QGlib/paramspec.cpp12
-rw-r--r--src/QGlib/paramspec.h7
-rw-r--r--src/QGlib/quark.cpp11
-rw-r--r--src/QGlib/quark.h8
-rw-r--r--src/QGlib/signal.cpp12
-rw-r--r--src/QGlib/signal.h20
-rw-r--r--src/QGlib/signalimpl_p.h16
-rw-r--r--src/QGlib/string.h75
-rw-r--r--src/QGlib/string_p.h (renamed from src/QGlib/string.cpp)11
-rw-r--r--src/QGlib/type.cpp7
-rw-r--r--src/QGlib/type.h5
-rw-r--r--src/QGlib/value.cpp1
-rw-r--r--src/QGlib/value.h1
18 files changed, 69 insertions, 139 deletions
diff --git a/src/QGlib/String b/src/QGlib/String
deleted file mode 100644
index eab76f2..0000000
--- a/src/QGlib/String
+++ /dev/null
@@ -1 +0,0 @@
-#include "string.h"
diff --git a/src/QGlib/closure.cpp b/src/QGlib/closure.cpp
index 79f33e4..1aef75e 100644
--- a/src/QGlib/closure.cpp
+++ b/src/QGlib/closure.cpp
@@ -17,6 +17,7 @@
#include "closure.h"
#include "quark.h"
#include <glib-object.h>
+#include <QtCore/QDebug>
namespace QGlib {
@@ -60,7 +61,7 @@ static void c_marshaller(GClosure *closure, GValue *returnValue, uint paramValue
if (ihint->detail != 0) {
Quark q(ihint->detail);
signalName.append(QLatin1String("::"));
- signalName.append(q.toString().toQString()); //FIXME ugly syntax
+ signalName.append(q.toString());
}
}
diff --git a/src/QGlib/global.h b/src/QGlib/global.h
index 33c65bb..dfbf811 100644
--- a/src/QGlib/global.h
+++ b/src/QGlib/global.h
@@ -30,7 +30,6 @@ namespace QGlib {
class ValueBase;
class Value;
class SharedValue;
-class String;
class Quark;
class Type;
class Signal;
diff --git a/src/QGlib/object.cpp b/src/QGlib/object.cpp
index cd98cdc..b7ce473 100644
--- a/src/QGlib/object.cpp
+++ b/src/QGlib/object.cpp
@@ -29,7 +29,7 @@ QList< RefPointer<T> > arrayToList(typename T::CType **array, uint n)
return result;
}
-ParamSpecPtr Object::findProperty(const String & name) const
+ParamSpecPtr Object::findProperty(const char *name) const
{
GObjectClass *klass = G_OBJECT_CLASS(g_type_class_ref(Type::fromInstance(object<void>())));
GParamSpec *param = g_object_class_find_property(klass, name);
@@ -52,7 +52,7 @@ QList<ParamSpecPtr> Object::listProperties() const
return result;
}
-Value Object::property(const String & name) const
+Value Object::property(const char *name) const
{
Value result;
ParamSpecPtr param = findProperty(name);
@@ -63,7 +63,7 @@ Value Object::property(const String & name) const
return result;
}
-void Object::setPropertyValue(const String & name, const ValueBase & value)
+void Object::setPropertyValue(const char *name, const ValueBase & value)
{
g_object_set_property(object<GObject>(), name, value);
}
diff --git a/src/QGlib/object.h b/src/QGlib/object.h
index bf1eaab..eb25d3b 100644
--- a/src/QGlib/object.h
+++ b/src/QGlib/object.h
@@ -22,7 +22,6 @@
#include "paramspec.h"
#include "value.h"
#include "type.h"
-#include "string.h"
#include <QtCore/QList>
namespace QGlib {
@@ -31,12 +30,12 @@ class Object : public RefCountedObject
{
QGLIB_WRAPPER(Object)
public:
- ParamSpecPtr findProperty(const String & name) const;
+ ParamSpecPtr findProperty(const char *name) const;
QList<ParamSpecPtr> listProperties() const;
- Value property(const String & name) const;
- template <class T> void setProperty(const String & name, const T & value);
- void setPropertyValue(const String & name, const ValueBase & value);
+ Value property(const char *name) const;
+ template <class T> void setProperty(const char *name, const T & value);
+ void setPropertyValue(const char *name, const ValueBase & value);
protected:
virtual void ref();
@@ -44,7 +43,7 @@ protected:
};
template <class T>
-void Object::setProperty(const String & name, const T & value)
+void Object::setProperty(const char *name, const T & value)
{
ParamSpecPtr param = findProperty(name);
if (param) {
diff --git a/src/QGlib/paramspec.cpp b/src/QGlib/paramspec.cpp
index cf0f1bb..54d8e1c 100644
--- a/src/QGlib/paramspec.cpp
+++ b/src/QGlib/paramspec.cpp
@@ -21,19 +21,19 @@
namespace QGlib {
-String ParamSpec::name() const
+QString ParamSpec::name() const
{
- return String(g_param_spec_get_name(object<GParamSpec>()));
+ return QString::fromUtf8(g_param_spec_get_name(object<GParamSpec>()));
}
-String ParamSpec::nick() const
+QString ParamSpec::nick() const
{
- return String(g_param_spec_get_nick(object<GParamSpec>()));
+ return QString::fromUtf8(g_param_spec_get_nick(object<GParamSpec>()));
}
-String ParamSpec::description() const
+QString ParamSpec::description() const
{
- return String(g_param_spec_get_blurb(object<GParamSpec>()));
+ return QString::fromUtf8(g_param_spec_get_blurb(object<GParamSpec>()));
}
ParamSpec::ParamFlags ParamSpec::flags() const
diff --git a/src/QGlib/paramspec.h b/src/QGlib/paramspec.h
index ae8fe3d..9a04f3c 100644
--- a/src/QGlib/paramspec.h
+++ b/src/QGlib/paramspec.h
@@ -21,6 +21,7 @@
#include "refpointer.h"
#include "type.h"
#include "value.h"
+#include <QtCore/QString>
namespace QGlib {
@@ -38,9 +39,9 @@ public:
};
Q_DECLARE_FLAGS(ParamFlags, ParamFlag);
- String name() const;
- String nick() const;
- String description() const;
+ QString name() const;
+ QString nick() const;
+ QString description() const;
ParamFlags flags() const;
Type valueType() const;
diff --git a/src/QGlib/quark.cpp b/src/QGlib/quark.cpp
index 3228073..ad47fb3 100644
--- a/src/QGlib/quark.cpp
+++ b/src/QGlib/quark.cpp
@@ -19,14 +19,19 @@
namespace QGlib {
-Quark::Quark(const String & str)
+Quark::Quark(const char *str)
{
m_quark = g_quark_from_string(str);
}
-String Quark::toString() const
+Quark::Quark(const QString & str)
{
- return String(g_quark_to_string(m_quark));
+ m_quark = g_quark_from_string(str.toUtf8());
+}
+
+QString Quark::toString() const
+{
+ return QString::fromUtf8(g_quark_to_string(m_quark));
}
}
diff --git a/src/QGlib/quark.h b/src/QGlib/quark.h
index 34a726f..2e5049a 100644
--- a/src/QGlib/quark.h
+++ b/src/QGlib/quark.h
@@ -17,7 +17,7 @@
#ifndef QGLIB_QUARK_H
#define QGLIB_QUARK_H
-#include "string.h"
+#include <QtCore/QString>
namespace QGlib {
@@ -25,10 +25,10 @@ class Quark
{
public:
inline Quark(quint32 gquark = 0) : m_quark(gquark) {}
- Quark(const String & str);
-
- String toString() const;
+ Quark(const char *str);
+ Quark(const QString & str);
+ QString toString() const;
inline operator quint32() const { return m_quark; }
private:
diff --git a/src/QGlib/signal.cpp b/src/QGlib/signal.cpp
index d49da11..ae42d0d 100644
--- a/src/QGlib/signal.cpp
+++ b/src/QGlib/signal.cpp
@@ -98,9 +98,9 @@ uint Signal::id() const
return d->id;
}
-String Signal::name() const
+QString Signal::name() const
{
- return d->query()->signal_name;
+ return QString::fromUtf8(d->query()->signal_name);
}
Signal::SignalFlags Signal::flags() const
@@ -128,7 +128,7 @@ QList<Type> Signal::paramTypes() const
}
//static
-Signal Signal::lookup(const String & name, Type type)
+Signal Signal::lookup(const char *name, Type type)
{
return Signal(g_signal_lookup(name, type));
}
@@ -147,11 +147,11 @@ QList<Signal> Signal::listSignals(Type type)
}
//static
-Value Signal::emit(void *instance, const String & detailedSignal, const QList<Value> & args)
+Value Signal::emit(void *instance, const char *detailedSignal, const QList<Value> & args)
{
Value result;
Type itype = Type::fromInstance(instance);
- QStringList signalParts = detailedSignal.toQString().split(QLatin1String("::"));
+ QStringList signalParts = QString::fromUtf8(detailedSignal).split(QLatin1String("::"));
Quark detail;
if (signalParts.size() > 1) {
detail = Quark(signalParts[1]);
@@ -225,7 +225,7 @@ Value Signal::emit(void *instance, const String & detailedSignal, const QList<Va
}
//static
-SignalHandler Signal::connect(void *instance, const String & detailedSignal,
+SignalHandler Signal::connect(void *instance, const char *detailedSignal,
const ClosurePtr & closure, ConnectFlags flags)
{
uint id = g_signal_connect_closure(instance, detailedSignal, closure,
diff --git a/src/QGlib/signal.h b/src/QGlib/signal.h
index 17e063a..a732677 100644
--- a/src/QGlib/signal.h
+++ b/src/QGlib/signal.h
@@ -93,34 +93,34 @@ public:
bool isValid() const;
uint id() const;
- QGlib::String name() const;
+ QString name() const;
SignalFlags flags() const;
Type instanceType() const;
Type returnType() const;
QList<Type> paramTypes() const;
- static Signal lookup(const QGlib::String & name, Type type);
+ static Signal lookup(const char *name, Type type);
static QList<Signal> listSignals(Type type);
#if QGLIB_HAVE_CXX0X
template <typename R, typename... Args>
- static R emit(void *instance, const QGlib::String & detailedSignal, Args&&... args);
+ static R emit(void *instance, const char *detailedSignal, Args&&... args);
template <typename T, typename R, typename... Args>
- static SignalHandler connect(void *instance, const QGlib::String & detailedSignal,
+ static SignalHandler connect(void *instance, const char *detailedSignal,
T *receiver, R (T::*slot)(Args...), ConnectFlags flags = 0);
#else //QGLIB_HAVE_CXX0X
//versions that take no arguments
template <typename R>
- static R emit(void *instance, const QGlib::String & detailedSignal);
+ static R emit(void *instance, const char *detailedSignal);
template <typename T, typename R>
- static SignalHandler connect(void *instance, const QGlib::String & detailedSignal,
+ static SignalHandler connect(void *instance, const char *detailedSignal,
T *receiver, R (T::*slot)(), ConnectFlags flags = 0);
# define QGLIB_SIGNAL_TMPL_PARAMS(n) \
@@ -131,11 +131,11 @@ public:
# define QGLIB_SIGNAL_EMIT_DECLARATION(z, n, data) \
template <typename R, QGLIB_SIGNAL_TMPL_PARAMS(n) > \
- static R emit(void *instance, const QGlib::String & detailedSignal, QGLIB_SIGNAL_TMPL_ARGS(n));
+ static R emit(void *instance, const char *detailedSignal, QGLIB_SIGNAL_TMPL_ARGS(n));
# define QGLIB_SIGNAL_CONNECT_DECLARATION(z, n, data) \
template <typename T, typename R, QGLIB_SIGNAL_TMPL_PARAMS(n) > \
- static SignalHandler connect(void *instance, const QGlib::String & detailedSignal, \
+ static SignalHandler connect(void *instance, const char *detailedSignal, \
T *receiver, R (T::*slot)(QGLIB_SIGNAL_TMPL_ARGS(n)), \
ConnectFlags flags = 0);
@@ -151,9 +151,9 @@ public:
#endif //QGLIB_HAVE_CXX0X
- static Value emit(void *instance, const QGlib::String & detailedSignal, const QList<Value> & args);
+ static Value emit(void *instance, const char *detailedSignal, const QList<Value> & args);
- static SignalHandler connect(void *instance, const QGlib::String & detailedSignal,
+ static SignalHandler connect(void *instance, const char *detailedSignal,
const ClosurePtr & closure, ConnectFlags flags = 0);
private:
diff --git a/src/QGlib/signalimpl_p.h b/src/QGlib/signalimpl_p.h
index bf055a2..d5d40da 100644
--- a/src/QGlib/signalimpl_p.h
+++ b/src/QGlib/signalimpl_p.h
@@ -64,7 +64,7 @@ QList<Value> packArguments(Arg1 && a1, Args&&... args)
template <typename R, typename... Args>
struct EmitImpl<R (Args...)>
{
- static inline R emit(void *instance, const QGlib::String & detailedSignal, Args&&... args)
+ static inline R emit(void *instance, const char *detailedSignal, Args&&... args)
{
Value && returnValue = Signal::emit(instance, detailedSignal, packArguments(args...));
@@ -81,7 +81,7 @@ struct EmitImpl<R (Args...)>
template <typename... Args>
struct EmitImpl<void (Args...)>
{
- static inline void emit(void *instance, const QGlib::String & detailedSignal, Args&&... args)
+ static inline void emit(void *instance, const char *detailedSignal, Args&&... args)
{
Value && returnValue = Signal::emit(instance, detailedSignal, packArguments(args...));
@@ -117,13 +117,13 @@ MemberFunction<T, R, Args...> mem_fn(R (T::*fn)(Args...), T *obj)
} //namespace Private
template <typename R, typename... Args>
-R Signal::emit(void *instance, const QGlib::String & detailedSignal, Args&&... args)
+R Signal::emit(void *instance, const char *detailedSignal, Args&&... args)
{
return QGlib::Private::EmitImpl<R (Args...)>::emit(instance, detailedSignal, args...);
}
template <typename T, typename R, typename... Args>
-SignalHandler Signal::connect(void *instance, const QGlib::String & detailedSignal,
+SignalHandler Signal::connect(void *instance, const char *detailedSignal,
T *receiver, R (T::*slot)(Args...), ConnectFlags flags)
{
typedef QGlib::Private::MemberFunction<T, R, Args...> F;
@@ -191,7 +191,7 @@ template <typename R QGLIB_SIGNAL_IMPL_COMMA
QGLIB_SIGNAL_IMPL_TEMPLATE_PARAMS>
struct EmitImpl<R (QGLIB_SIGNAL_IMPL_TEMPLATE_ARGS)>
{
- static inline R emit(void *instance, const QGlib::String & detailedSignal
+ static inline R emit(void *instance, const char *detailedSignal
QGLIB_SIGNAL_IMPL_FUNCTION_PARAMS)
{
QList<Value> values;
@@ -211,7 +211,7 @@ struct EmitImpl<R (QGLIB_SIGNAL_IMPL_TEMPLATE_ARGS)>
template <QGLIB_SIGNAL_IMPL_TEMPLATE_PARAMS>
struct EmitImpl<void (QGLIB_SIGNAL_IMPL_TEMPLATE_ARGS)>
{
- static inline void emit(void *instance, const QGlib::String & detailedSignal
+ static inline void emit(void *instance, const char *detailedSignal
QGLIB_SIGNAL_IMPL_FUNCTION_PARAMS)
{
QList<Value> values;
@@ -228,7 +228,7 @@ struct EmitImpl<void (QGLIB_SIGNAL_IMPL_TEMPLATE_ARGS)>
template <typename R QGLIB_SIGNAL_IMPL_COMMA
QGLIB_SIGNAL_IMPL_TEMPLATE_PARAMS>
-R Signal::emit(void *instance, const QGlib::String & detailedSignal QGLIB_SIGNAL_IMPL_FUNCTION_PARAMS)
+R Signal::emit(void *instance, const char *detailedSignal QGLIB_SIGNAL_IMPL_FUNCTION_PARAMS)
{
return QGlib::Private::EmitImpl<R (QGLIB_SIGNAL_IMPL_TEMPLATE_ARGS)>
::emit(instance, detailedSignal QGLIB_SIGNAL_IMPL_FUNCTION_ARGS);
@@ -236,7 +236,7 @@ R Signal::emit(void *instance, const QGlib::String & detailedSignal QGLIB_SIGNAL
template <typename T, typename R QGLIB_SIGNAL_IMPL_COMMA
QGLIB_SIGNAL_IMPL_TEMPLATE_PARAMS>
-SignalHandler Signal::connect(void *instance, const QGlib::String & detailedSignal,
+SignalHandler Signal::connect(void *instance, const char *detailedSignal,
T *receiver, R (T::*slot)(QGLIB_SIGNAL_IMPL_TEMPLATE_ARGS),
ConnectFlags flags)
{
diff --git a/src/QGlib/string.h b/src/QGlib/string.h
deleted file mode 100644
index e840b3f..0000000
--- a/src/QGlib/string.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- Copyright (C) 2010 George Kiagiadakis <kiagiadakis.george@gmail.com>
-
- This library is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-#ifndef QGLIB_STRING_H
-#define QGLIB_STRING_H
-
-#include <QtCore/QByteArray>
-#include <QtCore/QString>
-#include <QtCore/QDebug>
-
-namespace QGlib {
-
-/** This is a string class based on QByteArray. It is used instead of QString
- * to avoid the overhead of converting the data to/from UTF-16 when not necessary.
- * Since GLib/Gstreamer use entirely UTF-8 encoding, expect the data of this class
- * to be encoded as UTF-8. This means that if you want to display this string
- * somewhere, you should first convert it to QString with the toQString() method
- * or with operator QString().
- */
-class String
-{
-public:
- inline String() {}
- inline String(const char *str) : m_str(str) {}
- inline String(const QByteArray & str) : m_str(str) {}
- inline String(const QString & str) : m_str(str.toUtf8()) {}
-
- inline QString toQString() const { return QString::fromUtf8(m_str.constData(), m_str.size()); }
- inline operator QString() const { return toQString(); }
-
- /** This is a special method that is used to wrap the return value of glib/gstreamer
- * methods that return a newly allocated gchar*. This method converts it to a String
- * and calls g_free() on the original string to free it.
- */
- static String fromGCharPtr(char *s);
-
- /** This is a special method that is used to pass this string as an argument to
- * glib/gstreamer methods that take a const gchar*. If the string is empty, it
- * returns NULL to hit the sanity checks of those methods.
- */
- inline const char *toGCharPtr() const { return m_str.isEmpty() ? NULL : m_str.constData(); }
-
- /** Behaves the same as toGCharPtr() */
- inline operator const char*() const { return toGCharPtr(); }
-
- inline bool operator==(const char *other) const { return m_str == other; }
- inline bool operator==(const QByteArray & other) const { return m_str == other; }
- inline bool operator==(const String & other) const { return m_str == other.m_str; }
- inline bool operator==(const QString & other) const { return QString::fromUtf8(m_str) == other; }
-
-private:
- QByteArray m_str;
-};
-
-} //namespace QGlib
-
-inline QDebug operator<<(QDebug dbg, const QGlib::String & str)
-{
- return dbg << str.toQString();
-}
-
-#endif // QGLIB_STRING_H
diff --git a/src/QGlib/string.cpp b/src/QGlib/string_p.h
index e1a9d07..08a0094 100644
--- a/src/QGlib/string.cpp
+++ b/src/QGlib/string_p.h
@@ -14,16 +14,21 @@
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "string.h"
+#include <QtCore/QString>
#include <glib.h>
+/* WARNING: This header should only be included from
+ * QtGstreamer source files and should not be installed */
+
namespace QGlib {
+namespace Private {
-String String::fromGCharPtr(char* s)
+inline QString stringFromGCharPtr(char *s)
{
- String str(s);
+ QString str = QString::fromUtf8(s);
g_free(s);
return str;
}
}
+}
diff --git a/src/QGlib/type.cpp b/src/QGlib/type.cpp
index f6e84bb..87dc65a 100644
--- a/src/QGlib/type.cpp
+++ b/src/QGlib/type.cpp
@@ -15,7 +15,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "type.h"
-#include "string.h"
#include "quark.h"
#include <glib-object.h>
@@ -26,14 +25,14 @@ Type Type::fromInstance(void *instance)
return G_TYPE_FROM_INSTANCE(instance);
}
-Type Type::fromName(const QGlib::String & name)
+Type Type::fromName(const char *name)
{
return g_type_from_name(name);
}
-QGlib::String Type::name() const
+QString Type::name() const
{
- return QGlib::String(g_type_name(m_type));
+ return QString::fromUtf8(g_type_name(m_type));
}
Quark Type::qname() const
diff --git a/src/QGlib/type.h b/src/QGlib/type.h
index 1b0c5df..d4e0f81 100644
--- a/src/QGlib/type.h
+++ b/src/QGlib/type.h
@@ -61,9 +61,9 @@ public:
template<class T>
static Type fromInstance(const RefPointer<T> & instance);
static Type fromInstance(void *nativeInstance);
- static Type fromName(const QGlib::String & name);
+ static Type fromName(const char *name);
- QGlib::String name() const;
+ QString name() const;
Quark qname() const;
bool isAbstract() const;
@@ -180,7 +180,6 @@ QGLIB_REGISTER_NATIVE_TYPE(float, Type::Float)
QGLIB_REGISTER_NATIVE_TYPE(double, Type::Double)
QGLIB_REGISTER_NATIVE_TYPE(void*, Type::Pointer)
QGLIB_REGISTER_NATIVE_TYPE(const char*, Type::String)
-QGLIB_REGISTER_NATIVE_TYPE(QGlib::String, Type::String)
QGLIB_REGISTER_NATIVE_TYPE(QByteArray, Type::String)
QGLIB_REGISTER_NATIVE_TYPE(QString, Type::String)
diff --git a/src/QGlib/value.cpp b/src/QGlib/value.cpp
index 6847db9..f584187 100644
--- a/src/QGlib/value.cpp
+++ b/src/QGlib/value.cpp
@@ -231,7 +231,6 @@ SHORT_VALUEIMPL_IMPLEMENTATION(double, double)
SHORT_VALUEIMPL_IMPLEMENTATION(void*, pointer)
SHORT_VALUEIMPL_IMPLEMENTATION(QGlib::Type, gtype)
SHORT_VALUEIMPL_IMPLEMENTATION(const char*, string)
-SHORT_VALUEIMPL_IMPLEMENTATION(QGlib::String, string)
SHORT_VALUEIMPL_IMPLEMENTATION(QByteArray, string)
QGLIB_REGISTER_VALUEIMPL_IMPLEMENTATION(QString, QString::fromUtf8(g_value_get_string(value)),
diff --git a/src/QGlib/value.h b/src/QGlib/value.h
index 14eadb3..6b6d16d 100644
--- a/src/QGlib/value.h
+++ b/src/QGlib/value.h
@@ -272,7 +272,6 @@ QGLIB_REGISTER_VALUEIMPL(double)
QGLIB_REGISTER_VALUEIMPL(void*)
QGLIB_REGISTER_VALUEIMPL(QGlib::Type)
QGLIB_REGISTER_VALUEIMPL(const char*)
-QGLIB_REGISTER_VALUEIMPL(QGlib::String)
QGLIB_REGISTER_VALUEIMPL(QByteArray)
QGLIB_REGISTER_VALUEIMPL(QString)