Commit 41b862f1 authored by Jan Lingscheid's avatar Jan Lingscheid

Refactor Util::ptr_shared

Util::ptr_shared<T> was only used in its <char> specialization, so it is now refactored into a
non-template class. Using it with arbitary classes was dangerous anyway.
parent e1cb749a
......@@ -50,7 +50,7 @@ MangleCache mangle_cache;
}
Util::ptr_shared<char> demangle(char const *name) {
Util::ptr_shared demangle(char const *name) {
MangleCache::iterator found=mangle_cache.find(name);
char const *result;
......
......@@ -18,7 +18,7 @@ namespace Inkscape {
namespace Debug {
Util::ptr_shared<char> demangle(char const *name);
Util::ptr_shared demangle(char const *name);
}
......
......@@ -40,23 +40,23 @@ public:
struct PropertyPair {
public:
PropertyPair() {}
PropertyPair(Util::ptr_shared<char> n, Util::ptr_shared<char> v)
PropertyPair(Util::ptr_shared n, Util::ptr_shared v)
: name(n), value(v) {}
PropertyPair(char const *n, Util::ptr_shared<char> v)
PropertyPair(char const *n, Util::ptr_shared v)
: name(Util::share_string(n)), value(v) {}
PropertyPair(Util::ptr_shared<char> n, char const *v)
PropertyPair(Util::ptr_shared n, char const *v)
: name(n), value(Util::share_string(v)) {}
PropertyPair(char const *n, char const *v)
: name(Util::share_string(n)),
value(Util::share_string(v)) {}
Util::ptr_shared<char> name;
Util::ptr_shared<char> value;
Util::ptr_shared name;
Util::ptr_shared value;
};
static Category category() { return OTHER; }
virtual Util::ptr_shared<char> name() const=0;
virtual Util::ptr_shared name() const=0;
virtual unsigned propertyCount() const=0;
virtual PropertyPair property(unsigned property) const=0;
......
......@@ -23,7 +23,7 @@ public:
int features() const {
return SIZE_AVAILABLE | USED_AVAILABLE | GARBAGE_COLLECTED;
}
Util::ptr_shared<char> name() const {
Util::ptr_shared name() const {
return Util::share_static_string("libgc");
}
Heap::Stats stats() const {
......
......@@ -36,7 +36,7 @@ public:
virtual int features() const=0;
virtual Util::ptr_shared<char> name() const=0;
virtual Util::ptr_shared name() const=0;
virtual Stats stats() const=0;
virtual void force_collect()=0;
};
......
......@@ -26,7 +26,7 @@ bool Logger::_category_mask[Event::N_CATEGORIES];
namespace {
static void write_escaped_value(std::ostream &os, Util::ptr_shared<char> value) {
static void write_escaped_value(std::ostream &os, Util::ptr_shared value) {
for ( char const *current=value ; *current ; ++current ) {
switch (*current) {
case '&':
......@@ -58,7 +58,7 @@ static void write_indent(std::ostream &os, unsigned depth) {
static std::ofstream log_stream;
static bool empty_tag=false;
typedef std::vector<Util::ptr_shared<char>, GC::Alloc<Util::ptr_shared<char>, GC::MANUAL> > TagStack;
typedef std::vector<Util::ptr_shared, GC::Alloc<Util::ptr_shared, GC::MANUAL> > TagStack;
static TagStack &tag_stack() {
static TagStack stack;
return stack;
......@@ -158,7 +158,7 @@ void Logger::init() {
}
void Logger::_start(Event const &event) {
Util::ptr_shared<char> name=event.name();
Util::ptr_shared name=event.name();
if (empty_tag) {
log_stream << ">\n";
......@@ -185,7 +185,7 @@ void Logger::_start(Event const &event) {
}
void Logger::_skip() {
tag_stack().push_back(Util::ptr_shared<char>());
tag_stack().push_back(Util::ptr_shared());
}
void Logger::_finish() {
......
......@@ -26,7 +26,7 @@ namespace Debug {
template <Event::Category C=Event::OTHER>
class SimpleEvent : public Event {
public:
explicit SimpleEvent(Util::ptr_shared<char> name) : _name(name) {}
explicit SimpleEvent(Util::ptr_shared name) : _name(name) {}
explicit SimpleEvent(char const *name) : _name(Util::share_string(name)) {}
// default copy
......@@ -34,7 +34,7 @@ public:
static Category category() { return C; }
Util::ptr_shared<char> name() const { return _name; }
Util::ptr_shared name() const { return _name; }
unsigned propertyCount() const { return _properties.size(); }
PropertyPair property(unsigned property) const {
return _properties[property];
......@@ -43,21 +43,21 @@ public:
void generateChildEvents() const {}
protected:
void _addProperty(Util::ptr_shared<char> name,
Util::ptr_shared<char> value)
void _addProperty(Util::ptr_shared name,
Util::ptr_shared value)
{
_properties.push_back(PropertyPair(name, value));
}
void _addProperty(Util::ptr_shared<char> name, char const *value) {
void _addProperty(Util::ptr_shared name, char const *value) {
_addProperty(name, Util::share_string(value));
}
void _addProperty(char const *name, Util::ptr_shared<char> value) {
void _addProperty(char const *name, Util::ptr_shared value) {
_addProperty(Util::share_string(name), value);
}
void _addProperty(char const *name, char const *value) {
_addProperty(Util::share_string(name), Util::share_string(value));
}
void _addProperty(Util::ptr_shared<char> name, long value) {
void _addProperty(Util::ptr_shared name, long value) {
_addFormattedProperty(name, "%ld", value);
}
void _addProperty(char const *name, long value) {
......@@ -65,10 +65,10 @@ protected:
}
private:
Util::ptr_shared<char> _name;
Util::ptr_shared _name;
std::vector<PropertyPair, GC::Alloc<PropertyPair, GC::AUTO> > _properties;
void _addFormattedProperty(Util::ptr_shared<char> name, char const *format, ...)
void _addFormattedProperty(Util::ptr_shared name, char const *format, ...)
{
va_list args;
va_start(args, format);
......
......@@ -23,7 +23,7 @@ public:
int features() const;
Util::ptr_shared<char> name() const {
Util::ptr_shared name() const {
return Util::share_static_string("standard malloc()");
}
Stats stats() const;
......
......@@ -19,8 +19,8 @@ namespace Inkscape {
namespace Debug {
Util::ptr_shared<char> timestamp() {
Util::ptr_shared<char> result;
Util::ptr_shared timestamp() {
Util::ptr_shared result;
GTimeVal timestamp;
g_get_current_time(&timestamp);
gchar *value = g_strdup_printf( "%d.%06d", static_cast<gint>(timestamp.tv_sec), static_cast<gint>(timestamp.tv_usec) );
......
......@@ -18,7 +18,7 @@ namespace Inkscape {
namespace Debug {
Util::ptr_shared<char> timestamp();
Util::ptr_shared timestamp();
}
......
......@@ -27,7 +27,7 @@ typedef Debug::SimpleEvent<Debug::Event::REFCOUNT> RefCountEvent;
class BaseAnchorEvent : public RefCountEvent {
public:
BaseAnchorEvent(Anchored const *object, int bias,
Util::ptr_shared<char> name)
Util::ptr_shared name)
: RefCountEvent(name)
{
_addProperty("base", Util::format("%p", Core::base(const_cast<Anchored *>(object))));
......
......@@ -113,10 +113,10 @@ gchar *_get_path(Domain domain, Type type, char const *filename)
return path;
}
Util::ptr_shared<char> get_path(Domain domain, Type type, char const *filename)
Util::ptr_shared get_path(Domain domain, Type type, char const *filename)
{
char *path = _get_path(domain, type, filename);
Util::ptr_shared<char> result=Util::share_string(path);
Util::ptr_shared result=Util::share_string(path);
g_free(path);
return result;
}
......
......@@ -56,7 +56,7 @@ enum Domain {
USER
};
Util::ptr_shared<char> get_path(Domain domain, Type type,
Util::ptr_shared get_path(Domain domain, Type type,
char const *filename=NULL);
Glib::ustring get_path_ustring(Domain domain, Type type,
......
......@@ -40,8 +40,8 @@ public:
virtual void notifyChildAdded( Node &/*node*/, Node &/*child*/, Node */*prev*/ ) {}
virtual void notifyChildRemoved( Node &/*node*/, Node &/*child*/, Node */*prev*/ ) {}
virtual void notifyChildOrderChanged( Node &/*node*/, Node &/*child*/, Node */*old_prev*/, Node */*new_prev*/ ) {}
virtual void notifyContentChanged( Node &/*node*/, Util::ptr_shared<char> /*old_content*/, Util::ptr_shared<char> /*new_content*/ ) {}
virtual void notifyAttributeChanged( Node &/*node*/, GQuark name, Util::ptr_shared<char> /*old_value*/, Util::ptr_shared<char> /*new_value*/ ) {
virtual void notifyContentChanged( Node &/*node*/, Util::ptr_shared /*old_content*/, Util::ptr_shared /*new_content*/ ) {}
virtual void notifyAttributeChanged( Node &/*node*/, GQuark name, Util::ptr_shared /*old_value*/, Util::ptr_shared /*new_value*/ ) {
if ( name == _lockedAttr || name == _labelAttr ) {
if ( _mgr && _obj ) {
_mgr->_objectModified( _obj, 0 );
......@@ -59,9 +59,9 @@ public:
/*
namespace {
Util::ptr_shared<char> stringify_node(Node const &node);
Util::ptr_shared stringify_node(Node const &node);
Util::ptr_shared<char> stringify_obj(SPObject const &obj) {
Util::ptr_shared stringify_obj(SPObject const &obj) {
gchar *string;
if (obj.id) {
......@@ -70,7 +70,7 @@ Util::ptr_shared<char> stringify_obj(SPObject const &obj) {
string = g_strdup_printf("SPObject(%p) repr(%p)", &obj, obj.repr);
}
Util::ptr_shared<char> result=Util::share_string(string);
Util::ptr_shared result=Util::share_string(string);
g_free(string);
return result;
......@@ -80,7 +80,7 @@ typedef Debug::SimpleEvent<Debug::Event::OTHER> DebugLayer;
class DebugLayerNote : public DebugLayer {
public:
DebugLayerNote(Util::ptr_shared<char> descr)
DebugLayerNote(Util::ptr_shared descr)
: DebugLayer(Util::share_static_string("layer-note"))
{
_addProperty("descr", descr);
......@@ -97,7 +97,7 @@ public:
class DebugLayerObj : public DebugLayer {
public:
DebugLayerObj(SPObject const& obj, Util::ptr_shared<char> name)
DebugLayerObj(SPObject const& obj, Util::ptr_shared name)
: DebugLayer(name)
{
_addProperty("layer", stringify_obj(obj));
......
......@@ -76,7 +76,7 @@ public:
_filter(filter)
{}
virtual ~PrefNodeObserver() {}
virtual void notifyAttributeChanged(XML::Node &node, GQuark name, Util::ptr_shared<char>, Util::ptr_shared<char>);
virtual void notifyAttributeChanged(XML::Node &node, GQuark name, Util::ptr_shared, Util::ptr_shared);
private:
Observer &_observer;
Glib::ustring const _filter;
......@@ -561,7 +561,7 @@ Preferences::Observer::~Observer()
prefs->removeObserver(*this);
}
void Preferences::PrefNodeObserver::notifyAttributeChanged(XML::Node &node, GQuark name, Util::ptr_shared<char>, Util::ptr_shared<char> new_value)
void Preferences::PrefNodeObserver::notifyAttributeChanged(XML::Node &node, GQuark name, Util::ptr_shared, Util::ptr_shared new_value)
{
// filter out attributes we don't watch
gchar const *attr_name = g_quark_to_string(name);
......
......@@ -199,7 +199,7 @@ typedef Debug::SimpleEvent<Debug::Event::REFCOUNT> BaseRefCountEvent;
class RefCountEvent : public BaseRefCountEvent {
public:
RefCountEvent(SPObject *object, int bias, Util::ptr_shared<char> name)
RefCountEvent(SPObject *object, int bias, Util::ptr_shared name)
: BaseRefCountEvent(name)
{
_addProperty("object", Util::format("%p", object));
......
......@@ -75,8 +75,8 @@ void SPTRefReference::notifyChildOrderChanged(Inkscape::XML::Node &/*node*/, Ink
void SPTRefReference::notifyContentChanged(Inkscape::XML::Node &/*node*/,
Inkscape::Util::ptr_shared<char> /*old_content*/,
Inkscape::Util::ptr_shared<char> /*new_content*/)
Inkscape::Util::ptr_shared /*old_content*/,
Inkscape::Util::ptr_shared /*new_content*/)
{
SPObject *owner = getOwner();
......@@ -87,8 +87,8 @@ void SPTRefReference::notifyContentChanged(Inkscape::XML::Node &/*node*/,
void SPTRefReference::notifyAttributeChanged(Inkscape::XML::Node &/*node*/, GQuark /*name*/,
Inkscape::Util::ptr_shared<char> /*old_value*/,
Inkscape::Util::ptr_shared<char> /*new_value*/)
Inkscape::Util::ptr_shared /*old_value*/,
Inkscape::Util::ptr_shared /*new_value*/)
{
// Do nothing - tref only cares about textual content
}
......
......@@ -52,11 +52,11 @@ public:
virtual void notifyChildOrderChanged(Inkscape::XML::Node &node, Inkscape::XML::Node &child,
Inkscape::XML::Node *old_prev, Inkscape::XML::Node *new_prev);
virtual void notifyContentChanged(Inkscape::XML::Node &node,
Inkscape::Util::ptr_shared<char> old_content,
Inkscape::Util::ptr_shared<char> new_content);
Inkscape::Util::ptr_shared old_content,
Inkscape::Util::ptr_shared new_content);
virtual void notifyAttributeChanged(Inkscape::XML::Node &node, GQuark name,
Inkscape::Util::ptr_shared<char> old_value,
Inkscape::Util::ptr_shared<char> new_value);
Inkscape::Util::ptr_shared old_value,
Inkscape::Util::ptr_shared new_value);
/////////////////////////////////////////////////////////////////////
protected:
......
......@@ -148,8 +148,8 @@ public:
_pnl->_objectsChanged( _obj );
}
}
virtual void notifyContentChanged( Node &/*node*/, Util::ptr_shared<char> /*old_content*/, Util::ptr_shared<char> /*new_content*/ ) {}
virtual void notifyAttributeChanged( Node &/*node*/, GQuark name, Util::ptr_shared<char> /*old_value*/, Util::ptr_shared<char> /*new_value*/ ) {
virtual void notifyContentChanged( Node &/*node*/, Util::ptr_shared /*old_content*/, Util::ptr_shared /*new_content*/ ) {}
virtual void notifyAttributeChanged( Node &/*node*/, GQuark name, Util::ptr_shared /*old_value*/, Util::ptr_shared /*new_value*/ ) {
if ( _pnl && _obj ) {
if ( name == _lockedAttr || name == _labelAttr || name == _highlightAttr || name == _groupAttr || name == _styleAttr || name == _clipAttr || name == _maskAttr ) {
_pnl->_updateObject(_obj, name == _highlightAttr);
......
......@@ -56,8 +56,8 @@ public:
};
virtual void notifyContentChanged(Inkscape::XML::Node &node,
Inkscape::Util::ptr_shared<char> old_content,
Inkscape::Util::ptr_shared<char> new_content);
Inkscape::Util::ptr_shared old_content,
Inkscape::Util::ptr_shared new_content);
StyleDialog * _styleDialog;
};
......@@ -66,8 +66,8 @@ public:
void
StyleDialog::NodeObserver::notifyContentChanged(
Inkscape::XML::Node &/*node*/,
Inkscape::Util::ptr_shared<char> /*old_content*/,
Inkscape::Util::ptr_shared<char> /*new_content*/ ) {
Inkscape::Util::ptr_shared /*old_content*/,
Inkscape::Util::ptr_shared /*new_content*/ ) {
#ifdef DEBUG_STYLEDIALOG
std::cout << "StyleDialog::NodeObserver::notifyContentChanged" << std::endl;
......@@ -111,8 +111,8 @@ public:
virtual void notifyAttributeChanged( Inkscape::XML::Node &node,
GQuark qname,
Util::ptr_shared<char> /*old_value*/,
Util::ptr_shared<char> /*new_value*/ ) {
Util::ptr_shared /*old_value*/,
Util::ptr_shared /*new_value*/ ) {
if ( _styleDialog && _repr ) {
// For the moment only care about attributes that are directly used in selectors.
......
......@@ -106,8 +106,8 @@ public:
_pnl->_objectsChanged( _obj );
}
}
virtual void notifyContentChanged( Node &/*node*/, Util::ptr_shared<char> /*old_content*/, Util::ptr_shared<char> /*new_content*/ ) {}
virtual void notifyAttributeChanged( Node &/*node*/, GQuark name, Util::ptr_shared<char> /*old_value*/, Util::ptr_shared<char> /*new_value*/ ) {
virtual void notifyContentChanged( Node &/*node*/, Util::ptr_shared /*old_content*/, Util::ptr_shared /*new_content*/ ) {}
virtual void notifyAttributeChanged( Node &/*node*/, GQuark name, Util::ptr_shared /*old_value*/, Util::ptr_shared /*new_value*/ ) {
if ( _pnl && _obj ) {
if ( name == _labelAttr ) {
_pnl->_updateObject( _obj);
......
......@@ -68,7 +68,7 @@ public:
}
virtual void notifyAttributeChanged(Inkscape::XML::Node &/*node*/, GQuark attr,
Util::ptr_shared<char>, Util::ptr_shared<char>)
Util::ptr_shared, Util::ptr_shared)
{
// do nothing if blocked
if (_blocked) return;
......
......@@ -20,20 +20,20 @@ namespace Inkscape {
namespace Util {
inline ptr_shared<char> vformat(char const *format, va_list args) {
inline ptr_shared vformat(char const *format, va_list args) {
char *temp=g_strdup_vprintf(format, args);
ptr_shared<char> result=share_string(temp);
ptr_shared result=share_string(temp);
g_free(temp);
return result;
}
// needed since G_GNUC_PRINTF can only be used on a declaration
ptr_shared<char> format(char const *format, ...) G_GNUC_PRINTF(1,2);
inline ptr_shared<char> format(char const *format, ...) {
ptr_shared format(char const *format, ...) G_GNUC_PRINTF(1,2);
inline ptr_shared format(char const *format, ...) {
va_list args;
va_start(args, format);
ptr_shared<char> result=vformat(format, args);
ptr_shared result=vformat(format, args);
va_end(args);
return result;
......
/*
* Inkscape::Util::ptr_shared<T> - like T const *, but stronger
* Inkscape::Util::ptr_shared<T> - like T const *, but stronger.
* Used to hold c-style strings for objects that are managed by the gc.
*
* Authors:
* MenTaLguY <mental@rydia.net>
......@@ -15,13 +16,13 @@
namespace Inkscape {
namespace Util {
ptr_shared<char> share_string(char const *string) {
g_return_val_if_fail(string != NULL, share_unsafe<char>(NULL));
ptr_shared share_string(char const *string) {
g_return_val_if_fail(string != NULL, share_unsafe(NULL));
return share_string(string, std::strlen(string));
}
ptr_shared<char> share_string(char const *string, std::size_t length) {
g_return_val_if_fail(string != NULL, share_unsafe<char>(NULL));
ptr_shared share_string(char const *string, std::size_t length) {
g_return_val_if_fail(string != NULL, share_unsafe(NULL));
char *new_string=new (GC::ATOMIC) char[length+1];
std::memcpy(new_string, string, length);
new_string[length] = 0;
......
/*
* Inkscape::Util::ptr_shared<T> - like T const *, but stronger
* Inkscape::Util::ptr_shared<T> - like T const *, but stronger.
* Used to hold c-style strings for objects that are managed by the gc.
*
* Authors:
* MenTaLguY <mental@rydia.net>
......@@ -19,120 +20,84 @@
namespace Inkscape {
namespace Util {
template <typename T>
class ptr_shared {
public:
ptr_shared() : _obj(NULL) {}
template <typename T1>
ptr_shared(ptr_shared<T1> const &other) : _obj(other._obj) {}
ptr_shared() : _string(NULL) {}
ptr_shared(ptr_shared const &other) : _string(other._string) {}
T const *pointer() const { return _obj; }
operator char const *() const { return _string; }
operator bool() const { return _string; }
template <typename T1>
operator T1 const *() const { return _obj; }
char const *pointer() const { return _string; }
char const &operator[](int i) const { return _string[i]; }
operator bool() const { return _obj; }
T const &operator*() const { return *_obj; }
T const *operator->() const { return _obj; }
T const &operator[](int i) const { return _obj[i]; }
ptr_shared<T> operator+(int i) const {
return share_unsafe(_obj+i);
ptr_shared operator+(int i) const {
return share_unsafe(_string+i);
}
ptr_shared<T> operator-(int i) const {
return share_unsafe(_obj-i);
ptr_shared operator-(int i) const {
return share_unsafe(_string-i);
}
ptr_shared<T> &operator+=(int i) const {
_obj += i;
//WARNING: No bounds checking in += and -= functions. Moving the pointer
//past the end of the string and then back could probably cause the garbage
//collector to deallocate the string inbetween, as there's temporary no
//valid reference pointing into the allocated space.
ptr_shared &operator+=(int i) {
_string += i;
return *this;
}
ptr_shared<T> &operator-=(int i) const {
_obj -= i;
ptr_shared &operator-=(int i) {
_string -= i;
return *this;
}
template <typename T1>
std::ptrdiff_t operator-(ptr_shared<T1> const &other) {
return _obj - other._obj;
std::ptrdiff_t operator-(ptr_shared const &other) {
return _string - other._string;
}
template <typename T1>
ptr_shared<T> &operator=(ptr_shared<T1> const &other) {
_obj = other._obj;
ptr_shared &operator=(ptr_shared const &other) {
_string = other._string;
return *this;
}
template <typename T1>
bool operator==(ptr_shared<T1> const &other) const {
return _obj == other._obj;
bool operator==(ptr_shared const &other) const {
return _string == other._string;
}
template <typename T1>
bool operator!=(ptr_shared<T1> const &other) const {
return _obj != other._obj;
bool operator!=(ptr_shared const &other) const {
return _string != other._string;
}
template <typename T1>
bool operator>(ptr_shared<T1> const &other) const {
return _obj > other._obj;
bool operator>(ptr_shared const &other) const {
return _string > other._string;
}
template <typename T1>
bool operator<(ptr_shared<T1> const &other) const {
return _obj < other._obj;
}
static ptr_shared<T> share_unsafe(T const *obj) {
return ptr_shared<T>(obj);
bool operator<(ptr_shared const &other) const {
return _string < other._string;
}
protected:
explicit ptr_shared(T const *obj) : _obj(obj) {}
friend ptr_shared share_unsafe(char const *string);
private:
T const *_obj;
};
template <typename T>
inline ptr_shared<T> share(T const *obj) {
return share_unsafe(obj ? new T(*obj) : NULL);
}
ptr_shared(char const *string) : _string(string) {}
static ptr_shared share_unsafe(char const *string) {
return ptr_shared(string);
}
ptr_shared<char> share_string(char const *string);
ptr_shared<char> share_string(char const *string, std::size_t length);
//This class (and code usign it) assumes that it never has to free this
//pointer, and that the memory it points to will not be freed as long as a
//ptr_shared pointing to it exists.
char const *_string;
};
template <typename T>
inline ptr_shared<T> reshare(T const *obj) {
return ptr_shared<T>::share_unsafe(obj);
}
ptr_shared share_string(char const *string);
ptr_shared share_string(char const *string, std::size_t length);
template <typename T>
inline ptr_shared<T> share_unsafe(T const *obj) {
return ptr_shared<T>::share_unsafe(obj);
inline ptr_shared share_unsafe(char const *string) {
return ptr_shared::share_unsafe(string);
}
inline ptr_shared<char> share_static_string(char const *string) {
//TODO: Do we need this function?
inline ptr_shared share_static_string(char const *string) {
return share_unsafe(string);
}
template <typename T1, typename T2>
inline ptr_shared<T1> static_cast_shared(ptr_shared<T2> const &ref) {
return reshare(static_cast<T1 const *>(ref.pointer()));
}
template <typename T1, typename T2>
inline ptr_shared<T1> dynamic_cast_shared(ptr_shared<T2> const &ref) {
return reshare(dynamic_cast<T1 const *>(ref.pointer()));
}
template <typename T1, typename T2>
inline ptr_shared<T1> reinterpret_cast_shared(ptr_shared<T2> const &ref) {
return reshare(reinterpret_cast<T1 const *>(ref.pointer()));
}
}
}
......
......@@ -22,13 +22,13 @@ namespace XML {
* represented by this structure.
*/
struct AttributeRecord : public Inkscape::GC::Managed<> {
AttributeRecord(GQuark k, Inkscape::Util::ptr_shared<char> v)
AttributeRecord(GQuark k, Inkscape::Util::ptr_shared v)
: key(k), value(v) {}
/** @brief GQuark corresponding to the name of the attribute */
GQuark key;
/** @brief Shared pointer to the value of the attribute */
Inkscape::Util::ptr_shared<char> value;
Inkscape::Util::ptr_shared value;
// accept default copy constructor and assignment operator
};
......
......@@ -26,7 +26,7 @@ namespace XML {
* @brief Comment node, e.g. &lt;!-- Some comment --&gt;
*/
struct CommentNode : public SimpleNode {
CommentNode(Util::ptr_shared<char> content, Document *doc)
CommentNode(Util::ptr_shared content, Document *doc)
: SimpleNode(g_quark_from_static_string("comment"), doc)
{
setContent(content);
......
......@@ -69,7 +69,7 @@ void CompositeNodeObserver::notifyChildOrderChanged(Node &node, Node &child,
void CompositeNodeObserver::notifyContentChanged(
Node &node,
Util::ptr_shared<char> old_content, Util::ptr_shared<char> new_content
Util::ptr_shared old_content, Util::ptr_shared new_content
) {
_startIteration();
for ( ObserverRecordList::iterator iter=_active.begin() ;
......@@ -84,7 +84,7 @@ void CompositeNodeObserver::notifyContentChanged(
void CompositeNodeObserver::notifyAttributeChanged(
Node &node, GQuark name,
Util::ptr_shared<char> old_value, Util::ptr_shared<char> new_value
Util::ptr_shared old_value, Util::ptr_shared new_value
) {
_startIteration();
for ( ObserverRecordList::iterator iter=_active.begin() ;
......@@ -133,13 +133,13 @@ public:
}
}
void notifyContentChanged(Node &node, Util::ptr_shared<char> old_content, Util::ptr_shared<char> new_content) {
void notifyContentChanged(Node &node, Util::ptr_shared old_content, Util::ptr_shared new_content) {
if (vector.content_changed) {
vector.content_changed(&node, old_content, new_content, data);
}
}
void notifyAt