98#include <unordered_map>
107 auto it =
map.find(
id);
109 if (it ==
map.end()) {
110 std::cerr <<
"WARNING: unknown type: " <<
id << std::endl;
117 bool supportsId(std::string
const &
id)
const
119 return map.find(
id) !=
map.end();
122 static Factory
const &
get()
124 static Factory
const singleton;
131 template <
typename T>
132 static Func
constexpr make = [] () ->
SPObject* {
return new T; };
133 static Func
constexpr null = [] () ->
SPObject* {
return nullptr; };
135 std::unordered_map<std::string, Func>
const map =
138 {
"inkscape:box3d", make<SPBox3D> },
139 {
"inkscape:box3dside", make<Box3DSide> },
140 {
"svg:color-profile", make<Inkscape::ColorProfile> },
141 {
"inkscape:persp3d", make<Persp3D> },
142 {
"svg:a", make<SPAnchor> },
143 {
"svg:clipPath", make<SPClipPath> },
144 {
"svg:defs", make<SPDefs> },
145 {
"svg:desc", make<SPDesc> },
146 {
"svg:ellipse", [] () ->
SPObject* {
151 {
"svg:circle", [] () ->
SPObject* {
161 {
"svg:filter", make<SPFilter> },
162 {
"svg:flowDiv", make<SPFlowdiv> },
163 {
"svg:flowSpan", make<SPFlowtspan> },
164 {
"svg:flowPara", make<SPFlowpara> },
165 {
"svg:flowLine", make<SPFlowline> },
166 {
"svg:flowRegionBreak", make<SPFlowregionbreak> },
167 {
"svg:flowRegion", make<SPFlowregion> },
168 {
"svg:flowRegionExclude", make<SPFlowregionExclude> },
169 {
"svg:flowRoot", make<SPFlowtext> },
170 {
"svg:font", make<SPFont> },
171 {
"svg:font-face", make<SPFontFace> },
172 {
"svg:glyph", make<SPGlyph> },
173 {
"svg:hkern", make<SPHkern> },
174 {
"svg:vkern", make<SPVkern> },
175 {
"sodipodi:guide", make<SPGuide> },
176 {
"inkscape:page", make<SPPage> },
177 {
"svg:hatch", make<SPHatch> },
178 {
"svg:hatchpath", make<SPHatchPath> },
179 {
"svg:hatchPath", [] () ->
SPObject* {
180 std::cerr <<
"Warning: <hatchPath> has been renamed <hatchpath>" << std::endl;
183 {
"svg:image", make<SPImage> },
184 {
"svg:g", make<SPGroup> },
185 {
"svg:line", make<SPLine> },
186 {
"svg:linearGradient", make<SPLinearGradient> },
187 {
"svg:marker", make<SPMarker> },
188 {
"svg:mask", make<SPMask> },
190 std::cerr <<
"Warning: <mesh> has been renamed <meshgradient>." << std::endl;
191 std::cerr <<
"Warning: <mesh> has been repurposed as a shape that tightly wraps a <meshgradient>." << std::endl;
194 {
"svg:meshGradient", [] () ->
SPObject* {
195 std::cerr <<
"Warning: <meshGradient> has been renamed <meshgradient>" << std::endl;
198 {
"svg:meshgradient", [] () ->
SPObject* {
201 {
"svg:meshPatch", [] () ->
SPObject* {
202 std::cerr <<
"Warning: <meshPatch> and <meshRow> have been renamed <meshpatch> and <meshrow>" << std::endl;
205 {
"svg:meshpatch", make<SPMeshpatch> },
206 {
"svg:meshRow", make<SPMeshrow> },
207 {
"svg:meshrow", make<SPMeshrow> },
208 {
"svg:metadata", make<SPMetadata> },
209 {
"svg:missing-glyph", make<SPMissingGlyph> },
210 {
"sodipodi:namedview", make<SPNamedView> },
211 {
"inkscape:offset", make<SPOffset> },
212 {
"svg:path", make<SPPath> },
213 {
"svg:pattern", make<SPPattern> },
214 {
"svg:polygon", make<SPPolygon> },
215 {
"svg:polyline", make<SPPolyLine> },
216 {
"svg:radialGradient", make<SPRadialGradient> },
217 {
"svg:rect", make<SPRect> },
218 {
"rect", make<SPRect> },
219 {
"svg:svg", make<SPRoot> },
220 {
"svg:script", make<SPScript> },
221 {
"svg:solidColor", [] () ->
SPObject* {
222 std::cerr <<
"Warning: <solidColor> has been renamed <solidcolor>" << std::endl;
225 {
"svg:solidColor", [] () ->
SPObject* {
226 std::cerr <<
"Warning: <solidColor> has been renamed <solidcolor>" << std::endl;
229 {
"svg:solidcolor", make<SPSolidColor> },
230 {
"spiral", make<SPSpiral> },
231 {
"star", make<SPStar> },
232 {
"svg:stop", make<SPStop> },
233 {
"string", make<SPString> },
234 {
"svg:style", make<SPStyleElem> },
235 {
"svg:switch", make<SPSwitch> },
236 {
"svg:symbol", make<SPSymbol> },
237 {
"inkscape:tag", make<SPTag> },
238 {
"inkscape:tagref", make<SPTagUse> },
239 {
"svg:text", make<SPText> },
240 {
"svg:title", make<SPTitle> },
241 {
"svg:tref", make<SPTRef> },
242 {
"svg:tspan", make<SPTSpan> },
243 {
"svg:textPath", make<SPTextPath> },
244 {
"svg:use", make<SPUse> },
245 {
"inkscape:path-effect", make<LivePathEffectObject> },
248 {
"svg:feBlend", make<SPFeBlend> },
249 {
"svg:feColorMatrix", make<SPFeColorMatrix> },
250 {
"svg:feComponentTransfer", make<SPFeComponentTransfer> },
255 {
"svg:feComposite", make<SPFeComposite> },
256 {
"svg:feConvolveMatrix", make<SPFeConvolveMatrix> },
257 {
"svg:feDiffuseLighting", make<SPFeDiffuseLighting> },
258 {
"svg:feDisplacementMap", make<SPFeDisplacementMap> },
259 {
"svg:feDistantLight", make<SPFeDistantLight> },
260 {
"svg:feFlood", make<SPFeFlood> },
261 {
"svg:feGaussianBlur", make<SPGaussianBlur> },
262 {
"svg:feImage", make<SPFeImage> },
263 {
"svg:feMerge", make<SPFeMerge> },
264 {
"svg:feMergeNode", make<SPFeMergeNode> },
265 {
"svg:feMorphology", make<SPFeMorphology> },
266 {
"svg:feOffset", make<SPFeOffset> },
267 {
"svg:fePointLight", make<SPFePointLight> },
268 {
"svg:feSpecularLighting", make<SPFeSpecularLighting> },
269 {
"svg:feSpotLight", make<SPFeSpotLight> },
270 {
"svg:feTile", make<SPFeTile> },
271 {
"svg:feTurbulence", make<SPFeTurbulence> },
272 {
"inkscape:grid", make<SPGrid> },
276 {
"inkscape:clipboard", null },
277 {
"inkscape:templateinfo", null },
278 {
"inkscape:_templateinfo", null },
287 return Factory::get().create(
id);
292 return Factory::get().supportsId(
id);
Interface for refcounted XML nodes.
virtual char const * name() const =0
Get the name of the element node.
virtual char const * attribute(char const *key) const =0
Get the string representation of a node's attribute.
virtual NodeType type() const =0
Get the type of the node.
SPObject is an abstract base class of all of the document nodes at the SVG document level.
SPObject of the color-profile object found a direct child of defs.
SVG color matrix filter effect.
SVG <filter> implementation, see sp-filter.cpp.
SVG component transferfilter effect.
SVG composite filter effect.
SVG matrix convolution filter effect.
std::unordered_map< std::string, std::unique_ptr< SPDocument > > map
SVG diffuse lighting filter effect.
SVG displacement map filter effect.
SVG <filter> implementation, see sp-filter.cpp.
SVG Gaussian blur filter effect.
Inkscape::XML::Node * node
feMergeNode implementation.
T * get(GValue *value)
Returns a borrowed pointer to the T held by a value if it holds one, else nullptr.
@ ELEMENT_NODE
Regular element node, e.g. <group />.
@ TEXT_NODE
Text node, e.g. "Some text" in <group>Some text</group> is represented by a text node.
SVG morphology filter effect.
SVG offset filter effect.
SVG <filter> implementation, see sp-filter.cpp.
@ SP_GENERIC_ELLIPSE_CIRCLE
@ SP_GENERIC_ELLIPSE_ELLIPSE
TODO: insert short description here.
TODO: insert short description here.
TODO: insert short description here.
SVG <hatchPath> implementation.
SVG <hatch> implementation.
SVG <image> implementation.
TODO: insert short description here.
TODO: insert short description here.
SPMeshpatch: SVG <meshpatch> implementation.
SPMeshrow: SVG <meshrow> implementation.
SVG <pattern> implementation.
TODO: insert short description here.
TODO: insert short description here.
SPRoot: SVG <svg> implementation.
SPSolidColor: SVG <solidColor> implementation.
TODO: insert short description here.
TODO: insert short description here.
TODO: insert short description here.
SVG <inkscape:tag> implementation.
TODO: insert short description here.
SVG <tref> implementation, see sp-tref.cpp.
TODO: insert short description here.
SVG specular lighting filter effect.
SVG <filter> implementation, see sp-filter.cpp.
static std::string get_type_string(Inkscape::XML::Node const &node)
static SPObject * createObject(std::string const &id)
static bool supportsType(std::string const &id)
SVG turbulence filter effect.