Blender V4.5
ExtraHandler.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstddef>
10#include <vector>
11
12#include "BLI_string.h"
13
14#include "ExtraHandler.h"
15
17 : currentExtraTags(nullptr)
18{
19 this->dimp = dimp;
20 this->aimp = aimp;
21}
22
23bool ExtraHandler::elementBegin(const char *elementName, const char **attributes)
24{
25 /* \todo attribute handling for profile tags */
26 currentElement = std::string(elementName);
27 // addToSidTree(attributes[0], attributes[1]);
28 return true;
29}
30
31bool ExtraHandler::elementEnd(const char *elementName)
32{
33 return true;
34}
35
36bool ExtraHandler::textData(const char *text, size_t textLength)
37{
38 char buf[1024];
39
40 if (currentElement.length() == 0 || currentExtraTags == nullptr) {
41 return false;
42 }
43
44 BLI_strncpy(buf, text, textLength + 1);
45 currentExtraTags->addTag(currentElement, std::string(buf));
46 return true;
47}
48
49bool ExtraHandler::parseElement(const char *profileName,
50 const ulong &elementHash,
51 const COLLADAFW::UniqueId &uniqueId)
52{
53 /* implement for backwards compatibility, new version added object parameter */
54 return parseElement(profileName, elementHash, uniqueId, nullptr);
55}
56
57bool ExtraHandler::parseElement(const char *profileName,
58 const ulong &elementHash,
59 const COLLADAFW::UniqueId &uniqueId,
60 COLLADAFW::Object *object)
61{
62 if (BLI_strcaseeq(profileName, "blender")) {
63#if 0
64 printf("In parseElement for supported profile %s for id %s\n",
65 profileName,
66 uniqueId.toAscii().c_str());
67#endif
68 currentUid = uniqueId;
69 ExtraTags *et = dimp->getExtraTags(uniqueId);
70 if (!et) {
71 et = new ExtraTags(std::string(profileName));
72 dimp->addExtraTags(uniqueId, et);
73 }
74 currentExtraTags = et;
75 return true;
76 }
77 // printf("In parseElement for unsupported profile %s for id %s\n", profileName,
78 // uniqueId.toAscii().c_str());
79 return false;
80}
int BLI_strcaseeq(const char *a, const char *b) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
unsigned long ulong
static int uniqueId
bool elementEnd(const char *elementName) override
bool elementBegin(const char *elementName, const char **attributes) override
ExtraHandler(DocumentImporter *dimp, AnimationImporter *aimp)
bool parseElement(const char *profileName, const unsigned long &elementHash, const COLLADAFW::UniqueId &uniqueId, COLLADAFW::Object *object) override
bool textData(const char *text, size_t textLength) override
Class for saving <extra> tags for a specific UniqueId.
Definition ExtraTags.h:17
#define printf(...)