diff options
| author | Martin Owens <doctormo@gmail.com> | 2019-03-06 23:54:12 +0000 |
|---|---|---|
| committer | Martin Owens <doctormo@gmail.com> | 2019-03-06 23:54:12 +0000 |
| commit | 3711d5d705436c20590c1ff4cef12e67beed6597 (patch) | |
| tree | 9026f75a574bc3b9b531acb959eced87c5d4a9f7 /src/object | |
| parent | Merge: Correct text for enabling grid (diff) | |
| parent | Avoid the “using std::*;” or “using namespace std;” constructs. (diff) | |
| download | inkscape-3711d5d705436c20590c1ff4cef12e67beed6597.tar.gz inkscape-3711d5d705436c20590c1ff4cef12e67beed6597.zip | |
Merge: Avoid the “using std::*;” or “using namespace std;” construct
Diffstat (limited to 'src/object')
| -rw-r--r-- | src/object/sp-filter.cpp | 14 | ||||
| -rw-r--r-- | src/object/sp-guide.cpp | 8 | ||||
| -rw-r--r-- | src/object/sp-item-rm-unsatisfied-cns.cpp | 3 | ||||
| -rw-r--r-- | src/object/sp-item-update-cns.cpp | 11 | ||||
| -rw-r--r-- | src/object/sp-object.cpp | 23 |
5 files changed, 24 insertions, 35 deletions
diff --git a/src/object/sp-filter.cpp b/src/object/sp-filter.cpp index 24f849cc6..da7e8142d 100644 --- a/src/object/sp-filter.cpp +++ b/src/object/sp-filter.cpp @@ -19,6 +19,7 @@ #include <map> #include <cstring> #include <utility> +#include <vector> #include <glibmm.h> @@ -31,9 +32,6 @@ #include "uri.h" #include "xml/repr.h" -using std::map; -using std::pair; - static void filter_ref_changed(SPObject *old_ref, SPObject *ref, SPFilter *filter); static void filter_ref_modified(SPObject *href, guint flags, SPFilter *filter); @@ -101,7 +99,7 @@ void SPFilter::release() { this->href = nullptr; } - for (map<gchar *, int, ltstr>::const_iterator i = this->_image_name->begin() ; i != this->_image_name->end() ; ++i) { + for (std::map<gchar *, int, ltstr>::const_iterator i = this->_image_name->begin() ; i != this->_image_name->end() ; ++i) { g_free(i->first); } @@ -421,7 +419,7 @@ int SPFilter::primitive_count() const { } int SPFilter::get_image_name(gchar const *name) const { - map<gchar *, int, ltstr>::iterator result = this->_image_name->find(const_cast<gchar*>(name)); + std::map<gchar *, int, ltstr>::iterator result = this->_image_name->find(const_cast<gchar*>(name)); if (result == this->_image_name->end()) return -1; else return (*result).second; } @@ -430,8 +428,8 @@ int SPFilter::set_image_name(gchar const *name) { int value = this->_image_number_next; this->_image_number_next++; gchar *name_copy = strdup(name); - pair<gchar*,int> new_pair(name_copy, value); - const pair<map<gchar*,int,ltstr>::iterator,bool> ret = this->_image_name->insert(new_pair); + std::pair<gchar*,int> new_pair(name_copy, value); + const std::pair<std::map<gchar*,int,ltstr>::iterator,bool> ret = this->_image_name->insert(new_pair); if (ret.second == false) { // The element is not inserted (because an element with the same key was already in the map) // Therefore, free the memory allocated for the new entry: @@ -467,7 +465,7 @@ gchar const *SPFilter::name_for_image(int const image) const { return nullptr; break; default: - for (map<gchar *, int, ltstr>::const_iterator i + for (std::map<gchar *, int, ltstr>::const_iterator i = this->_image_name->begin() ; i != this->_image_name->end() ; ++i) { if (i->second == image) { diff --git a/src/object/sp-guide.cpp b/src/object/sp-guide.cpp index bbb66aa4a..8dbc68f09 100644 --- a/src/object/sp-guide.cpp +++ b/src/object/sp-guide.cpp @@ -19,6 +19,7 @@ #include <algorithm> #include <cstring> #include <string> +#include <vector> #include "display/sp-canvas.h" #include "display/guideline.h" @@ -40,7 +41,6 @@ #include "verbs.h" using Inkscape::DocumentUndo; -using std::vector; SPGuide::SPGuide() : SPObject() @@ -406,7 +406,7 @@ void SPGuide::moveto(Geom::Point const point_on_line, bool const commit) } /* DISABLED CODE BECAUSE SPGuideAttachment IS NOT USE AT THE MOMENT (johan) - for (vector<SPGuideAttachment>::const_iterator i(attached_items.begin()), + for (std::vector<SPGuideAttachment>::const_iterator i(attached_items.begin()), iEnd(attached_items.end()); i != iEnd; ++i) { @@ -445,7 +445,7 @@ void SPGuide::set_normal(Geom::Point const normal_to_line, bool const commit) } /* DISABLED CODE BECAUSE SPGuideAttachment IS NOT USE AT THE MOMENT (johan) - for (vector<SPGuideAttachment>::const_iterator i(attached_items.begin()), + for (std::vector<SPGuideAttachment>::const_iterator i(attached_items.begin()), iEnd(attached_items.end()); i != iEnd; ++i) { @@ -550,7 +550,7 @@ void sp_guide_remove(SPGuide *guide) { g_assert(SP_IS_GUIDE(guide)); - for (vector<SPGuideAttachment>::const_iterator i(guide->attached_items.begin()), + for (std::vector<SPGuideAttachment>::const_iterator i(guide->attached_items.begin()), iEnd(guide->attached_items.end()); i != iEnd; ++i) { diff --git a/src/object/sp-item-rm-unsatisfied-cns.cpp b/src/object/sp-item-rm-unsatisfied-cns.cpp index 88fe6ca56..3b476e20d 100644 --- a/src/object/sp-item-rm-unsatisfied-cns.cpp +++ b/src/object/sp-item-rm-unsatisfied-cns.cpp @@ -10,13 +10,12 @@ #include <algorithm> #include <2geom/coord.h> +#include <vector> #include "remove-last.h" #include "sp-guide.h" #include "sp-item-rm-unsatisfied-cns.h" -using std::vector; - void sp_item_rm_unsatisfied_cns(SPItem &item) { if (item.constraints.empty()) { diff --git a/src/object/sp-item-update-cns.cpp b/src/object/sp-item-update-cns.cpp index f70d91b9f..c16627eab 100644 --- a/src/object/sp-item-update-cns.cpp +++ b/src/object/sp-item-update-cns.cpp @@ -8,31 +8,28 @@ * Released under GNU GPL v2+, read the file 'COPYING' for more information. */ - +#include <vector> #include "satisfied-guide-cns.h" #include "sp-item-update-cns.h" #include "sp-guide.h" -using std::find; -using std::vector; - void sp_item_update_cns(SPItem &item, SPDesktop const &desktop) { std::vector<Inkscape::SnapCandidatePoint> snappoints; item.getSnappoints(snappoints, nullptr); /* TODO: Implement the ordering. */ - vector<SPGuideConstraint> found_cns; + std::vector<SPGuideConstraint> found_cns; satisfied_guide_cns(desktop, snappoints, found_cns); /* effic: It might be nice to avoid an n^2 algorithm, but in practice n will be small enough that it's still usually more efficient. */ - for (vector<SPGuideConstraint>::const_iterator fi(found_cns.begin()), + for (std::vector<SPGuideConstraint>::const_iterator fi(found_cns.begin()), fiEnd(found_cns.end()); fi != fiEnd; ++fi) { SPGuideConstraint const &cn = *fi; - if ( find(item.constraints.begin(), + if ( std::find(item.constraints.begin(), item.constraints.end(), cn) == item.constraints.end() ) diff --git a/src/object/sp-object.cpp b/src/object/sp-object.cpp index 5222fc5f2..714518f08 100644 --- a/src/object/sp-object.cpp +++ b/src/object/sp-object.cpp @@ -18,6 +18,7 @@ #include <cstring> #include <string> +#include <vector> #include <boost/range/adaptor/transformed.hpp> @@ -44,12 +45,6 @@ #include "util/format.h" #include "util/longest-common-suffix.h" -using std::memcpy; -using std::strchr; -using std::strcmp; -using std::strlen; -using std::strstr; - #define noSP_OBJECT_DEBUG_CASCADE #define noSP_OBJECT_DEBUG @@ -736,7 +731,7 @@ void SPObject::invoke_build(SPDocument *document, Inkscape::XML::Node *repr, uns } /* Redefine ID, if required */ - if ((id == nullptr) || (strcmp(id, this->getId()) != 0)) { + if ((id == nullptr) || (std::strcmp(id, this->getId()) != 0)) { this->repr->setAttribute("id", this->getId()); } } else if (id) { @@ -944,17 +939,17 @@ void SPObject::set(SPAttributeEnum key, gchar const* value) { object->_default_label = nullptr; break; case SP_ATTR_INKSCAPE_COLLECT: - if ( value && !strcmp(value, "always") ) { + if ( value && !std::strcmp(value, "always") ) { object->setCollectionPolicy(SPObject::ALWAYS_COLLECT); } else { object->setCollectionPolicy(SPObject::COLLECT_WITH_PARENT); } break; case SP_ATTR_XML_SPACE: - if (value && !strcmp(value, "preserve")) { + if (value && !std::strcmp(value, "preserve")) { object->xml_space.value = SP_XML_SPACE_PRESERVE; object->xml_space.set = TRUE; - } else if (value && !strcmp(value, "default")) { + } else if (value && !std::strcmp(value, "default")) { object->xml_space.value = SP_XML_SPACE_DEFAULT; object->xml_space.set = TRUE; } else if (object->parent) { @@ -1410,7 +1405,7 @@ sp_object_get_unique_id(SPObject *object, gchar const *name = object->getRepr()->name(); g_assert(name != nullptr); - gchar const *local = strchr(name, ':'); + gchar const *local = std::strchr(name, ':'); if (local) { name = local + 1; } @@ -1421,10 +1416,10 @@ sp_object_get_unique_id(SPObject *object, } } - size_t const name_len = strlen(name); + size_t const name_len = std::strlen(name); size_t const buflen = name_len + (sizeof(count) * 10 / 4) + 1; gchar *const buf = (gchar *) g_malloc(buflen); - memcpy(buf, name, name_len); + std::memcpy(buf, name, name_len); gchar *const count_buf = buf + name_len; size_t const count_buflen = buflen - name_len; do { @@ -1567,7 +1562,7 @@ SPObject* SPObject::findFirstChild(gchar const *tagname) const for (auto& child: const_cast<SPObject*>(this)->children) { if (child.repr->type() == Inkscape::XML::ELEMENT_NODE && - !strcmp(child.repr->name(), tagname)) { + !std::strcmp(child.repr->name(), tagname)) { return &child; } } |
