diff options
| author | Thomas Holder <thomas@thomas-holder.de> | 2019-11-03 19:57:31 +0000 |
|---|---|---|
| committer | Thomas Holder <thomas@thomas-holder.de> | 2019-11-03 19:57:31 +0000 |
| commit | 7c38b95f02b7fad29ead9057ccb50a9f48c904ae (patch) | |
| tree | 6cdc1ee90970d43826a61852e2c1029c515361ab /src/attributes.cpp | |
| parent | sanity check for XML attribute names (diff) | |
| download | inkscape-7c38b95f02b7fad29ead9057ccb50a9f48c904ae.tar.gz inkscape-7c38b95f02b7fad29ead9057ccb50a9f48c904ae.zip | |
make SP_ATTRIBUTE_IS_CSS a function
Diffstat (limited to 'src/attributes.cpp')
| -rw-r--r-- | src/attributes.cpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/attributes.cpp b/src/attributes.cpp index 549dcf8ce..15f1e51b5 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -566,7 +566,9 @@ static_assert(n_attrs == SPAttributeEnum_SIZE, ""); /** * Inverse to the \c props array for lookup by name. */ -struct AttributeLookupImpl { +class AttributeLookupImpl { + friend SPAttributeEnum sp_attribute_lookup(gchar const *key); + struct cstrless { bool operator()(char const *lhs, char const *rhs) const { return std::strcmp(lhs, rhs) < 0; } }; @@ -607,20 +609,11 @@ sp_attribute_name(SPAttributeEnum id) return props[id].name; } -std::vector<Glib::ustring> sp_attribute_name_list(bool cssattr, bool attr) +std::vector<Glib::ustring> sp_attribute_name_list(bool css_only) { std::vector<Glib::ustring> result; - static AttributeLookupImpl const _instance; - bool add = attr; for (auto prop : props) { - if (prop.code == SP_ATTR_D) { - if (cssattr) { - add = true; - } else if (attr) { - add = false; - } - } - if (add) { + if (!css_only || SP_ATTRIBUTE_IS_CSS(prop.code)) { result.emplace_back(prop.name); } } @@ -628,6 +621,9 @@ std::vector<Glib::ustring> sp_attribute_name_list(bool cssattr, bool attr) return result; } +bool SP_ATTRIBUTE_IS_CSS(SPAttributeEnum k) { // + return (k >= SP_ATTR_D) && (k < SP_PROP_SYSTEM_LANGUAGE); +} /* Local Variables: |
