diff options
| author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2018-06-15 10:46:15 +0000 |
|---|---|---|
| committer | Marc Jeanmougin <marcjeanmougin@free.fr> | 2018-06-18 12:27:01 +0000 |
| commit | f4349fb3e45bd44cef0e2b69af4c9b4cf35dcf43 (patch) | |
| tree | 7c6044fd3a17a2665841959dac9b3b2110b27924 /src/xml | |
| parent | Run clang-tidy’s modernize-use-override pass. (diff) | |
| download | inkscape-f4349fb3e45bd44cef0e2b69af4c9b4cf35dcf43.tar.gz inkscape-f4349fb3e45bd44cef0e2b69af4c9b4cf35dcf43.zip | |
Run clang-tidy’s modernize-use-nullptr pass.
This replaces all NULL or 0 with nullptr when assigned to or returned as
a pointer.
Diffstat (limited to 'src/xml')
| -rw-r--r-- | src/xml/croco-node-iface.cpp | 2 | ||||
| -rw-r--r-- | src/xml/event.cpp | 12 | ||||
| -rw-r--r-- | src/xml/helper-observer.cpp | 6 | ||||
| -rw-r--r-- | src/xml/log-builder.cpp | 4 | ||||
| -rw-r--r-- | src/xml/log-builder.h | 2 | ||||
| -rw-r--r-- | src/xml/node-fns.cpp | 8 | ||||
| -rw-r--r-- | src/xml/node-fns.h | 8 | ||||
| -rw-r--r-- | src/xml/node-iterators.h | 4 | ||||
| -rw-r--r-- | src/xml/node.h | 6 | ||||
| -rw-r--r-- | src/xml/rebase-hrefs.cpp | 4 | ||||
| -rw-r--r-- | src/xml/repr-css.cpp | 74 | ||||
| -rw-r--r-- | src/xml/repr-io.cpp | 96 | ||||
| -rw-r--r-- | src/xml/repr-sorting.cpp | 6 | ||||
| -rw-r--r-- | src/xml/repr-util.cpp | 96 | ||||
| -rw-r--r-- | src/xml/repr.h | 12 | ||||
| -rw-r--r-- | src/xml/simple-node.cpp | 56 |
16 files changed, 198 insertions, 198 deletions
diff --git a/src/xml/croco-node-iface.cpp b/src/xml/croco-node-iface.cpp index 6bd5a6920..f9bb66532 100644 --- a/src/xml/croco-node-iface.cpp +++ b/src/xml/croco-node-iface.cpp @@ -31,7 +31,7 @@ static CRXMLNodePtr get_prev(CRXMLNodePtr cn) if (n_pos) { return n->parent()->nthChild(n_pos - 1); } else { - return NULL; + return nullptr; } } diff --git a/src/xml/event.cpp b/src/xml/event.cpp index d0ba10e08..ecb6d0130 100644 --- a/src/xml/event.cpp +++ b/src/xml/event.cpp @@ -38,7 +38,7 @@ sp_repr_begin_transaction (Inkscape::XML::Document *doc) EventTracker<SimpleEvent<Event::XML> > tracker("begin-transaction"); - g_assert(doc != NULL); + g_assert(doc != nullptr); doc->beginTransaction(); } @@ -51,7 +51,7 @@ sp_repr_rollback (Inkscape::XML::Document *doc) EventTracker<SimpleEvent<Event::XML> > tracker("rollback"); - g_assert(doc != NULL); + g_assert(doc != nullptr); doc->rollback(); } @@ -64,7 +64,7 @@ sp_repr_commit (Inkscape::XML::Document *doc) EventTracker<SimpleEvent<Event::XML> > tracker("commit"); - g_assert(doc != NULL); + g_assert(doc != nullptr); doc->commit(); } @@ -77,7 +77,7 @@ sp_repr_commit_undoable (Inkscape::XML::Document *doc) EventTracker<SimpleEvent<Event::XML> > tracker("commit"); - g_assert(doc != NULL); + g_assert(doc != nullptr); return doc->commitUndoable(); } @@ -184,7 +184,7 @@ void Inkscape::XML::replay_log_to_observer( Inkscape::XML::NodeObserver &observer ) { List<Inkscape::XML::Event const &> reversed = - reverse_list<Inkscape::XML::Event::ConstIterator>(log, NULL); + reverse_list<Inkscape::XML::Event::ConstIterator>(log, nullptr); for ( ; reversed ; ++reversed ) { reversed->replayOne(observer); } @@ -410,7 +410,7 @@ public: static Glib::ustring node_to_string(Node const &node) { Glib::ustring result; - char const *type_name=NULL; + char const *type_name=nullptr; switch (node.type()) { case Inkscape::XML::DOCUMENT_NODE: type_name = "Document"; diff --git a/src/xml/helper-observer.cpp b/src/xml/helper-observer.cpp index 022cad965..048d878a2 100644 --- a/src/xml/helper-observer.cpp +++ b/src/xml/helper-observer.cpp @@ -8,12 +8,12 @@ namespace XML { // Very simple observer that just emits a signal if anything happens to a node SignalObserver::SignalObserver() - : _oldsel(NULL) + : _oldsel(nullptr) {} SignalObserver::~SignalObserver() { - set(NULL); // if _oldsel!=nullptr, remove observer and decrease refcount + set(nullptr); // if _oldsel!=nullptr, remove observer and decrease refcount } // Add this observer to the SPObject and remove it from any previous object @@ -27,7 +27,7 @@ void SignalObserver::set(SPObject* o) _oldsel->getRepr()->removeObserver(*this); } sp_object_unref(_oldsel); - _oldsel = NULL; + _oldsel = nullptr; } if(o) { if (o->getRepr()) { diff --git a/src/xml/log-builder.cpp b/src/xml/log-builder.cpp index 12577cf69..0b17e41c4 100644 --- a/src/xml/log-builder.cpp +++ b/src/xml/log-builder.cpp @@ -22,12 +22,12 @@ namespace XML { void LogBuilder::discard() { sp_repr_free_log(_log); - _log = NULL; + _log = nullptr; } Event *LogBuilder::detach() { Event *log=_log; - _log = NULL; + _log = nullptr; return log; } diff --git a/src/xml/log-builder.h b/src/xml/log-builder.h index 8b0f6662d..d6505ddcb 100644 --- a/src/xml/log-builder.h +++ b/src/xml/log-builder.h @@ -32,7 +32,7 @@ class Node; */ class LogBuilder { public: - LogBuilder() : _log(NULL) {} + LogBuilder() : _log(nullptr) {} ~LogBuilder() { discard(); } /** @name Manipulate the recorded event log diff --git a/src/xml/node-fns.cpp b/src/xml/node-fns.cpp index e1506e3f2..18b12075d 100644 --- a/src/xml/node-fns.cpp +++ b/src/xml/node-fns.cpp @@ -42,7 +42,7 @@ bool id_permitted_internal_memoized(GQuark qname) { } bool id_permitted(Node const *node) { - g_return_val_if_fail(node != NULL, false); + g_return_val_if_fail(node != nullptr, false); if ( node->type() != ELEMENT_NODE ) { return false; @@ -62,14 +62,14 @@ Node *previous_node(Node *node) { using Inkscape::Algorithms::find_if_before; if ( !node || !node->parent() ) { - return NULL; + return nullptr; } Node *previous=find_if_before<NodeSiblingIterator>( - node->parent()->firstChild(), NULL, node_matches(*node) + node->parent()->firstChild(), nullptr, node_matches(*node) ); - g_assert(previous == NULL + g_assert(previous == nullptr ? node->parent()->firstChild() == node : previous->next() == node); diff --git a/src/xml/node-fns.h b/src/xml/node-fns.h index f6b1173db..c18201ff4 100644 --- a/src/xml/node-fns.h +++ b/src/xml/node-fns.h @@ -33,10 +33,10 @@ bool id_permitted(Node const *node); * @relates Inkscape::XML::Node */ inline Node *next_node(Node *node) { - return ( node ? node->next() : NULL ); + return ( node ? node->next() : nullptr ); } inline Node const *next_node(Node const *node) { - return ( node ? node->next() : NULL ); + return ( node ? node->next() : nullptr ); } //@} @@ -65,10 +65,10 @@ inline Node const *previous_node(Node const *node) { * @relates Inkscape::XML::Node */ inline Node *parent_node(Node *node) { - return ( node ? node->parent() : NULL ); + return ( node ? node->parent() : nullptr ); } inline Node const *parent_node(Node const *node) { - return ( node ? node->parent() : NULL ); + return ( node ? node->parent() : nullptr ); } //@} diff --git a/src/xml/node-iterators.h b/src/xml/node-iterators.h index 389d70be0..4e4b92b4d 100644 --- a/src/xml/node-iterators.h +++ b/src/xml/node-iterators.h @@ -20,13 +20,13 @@ namespace XML { struct NodeSiblingIteratorStrategy { static Node const *next(Node const *node) { - return ( node ? node->next() : NULL ); + return ( node ? node->next() : nullptr ); } }; struct NodeParentIteratorStrategy { static Node const *next(Node const *node) { - return ( node ? node->parent() : NULL ); + return ( node ? node->parent() : nullptr ); } }; diff --git a/src/xml/node.h b/src/xml/node.h index 85d9f6f12..3f19e8fa1 100644 --- a/src/xml/node.h +++ b/src/xml/node.h @@ -208,13 +208,13 @@ public: void setAttribute(char const *key, Glib::ustring const &value, bool is_interactive=false) { - setAttribute(key, value.empty() ? NULL : value.c_str(), is_interactive); + setAttribute(key, value.empty() ? nullptr : value.c_str(), is_interactive); } void setAttribute(Glib::ustring const &key, Glib::ustring const &value, bool is_interactive=false) { - setAttribute( key.empty() ? NULL : key.c_str(), - value.empty() ? NULL : value.c_str(), is_interactive); + setAttribute( key.empty() ? nullptr : key.c_str(), + value.empty() ? nullptr : value.c_str(), is_interactive); } //@} diff --git a/src/xml/rebase-hrefs.cpp b/src/xml/rebase-hrefs.cpp index 072a9b6e4..630882ed3 100644 --- a/src/xml/rebase-hrefs.cpp +++ b/src/xml/rebase-hrefs.cpp @@ -276,7 +276,7 @@ void Inkscape::XML::rebase_hrefs(SPDocument *const doc, gchar const *const new_b std::string new_href = sp_relative_path_from_path(abs_href, new_abs_base); ir->setAttribute("sodipodi:absref", ( spns ? abs_href.c_str() - : NULL )); + : nullptr )); if (!Glib::path_is_absolute(new_href)) { #ifdef WIN32 /* Native Windows path separators are replaced with / so that the href @@ -285,7 +285,7 @@ void Inkscape::XML::rebase_hrefs(SPDocument *const doc, gchar const *const new_b #endif ir->setAttribute("xlink:href", new_href.c_str()); } else { - ir->setAttribute("xlink:href", g_filename_to_uri(new_href.c_str(), NULL, NULL)); + ir->setAttribute("xlink:href", g_filename_to_uri(new_href.c_str(), nullptr, nullptr)); } /* impl: I assume that if !spns then any existing sodipodi:absref is about to get diff --git a/src/xml/repr-css.cpp b/src/xml/repr-css.cpp index f0b7e0d8d..9a0ba48de 100644 --- a/src/xml/repr-css.cpp +++ b/src/xml/repr-css.cpp @@ -59,7 +59,7 @@ static void sp_repr_css_add_components(SPCSSAttr *css, Node *repr, gchar const * */ SPCSSAttr *sp_repr_css_attr_new() { - static Inkscape::XML::Document *attr_doc=NULL; + static Inkscape::XML::Document *attr_doc=nullptr; if (!attr_doc) { attr_doc = new Inkscape::XML::SimpleDocument(); } @@ -71,7 +71,7 @@ SPCSSAttr *sp_repr_css_attr_new() */ void sp_repr_css_attr_unref(SPCSSAttr *css) { - g_assert(css != NULL); + g_assert(css != nullptr); Inkscape::GC::release((Node *) css); } @@ -83,8 +83,8 @@ void sp_repr_css_attr_unref(SPCSSAttr *css) */ SPCSSAttr *sp_repr_css_attr(Node *repr, gchar const *attr) { - g_assert(repr != NULL); - g_assert(attr != NULL); + g_assert(repr != nullptr); + g_assert(attr != nullptr); SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_add_components(css, repr, attr); @@ -104,21 +104,21 @@ SPCSSAttr *sp_repr_css_attr_parse_color_to_fill(const Glib::ustring &text) char *str = const_cast<char *>(text.data()); bool attempt_alpha = false; if ( !str || ( *str == '\0' ) ) { - return NULL; // this is OK due to boolean short-circuit + return nullptr; // this is OK due to boolean short-circuit } // those conditionals guard against parsing e.g. the string "fab" as "fab000" // (incomplete color) and "45fab71" as "45fab710" (incomplete alpha) if ( *str == '#' ) { if ( len < 7 ) { - return NULL; + return nullptr; } if ( len >= 9 ) { attempt_alpha = true; } } else { if ( len < 6 ) { - return NULL; + return nullptr; } if ( len >= 8 ) { attempt_alpha = true; @@ -158,7 +158,7 @@ SPCSSAttr *sp_repr_css_attr_parse_color_to_fill(const Glib::ustring &text) sp_repr_css_set_property(color_css, "fill-opacity", opcss.str().data()); return color_css; } - return NULL; + return nullptr; } @@ -181,8 +181,8 @@ static void sp_repr_css_attr_inherited_recursive(SPCSSAttr *css, Node *repr, gch */ SPCSSAttr *sp_repr_css_attr_inherited(Node *repr, gchar const *attr) { - g_assert(repr != NULL); - g_assert(attr != NULL); + g_assert(repr != nullptr); + g_assert(attr != nullptr); SPCSSAttr *css = sp_repr_css_attr_new(); @@ -198,9 +198,9 @@ SPCSSAttr *sp_repr_css_attr_inherited(Node *repr, gchar const *attr) */ static void sp_repr_css_add_components(SPCSSAttr *css, Node *repr, gchar const *attr) { - g_assert(css != NULL); - g_assert(repr != NULL); - g_assert(attr != NULL); + g_assert(css != nullptr); + g_assert(repr != nullptr); + g_assert(attr != nullptr); char const *data = repr->attribute(attr); sp_repr_css_attr_add_from_string(css, data); @@ -212,11 +212,11 @@ static void sp_repr_css_add_components(SPCSSAttr *css, Node *repr, gchar const * */ char const *sp_repr_css_property(SPCSSAttr *css, gchar const *name, gchar const *defval) { - g_assert(css != NULL); - g_assert(name != NULL); + g_assert(css != nullptr); + g_assert(name != nullptr); char const *attr = ((Node *)css)->attribute(name); - return ( attr == NULL + return ( attr == nullptr ? defval : attr ); } @@ -226,8 +226,8 @@ char const *sp_repr_css_property(SPCSSAttr *css, gchar const *name, gchar const */ bool sp_repr_css_property_is_unset(SPCSSAttr *css, gchar const *name) { - g_assert(css != NULL); - g_assert(name != NULL); + g_assert(css != nullptr); + g_assert(name != nullptr); char const *attr = ((Node *)css)->attribute(name); return (attr && !strcmp(attr, "inkscape:unset")); @@ -239,8 +239,8 @@ bool sp_repr_css_property_is_unset(SPCSSAttr *css, gchar const *name) */ void sp_repr_css_set_property(SPCSSAttr *css, gchar const *name, gchar const *value) { - g_assert(css != NULL); - g_assert(name != NULL); + g_assert(css != nullptr); + g_assert(name != nullptr); ((Node *) css)->setAttribute(name, value, false); } @@ -250,8 +250,8 @@ void sp_repr_css_set_property(SPCSSAttr *css, gchar const *name, gchar const *va */ void sp_repr_css_unset_property(SPCSSAttr *css, gchar const *name) { - g_assert(css != NULL); - g_assert(name != NULL); + g_assert(css != nullptr); + g_assert(name != nullptr); ((Node *) css)->setAttribute(name, "inkscape:unset", false); } @@ -261,8 +261,8 @@ void sp_repr_css_unset_property(SPCSSAttr *css, gchar const *name) */ double sp_repr_css_double_property(SPCSSAttr *css, gchar const *name, double defval) { - g_assert(css != NULL); - g_assert(name != NULL); + g_assert(css != nullptr); + g_assert(name != nullptr); double val = defval; sp_repr_get_double((Node *) css, name, &val); @@ -297,9 +297,9 @@ void sp_repr_css_write_string(SPCSSAttr *css, Glib::ustring &str) */ void sp_repr_css_set(Node *repr, SPCSSAttr *css, gchar const *attr) { - g_assert(repr != NULL); - g_assert(css != NULL); - g_assert(attr != NULL); + g_assert(repr != nullptr); + g_assert(css != nullptr); + g_assert(attr != nullptr); Glib::ustring value; sp_repr_css_write_string(css, value); @@ -332,8 +332,8 @@ void sp_repr_css_print(SPCSSAttr *css) */ void sp_repr_css_merge(SPCSSAttr *dst, SPCSSAttr *src) { - g_assert(dst != NULL); - g_assert(src != NULL); + g_assert(dst != nullptr); + g_assert(src != nullptr); dst->mergeFrom(src, ""); } @@ -428,7 +428,7 @@ static void sp_repr_css_merge_from_decl_list(SPCSSAttr *css, CRDeclaration const */ void sp_repr_css_attr_add_from_string(SPCSSAttr *css, gchar const *p) { - if (p != NULL) { + if (p != nullptr) { CRDeclaration *const decl_list = cr_declaration_parse_list_from_buf(reinterpret_cast<guchar const *>(p), CR_UTF_8); if (decl_list) { @@ -445,9 +445,9 @@ void sp_repr_css_attr_add_from_string(SPCSSAttr *css, gchar const *p) */ void sp_repr_css_change(Node *repr, SPCSSAttr *css, gchar const *attr) { - g_assert(repr != NULL); - g_assert(css != NULL); - g_assert(attr != NULL); + g_assert(repr != nullptr); + g_assert(css != nullptr); + g_assert(attr != nullptr); SPCSSAttr *current = sp_repr_css_attr(repr, attr); sp_repr_css_merge(current, css); @@ -458,13 +458,13 @@ void sp_repr_css_change(Node *repr, SPCSSAttr *css, gchar const *attr) void sp_repr_css_change_recursive(Node *repr, SPCSSAttr *css, gchar const *attr) { - g_assert(repr != NULL); - g_assert(css != NULL); - g_assert(attr != NULL); + g_assert(repr != nullptr); + g_assert(css != nullptr); + g_assert(attr != nullptr); sp_repr_css_change(repr, css, attr); - for (Node *child = repr->firstChild(); child != NULL; child = child->next()) { + for (Node *child = repr->firstChild(); child != nullptr; child = child->next()) { sp_repr_css_change_recursive(child, css, attr); } } diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp index 519b30cd4..0fdd891a2 100644 --- a/src/xml/repr-io.cpp +++ b/src/xml/repr-io.cpp @@ -72,16 +72,16 @@ class XmlSource { public: XmlSource() - : filename(0), - encoding(0), - fp(NULL), + : filename(nullptr), + encoding(nullptr), + fp(nullptr), firstFewLen(0), LoadEntities(false), cachedData(), cachedPos(0), dummy("x"), - instr(NULL), - gzin(NULL) + instr(nullptr), + gzin(nullptr) { for (int k=0;k<4;k++) { @@ -93,7 +93,7 @@ public: close(); if ( encoding ) { g_free(encoding); - encoding = 0; + encoding = nullptr; } } @@ -138,7 +138,7 @@ int XmlSource::setFile(char const *filename, bool load_entities=false) if ( (some >= 2) && (firstFew[0] == 0x1f) && (firstFew[1] == 0x8b) ) { //g_message(" the file being read is gzip'd. extract it"); fclose(fp); - fp = 0; + fp = nullptr; fp = Inkscape::IO::fopen_utf8name(filename, "r"); instr = new Inkscape::IO::UriInputStream(fp, dummy); gzin = new Inkscape::IO::GzipInputStream(*instr); @@ -198,14 +198,14 @@ int XmlSource::setFile(char const *filename, bool load_entities=false) GRegex *regex = g_regex_new( "<!ENTITY\\s+[^>\\s]+\\s+(SYSTEM|PUBLIC\\s+\"[^>\"]+\")\\s+\"[^>\"]+\"\\s*>", - G_REGEX_CASELESS, G_REGEX_MATCH_NEWLINE_ANY, NULL); + G_REGEX_CASELESS, G_REGEX_MATCH_NEWLINE_ANY, nullptr); g_regex_match (regex, this->cachedData.c_str(), G_REGEX_MATCH_NEWLINE_ANY, &info); while (g_match_info_matches (info)) { if (g_match_info_fetch_pos (info, 1, &start, &end)) this->cachedData.erase(start, end - start); - g_match_info_next (info, NULL); + g_match_info_next (info, nullptr); } g_match_info_free(info); g_regex_unref(regex); @@ -302,17 +302,17 @@ int XmlSource::close() if ( gzin ) { gzin->close(); delete gzin; - gzin = 0; + gzin = nullptr; } if ( instr ) { instr->close(); - fp = 0; + fp = nullptr; delete instr; - instr = 0; + instr = nullptr; } if ( fp ) { fclose(fp); - fp = 0; + fp = nullptr; } return 0; } @@ -323,15 +323,15 @@ int XmlSource::close() */ Document *sp_repr_read_file (const gchar * filename, const gchar *default_ns) { - xmlDocPtr doc = 0; - Document * rdoc = 0; + xmlDocPtr doc = nullptr; + Document * rdoc = nullptr; xmlSubstituteEntitiesDefault(1); - g_return_val_if_fail(filename != NULL, NULL); + g_return_val_if_fail(filename != nullptr, NULL); if (!Inkscape::IO::file_test(filename, G_FILE_TEST_EXISTS)) { g_warning("Can't open file: %s (doesn't exist)", filename); - return NULL; + return nullptr; } /* fixme: A file can disappear at any time, including between now and when we actually try to * open it. Get rid of the above test once we're sure that we correctly handle @@ -340,10 +340,10 @@ Document *sp_repr_read_file (const gchar * filename, const gchar *default_ns) // TODO: bulia, please look over gsize bytesRead = 0; gsize bytesWritten = 0; - GError* error = NULL; + GError* error = nullptr; // TODO: need to replace with our own fopen and reading gchar* localFilename = g_filename_from_utf8(filename, -1, &bytesRead, &bytesWritten, &error); - g_return_val_if_fail(localFilename != NULL, NULL); + g_return_val_if_fail(localFilename != nullptr, NULL); Inkscape::IO::dump_fopen_call(filename, "N"); @@ -383,14 +383,14 @@ Document *sp_repr_read_mem (const gchar * buffer, gint length, const gchar *defa xmlSubstituteEntitiesDefault(1); - g_return_val_if_fail (buffer != NULL, NULL); + g_return_val_if_fail (buffer != nullptr, NULL); int parser_options = XML_PARSE_HUGE | XML_PARSE_RECOVER; parser_options |= XML_PARSE_NONET; // TODO: should we allow network access? // proper solution would be to check the preference "/options/externalresources/xml/allow_net_access" // as done in XmlSource::readXml which gets called by the analogous sp_repr_read_file() // but sp_repr_read_mem() seems to be called in locations where Inkscape::Preferences::get() fails badly - doc = xmlReadMemory (const_cast<gchar *>(buffer), length, NULL, NULL, parser_options); + doc = xmlReadMemory (const_cast<gchar *>(buffer), length, nullptr, nullptr, parser_options); rdoc = sp_repr_do_read (doc, default_ns); if (doc) { @@ -465,20 +465,20 @@ void promote_to_namespace(Node *repr, const gchar *prefix) { */ Document *sp_repr_do_read (xmlDocPtr doc, const gchar *default_ns) { - if (doc == NULL) { - return NULL; + if (doc == nullptr) { + return nullptr; } xmlNodePtr node=xmlDocGetRootElement (doc); - if (node == NULL) { - return NULL; + if (node == nullptr) { + return nullptr; } std::map<std::string, std::string> prefix_map; Document *rdoc = new Inkscape::XML::SimpleDocument(); - Node *root=NULL; - for ( node = doc->children ; node != NULL ; node = node->next ) { + Node *root=nullptr; + for ( node = doc->children ; node != nullptr ; node = node->next ) { if (node->type == XML_ELEMENT_NODE) { Node *repr=sp_repr_svg_read_node(rdoc, node, default_ns, prefix_map); rdoc->appendChild(repr); @@ -487,7 +487,7 @@ Document *sp_repr_do_read (xmlDocPtr doc, const gchar *default_ns) if (!root) { root = repr; } else { - root = NULL; + root = nullptr; break; } } else if ( node->type == XML_COMMENT_NODE || node->type == XML_PI_NODE ) { @@ -497,7 +497,7 @@ Document *sp_repr_do_read (xmlDocPtr doc, const gchar *default_ns) } } - if (root != NULL) { + if (root != nullptr) { /* promote elements of some XML documents that don't use namespaces * into their default namespace */ if ( default_ns && !strchr(root->name(), ':') ) { @@ -535,11 +535,11 @@ gint sp_repr_qualified_name (gchar *p, gint len, xmlNsPtr ns, const xmlChar *nam prefix_map[reinterpret_cast<const char*>(prefix)] = reinterpret_cast<const char*>(ns->href); } else { - prefix = NULL; + prefix = nullptr; } } else { - prefix = NULL; + prefix = nullptr; } if (prefix) { @@ -557,8 +557,8 @@ static Node *sp_repr_svg_read_node (Document *xml_doc, xmlNodePtr node, const gc if (node->type == XML_TEXT_NODE || node->type == XML_CDATA_SECTION_NODE) { - if (node->content == NULL || *(node->content) == '\0') { - return NULL; // empty text node + if (node->content == nullptr || *(node->content) == '\0') { + return nullptr; // empty text node } // Since libxml2 2.9.0, only element nodes are checked, thus check parent. @@ -571,7 +571,7 @@ static Node *sp_repr_svg_read_node (Document *xml_doc, xmlNodePtr node, const gc ; // skip all whitespace if (!(*p)) { // this is an all-whitespace node, and preserve == default - return NULL; // we do not preserve all-whitespace nodes unless we are asked to + return nullptr; // we do not preserve all-whitespace nodes unless we are asked to } // We keep track of original node type so that CDATA sections are preserved on output. @@ -589,14 +589,14 @@ static Node *sp_repr_svg_read_node (Document *xml_doc, xmlNodePtr node, const gc } if (node->type == XML_ENTITY_DECL) { - return NULL; + return nullptr; } sp_repr_qualified_name (c, 256, node->ns, node->name, default_ns, prefix_map); Node *repr = xml_doc->createElement(c); /* TODO remember node->ns->prefix if node->ns != NULL */ - for (prop = node->properties; prop != NULL; prop = prop->next) { + for (prop = node->properties; prop != nullptr; prop = prop->next) { if (prop->children) { sp_repr_qualified_name (c, 256, prop->ns, prop->name, default_ns, prefix_map); repr->setAttribute(c, reinterpret_cast<gchar*>(prop->children->content)); @@ -608,7 +608,7 @@ static Node *sp_repr_svg_read_node (Document *xml_doc, xmlNodePtr node, const gc repr->setContent(reinterpret_cast<gchar*>(node->content)); } - for (child = node->xmlChildrenNode; child != NULL; child = child->next) { + for (child = node->xmlChildrenNode; child != nullptr; child = child->next) { Node *crepr = sp_repr_svg_read_node (xml_doc, child, default_ns, prefix_map); if (crepr) { repr->appendChild(crepr); @@ -660,7 +660,7 @@ Glib::ustring sp_repr_save_buf(Document *doc) Inkscape::IO::StringOutputStream souts; Inkscape::IO::OutputStreamWriter outs(souts); - sp_repr_save_writer(doc, &outs, SP_INKSCAPE_NS_URI, 0, 0); + sp_repr_save_writer(doc, &outs, SP_INKSCAPE_NS_URI, nullptr, nullptr); outs.close(); Glib::ustring buf = souts.getString(); @@ -675,7 +675,7 @@ void sp_repr_save_stream(Document *doc, FILE *fp, gchar const *default_ns, bool { Inkscape::URI dummy("x"); Inkscape::IO::UriOutputStream bout(fp, dummy); - Inkscape::IO::GzipOutputStream *gout = compress ? new Inkscape::IO::GzipOutputStream(bout) : NULL; + Inkscape::IO::GzipOutputStream *gout = compress ? new Inkscape::IO::GzipOutputStream(bout) : nullptr; Inkscape::IO::OutputStreamWriter *out = compress ? new Inkscape::IO::OutputStreamWriter( *gout ) : new Inkscape::IO::OutputStreamWriter( bout ); sp_repr_save_writer(doc, out, default_ns, old_href_abs_base, new_href_abs_base); @@ -710,7 +710,7 @@ bool sp_repr_save_rebased_file(Document *doc, gchar const *const filename, gchar Inkscape::IO::dump_fopen_call( filename, "B" ); FILE *file = Inkscape::IO::fopen_utf8name(filename, "w"); - if (file == NULL) { + if (file == nullptr) { return false; } @@ -744,7 +744,7 @@ bool sp_repr_save_rebased_file(Document *doc, gchar const *const filename, gchar */ bool sp_repr_save_file(Document *doc, gchar const *const filename, gchar const *default_ns) { - return sp_repr_save_rebased_file(doc, filename, default_ns, NULL, NULL); + return sp_repr_save_rebased_file(doc, filename, default_ns, nullptr, nullptr); } @@ -864,7 +864,7 @@ static void sp_repr_write_stream_root_element(Node *repr, Writer &out, { using Inkscape::Util::ptr_shared; - g_assert(repr != NULL); + g_assert(repr != nullptr); // Clean unnecessary attributes and stype properties. (Controlled by preferences.) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -882,7 +882,7 @@ static void sp_repr_write_stream_root_element(Node *repr, Writer &out, Glib::QueryQuark elide_prefix=GQuark(0); if ( default_ns && ns_map.find(GQuark(0)) == ns_map.end() ) { - elide_prefix = g_quark_from_string(sp_xml_ns_uri_prefix(default_ns, NULL)); + elide_prefix = g_quark_from_string(sp_xml_ns_uri_prefix(default_ns, nullptr)); } List<AttributeRecord const> attributes=repr->attributeList(); @@ -964,10 +964,10 @@ void sp_repr_write_stream_element( Node * repr, Writer & out, gchar const *old_href_base, gchar const *new_href_base ) { - Node *child = 0; + Node *child = nullptr; bool loose = false; - g_return_if_fail (repr != NULL); + g_return_if_fail (repr != nullptr); if ( indent_level > 16 ) { indent_level = 16; @@ -993,7 +993,7 @@ void sp_repr_write_stream_element( Node * repr, Writer & out, // if this is a <text> element, suppress formatting whitespace // for its content and children: gchar const *xml_space_attr = repr->attribute("xml:space"); - if (xml_space_attr != NULL && !strcmp(xml_space_attr, "preserve")) { + if (xml_space_attr != nullptr && !strcmp(xml_space_attr, "preserve")) { add_whitespace = false; } @@ -1017,7 +1017,7 @@ void sp_repr_write_stream_element( Node * repr, Writer & out, } loose = TRUE; - for (child = repr->firstChild() ; child != NULL; child = child->next()) { + for (child = repr->firstChild() ; child != nullptr; child = child->next()) { if (child->type() == Inkscape::XML::TEXT_NODE) { loose = FALSE; break; @@ -1028,7 +1028,7 @@ void sp_repr_write_stream_element( Node * repr, Writer & out, if (loose && add_whitespace) { out.writeString( "\n" ); } - for (child = repr->firstChild(); child != NULL; child = child->next()) { + for (child = repr->firstChild(); child != nullptr; child = child->next()) { sp_repr_write_stream(child, out, ( loose ? indent_level + 1 : 0 ), add_whitespace, elide_prefix, inlineattrs, indent, old_href_base, new_href_base); diff --git a/src/xml/repr-sorting.cpp b/src/xml/repr-sorting.cpp index 09a39acb2..75fb74166 100644 --- a/src/xml/repr-sorting.cpp +++ b/src/xml/repr-sorting.cpp @@ -14,7 +14,7 @@ Inkscape::XML::Node const *LCA(Inkscape::XML::Node const *a, Inkscape::XML::Node { using Inkscape::Algorithms::longest_common_suffix; Inkscape::XML::Node const *ancestor = longest_common_suffix<Inkscape::XML::NodeConstParentIterator>( - a, b, NULL, &same_repr); + a, b, nullptr, &same_repr); bool OK = false; if (ancestor) { if (ancestor->type() != Inkscape::XML::DOCUMENT_NODE) { @@ -24,7 +24,7 @@ Inkscape::XML::Node const *LCA(Inkscape::XML::Node const *a, Inkscape::XML::Node if ( OK ) { return ancestor; } else { - return NULL; + return nullptr; } } @@ -36,7 +36,7 @@ Inkscape::XML::Node *LCA(Inkscape::XML::Node *a, Inkscape::XML::Node *b) Inkscape::XML::Node const *AncetreFils(Inkscape::XML::Node const *descendent, Inkscape::XML::Node const *ancestor) { - Inkscape::XML::Node const *result = 0; + Inkscape::XML::Node const *result = nullptr; if ( descendent && ancestor ) { if (descendent->parent() == ancestor) { result = descendent; diff --git a/src/xml/repr-util.cpp b/src/xml/repr-util.cpp index 6da1233db..7946eebfc 100644 --- a/src/xml/repr-util.cpp +++ b/src/xml/repr-util.cpp @@ -71,7 +71,7 @@ static char *sp_xml_ns_auto_prefix(char const *uri); * SPXMLNs */ -static SPXMLNs *namespaces=NULL; +static SPXMLNs *namespaces=nullptr; /* * There are the prefixes to use for the XML namespaces defined @@ -134,7 +134,7 @@ static void sp_xml_ns_register_defaults() defaults[10].uri = g_quark_from_static_string(SP_OLD_CC_NS_URI); defaults[10].prefix = g_quark_from_static_string("cc"); - defaults[10].next = NULL; + defaults[10].next = nullptr; namespaces = &defaults[0]; } @@ -169,14 +169,14 @@ gchar const *sp_xml_ns_uri_prefix(gchar const *uri, gchar const *suggested) { char const *prefix; - if (!uri) return NULL; + if (!uri) return nullptr; if (!namespaces) { sp_xml_ns_register_defaults(); } GQuark const key = g_quark_from_string(uri); - prefix = NULL; + prefix = nullptr; for ( SPXMLNs *iter=namespaces ; iter ; iter = iter->next ) { if ( iter->uri == key ) { prefix = g_quark_to_string(iter->prefix); @@ -210,7 +210,7 @@ gchar const *sp_xml_ns_uri_prefix(gchar const *uri, gchar const *suggested) } ns = g_new(SPXMLNs, 1); - g_assert( ns != NULL ); + g_assert( ns != nullptr ); ns->uri = g_quark_from_string(uri); ns->prefix = g_quark_from_string(new_prefix); @@ -230,14 +230,14 @@ gchar const *sp_xml_ns_prefix_uri(gchar const *prefix) SPXMLNs *iter; char const *uri; - if (!prefix) return NULL; + if (!prefix) return nullptr; if (!namespaces) { sp_xml_ns_register_defaults(); } GQuark const key = g_quark_from_string(prefix); - uri = NULL; + uri = nullptr; for ( iter = namespaces ; iter ; iter = iter->next ) { if ( iter->prefix == key ) { uri = g_quark_to_string(iter->uri); @@ -268,7 +268,7 @@ int sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::No // Find the lowest common ancestor(LCA) Inkscape::XML::Node const *ancestor = LCA(first, second); - g_assert(ancestor != NULL); + g_assert(ancestor != nullptr); if (ancestor == first) { return 1; @@ -324,7 +324,7 @@ Inkscape::XML::Node *sp_repr_lookup_child(Inkscape::XML::Node *repr, gchar const *key, gchar const *value) { - g_return_val_if_fail(repr != NULL, NULL); + g_return_val_if_fail(repr != nullptr, NULL); for ( Inkscape::XML::Node *child = repr->firstChild() ; child ; child = child->next() ) { gchar const *child_value = child->attribute(key); if ( (child_value == value) || @@ -333,14 +333,14 @@ Inkscape::XML::Node *sp_repr_lookup_child(Inkscape::XML::Node *repr, return child; } } - return NULL; + return nullptr; } Inkscape::XML::Node const *sp_repr_lookup_name( Inkscape::XML::Node const *repr, gchar const *name, gint maxdepth ) { - Inkscape::XML::Node const *found = 0; - g_return_val_if_fail(repr != NULL, NULL); - g_return_val_if_fail(name != NULL, NULL); + Inkscape::XML::Node const *found = nullptr; + g_return_val_if_fail(repr != nullptr, NULL); + g_return_val_if_fail(name != nullptr, NULL); GQuark const quark = g_quark_from_string(name); @@ -369,8 +369,8 @@ std::vector<Inkscape::XML::Node const *> sp_repr_lookup_name_many( Inkscape::XML { std::vector<Inkscape::XML::Node const *> nodes; std::vector<Inkscape::XML::Node const *> found; - g_return_val_if_fail(repr != NULL, nodes); - g_return_val_if_fail(name != NULL, nodes); + g_return_val_if_fail(repr != nullptr, nodes); + g_return_val_if_fail(name != nullptr, nodes); GQuark const quark = g_quark_from_string(name); @@ -398,10 +398,10 @@ std::vector<Inkscape::XML::Node const *> sp_repr_lookup_name_many( Inkscape::XML */ bool sp_repr_is_meta_element(const Inkscape::XML::Node *node) { - if (node == NULL) return false; + if (node == nullptr) return false; if (node->type() != Inkscape::XML::ELEMENT_NODE) return false; gchar const *name = node->name(); - if (name == NULL) return false; + if (name == nullptr) return false; if (!std::strcmp(name, "svg:title")) return true; if (!std::strcmp(name, "svg:desc")) return true; if (!std::strcmp(name, "svg:metadata")) return true; @@ -418,13 +418,13 @@ unsigned int sp_repr_get_boolean(Inkscape::XML::Node *repr, gchar const *key, un { gchar const *v; - g_return_val_if_fail(repr != NULL, FALSE); - g_return_val_if_fail(key != NULL, FALSE); - g_return_val_if_fail(val != NULL, FALSE); + g_return_val_if_fail(repr != nullptr, FALSE); + g_return_val_if_fail(key != nullptr, FALSE); + g_return_val_if_fail(val != nullptr, FALSE); v = repr->attribute(key); - if (v != NULL) { + if (v != nullptr) { if (!g_ascii_strcasecmp(v, "true") || !g_ascii_strcasecmp(v, "yes" ) || !g_ascii_strcasecmp(v, "y" ) || @@ -444,13 +444,13 @@ unsigned int sp_repr_get_int(Inkscape::XML::Node *repr, gchar const *key, int *v { gchar const *v; - g_return_val_if_fail(repr != NULL, FALSE); - g_return_val_if_fail(key != NULL, FALSE); - g_return_val_if_fail(val != NULL, FALSE); + g_return_val_if_fail(repr != nullptr, FALSE); + g_return_val_if_fail(key != nullptr, FALSE); + g_return_val_if_fail(val != nullptr, FALSE); v = repr->attribute(key); - if (v != NULL) { + if (v != nullptr) { *val = atoi(v); return TRUE; } @@ -460,14 +460,14 @@ unsigned int sp_repr_get_int(Inkscape::XML::Node *repr, gchar const *key, int *v unsigned int sp_repr_get_double(Inkscape::XML::Node *repr, gchar const *key, double *val) { - g_return_val_if_fail(repr != NULL, FALSE); - g_return_val_if_fail(key != NULL, FALSE); - g_return_val_if_fail(val != NULL, FALSE); + g_return_val_if_fail(repr != nullptr, FALSE); + g_return_val_if_fail(key != nullptr, FALSE); + g_return_val_if_fail(val != nullptr, FALSE); gchar const *v = repr->attribute(key); - if (v != NULL) { - *val = g_ascii_strtod(v, NULL); + if (v != nullptr) { + *val = g_ascii_strtod(v, nullptr); return TRUE; } @@ -476,8 +476,8 @@ unsigned int sp_repr_get_double(Inkscape::XML::Node *repr, gchar const *key, dou unsigned int sp_repr_set_boolean(Inkscape::XML::Node *repr, gchar const *key, unsigned int val) { - g_return_val_if_fail(repr != NULL, FALSE); - g_return_val_if_fail(key != NULL, FALSE); + g_return_val_if_fail(repr != nullptr, FALSE); + g_return_val_if_fail(key != nullptr, FALSE); repr->setAttribute(key, (val) ? "true" : "false"); return true; @@ -487,8 +487,8 @@ unsigned int sp_repr_set_int(Inkscape::XML::Node *repr, gchar const *key, int va { gchar c[32]; - g_return_val_if_fail(repr != NULL, FALSE); - g_return_val_if_fail(key != NULL, FALSE); + g_return_val_if_fail(repr != nullptr, FALSE); + g_return_val_if_fail(key != nullptr, FALSE); g_snprintf(c, 32, "%d", val); @@ -503,8 +503,8 @@ unsigned int sp_repr_set_int(Inkscape::XML::Node *repr, gchar const *key, int va */ unsigned int sp_repr_set_css_double(Inkscape::XML::Node *repr, gchar const *key, double val) { - g_return_val_if_fail(repr != NULL, FALSE); - g_return_val_if_fail(key != NULL, FALSE); + g_return_val_if_fail(repr != nullptr, FALSE); + g_return_val_if_fail(key != nullptr, FALSE); Inkscape::CSSOStringStream os; os << val; @@ -520,8 +520,8 @@ unsigned int sp_repr_set_css_double(Inkscape::XML::Node *repr, gchar const *key, */ unsigned int sp_repr_set_svg_double(Inkscape::XML::Node *repr, gchar const *key, double val) { - g_return_val_if_fail(repr != NULL, FALSE); - g_return_val_if_fail(key != NULL, FALSE); + g_return_val_if_fail(repr != nullptr, FALSE); + g_return_val_if_fail(key != nullptr, FALSE); g_return_val_if_fail(val==val, FALSE);//tests for nan Inkscape::SVGOStringStream os; @@ -538,8 +538,8 @@ unsigned int sp_repr_set_svg_double(Inkscape::XML::Node *repr, gchar const *key, */ unsigned int sp_repr_set_svg_length(Inkscape::XML::Node *repr, gchar const *key, SVGLength &val) { - g_return_val_if_fail(repr != NULL, FALSE); - g_return_val_if_fail(key != NULL, FALSE); + g_return_val_if_fail(repr != nullptr, FALSE); + g_return_val_if_fail(key != nullptr, FALSE); repr->setAttribute(key, val.write()); return true; @@ -547,8 +547,8 @@ unsigned int sp_repr_set_svg_length(Inkscape::XML::Node *repr, gchar const *key, unsigned sp_repr_set_point(Inkscape::XML::Node *repr, gchar const *key, Geom::Point const & val) { - g_return_val_if_fail(repr != NULL, FALSE); - g_return_val_if_fail(key != NULL, FALSE); + g_return_val_if_fail(repr != nullptr, FALSE); + g_return_val_if_fail(key != nullptr, FALSE); Inkscape::SVGOStringStream os; os << val[Geom::X] << "," << val[Geom::Y]; @@ -559,20 +559,20 @@ unsigned sp_repr_set_point(Inkscape::XML::Node *repr, gchar const *key, Geom::Po unsigned int sp_repr_get_point(Inkscape::XML::Node *repr, gchar const *key, Geom::Point *val) { - g_return_val_if_fail(repr != NULL, FALSE); - g_return_val_if_fail(key != NULL, FALSE); - g_return_val_if_fail(val != NULL, FALSE); + g_return_val_if_fail(repr != nullptr, FALSE); + g_return_val_if_fail(key != nullptr, FALSE); + g_return_val_if_fail(val != nullptr, FALSE); gchar const *v = repr->attribute(key); - g_return_val_if_fail(v != NULL, FALSE); + g_return_val_if_fail(v != nullptr, FALSE); gchar ** strarray = g_strsplit(v, ",", 2); if (strarray && strarray[0] && strarray[1]) { double newx, newy; - newx = g_ascii_strtod(strarray[0], NULL); - newy = g_ascii_strtod(strarray[1], NULL); + newx = g_ascii_strtod(strarray[0], nullptr); + newy = g_ascii_strtod(strarray[1], nullptr); g_strfreev (strarray); *val = Geom::Point(newx, newy); return TRUE; diff --git a/src/xml/repr.h b/src/xml/repr.h index ecc5c02a6..632b1f28a 100644 --- a/src/xml/repr.h +++ b/src/xml/repr.h @@ -56,18 +56,18 @@ Inkscape::XML::Document *sp_repr_read_mem(char const *buffer, int length, char c void sp_repr_write_stream(Inkscape::XML::Node *repr, Inkscape::IO::Writer &out, int indent_level, bool add_whitespace, Glib::QueryQuark elide_prefix, int inlineattrs, int indent, - char const *old_href_base = NULL, - char const *new_href_base = NULL); + char const *old_href_base = nullptr, + char const *new_href_base = nullptr); Inkscape::XML::Document *sp_repr_read_buf (const Glib::ustring &buf, const char *default_ns); Glib::ustring sp_repr_save_buf(Inkscape::XML::Document *doc); // TODO convert to std::string void sp_repr_save_stream(Inkscape::XML::Document *doc, FILE *to_file, - char const *default_ns = NULL, bool compress = false, - char const *old_href_base = NULL, - char const *new_href_base = NULL); + char const *default_ns = nullptr, bool compress = false, + char const *old_href_base = nullptr, + char const *new_href_base = nullptr); -bool sp_repr_save_file(Inkscape::XML::Document *doc, char const *filename, char const *default_ns=NULL); +bool sp_repr_save_file(Inkscape::XML::Document *doc, char const *filename, char const *default_ns=nullptr); bool sp_repr_save_rebased_file(Inkscape::XML::Document *doc, char const *filename_utf8, char const *default_ns, char const *old_base, char const *new_base_filename); diff --git a/src/xml/simple-node.cpp b/src/xml/simple-node.cpp index a1a7127cc..13cf10783 100644 --- a/src/xml/simple-node.cpp +++ b/src/xml/simple-node.cpp @@ -166,11 +166,11 @@ SimpleNode::SimpleNode(int code, Document *document) : Node(), _name(code), _attributes(), _child_count(0), _cached_positions_valid(false) { - g_assert(document != NULL); + g_assert(document != nullptr); this->_document = document; - this->_parent = this->_next = NULL; - this->_first_child = this->_last_child = NULL; + this->_parent = this->_next = nullptr; + this->_first_child = this->_last_child = nullptr; _observers.add(_subtree_observers); } @@ -182,14 +182,14 @@ SimpleNode::SimpleNode(SimpleNode const &node, Document *document) _child_count(node._child_count), _cached_positions_valid(node._cached_positions_valid) { - g_assert(document != NULL); + g_assert(document != nullptr); _document = document; - _parent = _next = NULL; - _first_child = _last_child = NULL; + _parent = _next = nullptr; + _first_child = _last_child = nullptr; for ( SimpleNode *child = node._first_child ; - child != NULL ; child = child->_next ) + child != nullptr ; child = child->_next ) { SimpleNode *child_copy=dynamic_cast<SimpleNode *>(child->duplicate(document)); @@ -222,7 +222,7 @@ gchar const *SimpleNode::content() const { } gchar const *SimpleNode::attribute(gchar const *name) const { - g_return_val_if_fail(name != NULL, NULL); + g_return_val_if_fail(name != nullptr, NULL); GQuark const key = g_quark_from_string(name); @@ -234,11 +234,11 @@ gchar const *SimpleNode::attribute(gchar const *name) const { } } - return NULL; + return nullptr; } unsigned SimpleNode::position() const { - g_return_val_if_fail(_parent != NULL, 0); + g_return_val_if_fail(_parent != nullptr, 0); return _parent->_childPosition(*this); } @@ -265,7 +265,7 @@ Node *SimpleNode::nthChild(unsigned index) { } bool SimpleNode::matchAttributeName(gchar const *partial_name) const { - g_return_val_if_fail(partial_name != NULL, false); + g_return_val_if_fail(partial_name != nullptr, false); for ( List<AttributeRecord const> iter = _attributes ; iter ; ++iter ) @@ -319,19 +319,19 @@ SimpleNode::setAttribute(gchar const *name, gchar const *value, bool const /*is_ gchar* cleaned_value = g_strdup( value ); // Only check elements in SVG name space and don't block setting attribute to NULL. - if( element.substr(0,4) == "svg:" && value != NULL) { + if( element.substr(0,4) == "svg:" && value != nullptr) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if( prefs->getBool("/options/svgoutput/check_on_editing") ) { gchar const *id_char = attribute("id"); - Glib::ustring id = (id_char == NULL ? "" : id_char ); + Glib::ustring id = (id_char == nullptr ? "" : id_char ); unsigned int flags = sp_attribute_clean_get_prefs(); bool attr_warn = flags & SP_ATTR_CLEAN_ATTR_WARN; bool attr_remove = flags & SP_ATTR_CLEAN_ATTR_REMOVE; // Check attributes - if( (attr_warn || attr_remove) && value != NULL ) { + if( (attr_warn || attr_remove) && value != nullptr ) { bool is_useful = sp_attribute_check_attribute( element, id, name, attr_warn ); if( !is_useful && attr_remove ) { g_free( cleaned_value ); @@ -468,8 +468,8 @@ void SimpleNode::removeChild(Node *generic_child) { _cached_positions_valid = false; } - child->_next = NULL; - child->_setParent(NULL); + child->_next = nullptr; + child->_setParent(nullptr); _child_count--; _document->logger()->notifyChildRemoved(*this, *child, ref); @@ -527,12 +527,12 @@ void SimpleNode::changeOrder(Node *generic_child, Node *generic_ref) { } void SimpleNode::setPosition(int pos) { - g_return_if_fail(_parent != NULL); + g_return_if_fail(_parent != nullptr); // a position beyond the end of the list means the end of the list; // a negative position is the same as an infinitely large position - SimpleNode *ref=NULL; + SimpleNode *ref=nullptr; for ( SimpleNode *sibling = _parent->_first_child ; sibling && pos ; sibling = sibling->_next ) { @@ -582,11 +582,11 @@ void SimpleNode::synthesizeEvents(NodeEventVector const *vector, void *data) { for ( List<AttributeRecord const> iter = _attributes ; iter ; ++iter ) { - vector->attr_changed(this, g_quark_to_string(iter->key), NULL, iter->value, false, data); + vector->attr_changed(this, g_quark_to_string(iter->key), nullptr, iter->value, false, data); } } if (vector->child_added) { - SimpleNode *ref = NULL; + SimpleNode *ref = nullptr; for ( SimpleNode *child = this->_first_child ; child ; child = child->_next ) { @@ -595,7 +595,7 @@ void SimpleNode::synthesizeEvents(NodeEventVector const *vector, void *data) { } } if (vector->content_changed) { - vector->content_changed(this, NULL, this->_content, data); + vector->content_changed(this, nullptr, this->_content, data); } } @@ -618,7 +618,7 @@ void SimpleNode::recursivePrintTree(unsigned level) { } else { std::cout << name() << std::endl; } - for (SimpleNode *child = _first_child; child != NULL; child = child->_next) { + for (SimpleNode *child = _first_child; child != nullptr; child = child->_next) { child->recursivePrintTree( level+1 ); } } @@ -637,17 +637,17 @@ Node *SimpleNode::root() { return child; } } - return NULL; + return nullptr; } else if ( parent->type() == ELEMENT_NODE ) { return parent; } else { - return NULL; + return nullptr; } } void SimpleNode::cleanOriginal(Node *src, gchar const *key){ std::vector<Node *> to_delete; - for ( Node *child = this->firstChild() ; child != NULL ; child = child->next() ) + for ( Node *child = this->firstChild() ; child != nullptr ; child = child->next() ) { gchar const *id = child->attribute(key); if (id) { @@ -715,8 +715,8 @@ bool SimpleNode::equal(Node const *other, bool recursive) { } void SimpleNode::mergeFrom(Node const *src, gchar const *key, bool extension, bool clean) { - g_return_if_fail(src != NULL); - g_return_if_fail(key != NULL); + g_return_if_fail(src != nullptr); + g_return_if_fail(key != nullptr); g_assert(src != this); setContent(src->content()); @@ -729,7 +729,7 @@ void SimpleNode::mergeFrom(Node const *src, gchar const *key, bool extension, bo cleanOriginal(srcp, key); } - for ( Node const *child = src->firstChild() ; child != NULL ; child = child->next() ) + for ( Node const *child = src->firstChild() ; child != nullptr ; child = child->next() ) { gchar const *id = child->attribute(key); if (id) { |
