This file is indexed.

/usr/include/collada-dom2.4/dae/daeElement.h is in libcollada-dom2.4-dp-dev 2.4.4+ds1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
/*
 * Copyright 2006 Sony Computer Entertainment Inc.
 *
 * Licensed under the MIT Open Source License, for details please see license.txt or the website
 * http://www.opensource.org/licenses/mit-license.php
 *
 */

#ifndef __DAE_ELEMENT_H__
#define __DAE_ELEMENT_H__
#include <string>
#include <dae/daeTypes.h>
#include <dae/daeMemorySystem.h>
#include <wchar.h>
#include <dae/daeArray.h>
#include <dae/daeRefCountedObj.h>
#include <dae/daeSmartRef.h>

//#ifndef NO_MALLOC_HEADER
//#include <malloc.h>
//#endif

//namespace COLLADA_TYPE
//{
//	typedef int TypeEnum;
//}

class DAE;
class daeMetaElement;
class daeMetaAttribute;
class daeDocument;
class daeURI;

/**
 * The @c daeElement class represents an instance of a COLLADA "Element";
 * it is the main base class for the COLLADA Dom.
 * Features of this class include:
 * - Uses factory concepts defined via daeMetaElement
 * - Composed of attributes, content elements and content values
 * - Reference counted via daeSmartRef
 * - Contains information for XML base URI, and XML containing element
 */
class DLLSPEC daeElement : public daeRefCountedObj
{
public:
    /**
     * Macro that defines new and delete overrides for this class
     */
    DAE_ALLOC
protected:
    daeElement* _parent;
    daeDocument* _document;
    daeMetaElement* _meta;
    daeString _elementName;
    daeBoolArray _validAttributeArray; // This is now obsolete and can be removed
    void* _userData;

protected:
    daeElement( const daeElement &cpy ) : daeRefCountedObj() {
        (void)cpy;
    };
    virtual daeElement &operator=( const daeElement &cpy ) {
        (void)cpy; return *this;
    }

    void init();

    // These functions are called internally.
    void setDocument( daeDocument* c, bool notifyDocument );
    daeElement* simpleAdd(daeString name, int index = -1);

public:
    /**
     * Element Constructor.
     * @note This should not be used externally.
     * Use factories to create elements
     */
    daeElement();
    /**
     * Element Constructor.
     * @note This should not be used externally.
     * Use factories to create elements
     */
    daeElement(DAE& dae);

    /**
     * Element Destructor.
     * @note This should not be used externally,
     * if daeSmartRefs are being used.
     */
    virtual ~daeElement();

    /**
     * Sets up a @c daeElement. Called on all @c daeElements as part of their initialization.
     * @param meta Meta element to use to configure this element.
     * @note Should not be called externally.
     */
    void setup(daeMetaElement* meta);

    // These functions are for adding child elements. They return null if adding
    // the element failed.
    daeElement* add(daeString name, int index = -1);
    daeElement* add(daeElement* elt, int index = -1);
    daeElement* addBefore(daeElement* elt, daeElement* index);
    daeElement* addAfter(daeElement* elt, daeElement* index);

    // These functions are deprecated. Use 'add' instead.
    daeElement* createAndPlace(daeString elementName);
    daeElement* createAndPlaceAt(daeInt index, daeString elementName);
    daeBool placeElement(daeElement* element);
    daeBool placeElementAt(daeInt index, daeElement* element);
    daeBool placeElementBefore( daeElement* marker, daeElement *element );
    daeBool placeElementAfter( daeElement* marker, daeElement *element );

    /**
     * Finds the last index into the array of children of the name specified.
     * @param elementName The name to look for.
     * @return Returns the index into the children array of the last element with name elementName. -1 if
     *         there are no children of name elementName.
     */
    daeInt findLastIndexOf( daeString elementName );

    /**
     * Removes the specified element from it parent, the @c this element.
     * This function is the opposite of @c placeElement().  It removes the specified
     * element from the <tt><i> _contents </i></tt> array, and from wherever else it appears
     * inside of the @c this element.  Use this function instead of @c clear(), @c remove() or @c delete()
     * if you want to keep the <tt><i> _contents </i></tt> field up-to-date.
     *
     * @param element Element to be removed in the @c this container.
     * @return Returns true if the element was successfully removed, false otherwise.
     */
    daeBool removeChildElement(daeElement* element);

    /**
     * Removes the specified element from its parent element.
     * This function is the opposite of @c placeElement().  It removes the specified
     * element from both the <tt><i> _contents </i></tt> array and from wherever else it appears
     * inside of its parent. The function itself finds the parent, and is defined as a static method,
     * since removing the element from its parent may result in the deletion of the element.
     * If the element has no parent, nothing is done.
     *
     * Use this function instead of @c clear(), @c remove() or @c delete()
     * if you want to keep <tt><i> _contents </i></tt> up-to-date.
     *
     * @param element Element to remove from its parent container, the function finds the parent element.
     * @return Returns true if the element was successfully removed, false otherwise.
     */
    static daeBool removeFromParent(daeElement* element)
    {
        if(element != NULL && element->_parent != NULL)
            return(element->_parent->removeChildElement(element));
        return false;
    };

    /**
     * Returns the number of attributes in this element.
     * @return The number of attributes this element has.
     */
    size_t getAttributeCount();

    /**
     * Returns the daeMetaAttribute object corresponding to the attribute specified.
     * @param name The name of the attribute to find.
     * @return Returns the corresponding daeMetaAttribute object or NULL if this element
     * doesn't have the specified attribute.
     */
    daeMetaAttribute* getAttributeObject(daeString name);

    /**
     * Returns the daeMetaAttribute object corresponding to attribute i.
     * @param i The index of the attribute to find.
     * @return Returns the corresponding daeMetaAttribute object
     */
    daeMetaAttribute* getAttributeObject(size_t i);

    /**
     * Returns the name of the attribute at the specified index.
     * @param i The index of the attribute whose name should be retrieved.
     * @return Returns the name of the attribute, or "" if the index is out of range.
     */
    std::string getAttributeName(size_t i);

    /**
     * Checks if this element can have the attribute specified.
     * @param name The name of the attribute to look for.
     * @return Returns true is this element can have an attribute with the name specified. False otherwise.
     */
    daeBool hasAttribute(daeString name);

    /**
     * Checks if an attribute has been set either by being loaded from the COLLADA document or set
     * programmatically.
     * @param name The name of the attribute to check.
     * @return Returns true if the attribute has been set. False if the attribute hasn't been set
     * or doesn't exist for this element.
     */
    daeBool isAttributeSet(daeString name);

    /**
     * Gets an attribute's value as a string.
     * @param name The name of the attribute.
     * @return The value of the attribute. Returns an empty string if this element doesn't
     * have the specified attribute.
     */
    std::string getAttribute(daeString name);

    /**
     * Just like the previous method, this method gets an attribute's value as a string. It
     * takes the string as a reference parameter instead of returning it, for extra efficiency.
     * @param name The name of the attribute.
     * @param A string in which to store the value of the attribute. This will be set to an empty
     * string if this element doesn't have the specified attribute.
     */
    void getAttribute(daeString name, std::string& value);

    /**
     * Gets an attribute's value as a string.
     * @param i The index of the attribute to retrieve.
     * @return The value of the attribute.
     */
    std::string getAttribute(size_t i);

    /**
     * Just like the previous method, this method gets an attribute's value as a string. It
     * takes the string as a reference parameter instead of returning it, for extra efficiency.
     * @param i The index of the attribute to retrieve.
     * @param A string in which to store the value of the attribute.
     */
    void getAttribute(size_t i, std::string& value);

    struct DLLSPEC attr {
        attr();
        attr(const std::string& name, const std::string& value);

        std::string name;
        std::string value;
    };

    /**
     * Returns an array containing all the attributes of this element.
     * @return A daeArray of attr objects.
     */
    daeTArray<attr> getAttributes();

    /**
     * Just like the previous method, this method returns an array containing all the attributes
     * of this element. It returns the result via a reference parameter for extra efficiency.
     * @param attrs The array of attr objects to return.
     */
    void getAttributes(daeTArray<attr>& attrs);

    /**
     * Sets the attribute to the specified value.
     * @param name Attribute to set.
     * @param value Value to apply to the attribute.
     * @return Returns true if the attribute was found and the value was set, false otherwise.
     */
    virtual daeBool setAttribute(daeString name, daeString value);

    /**
     * Sets the attribute at the specified index to the given value.
     * @param i Index of the attribute to set.
     * @param value Value to apply to the attribute.
     * @return Returns true if the attribute was found and the value was set, false otherwise.
     */
    virtual daeBool setAttribute(size_t i, daeString value);

    /**
     * Returns the daeMetaAttribute object corresponding to the character data for this element.
     * @return Returns a daeMetaAttribute object or NULL if this element doesn't have
     * character data.
     */
    daeMetaAttribute* getCharDataObject();

    /**
     * Checks if this element can have character data.
     * @return Returns true if this element can have character data, false otherwise.
     */
    daeBool hasCharData();

    /**
     * Returns this element's character data as a string.
     * @return A string containing this element's character data, or an empty string
     * if this element can't have character data.
     */
    std::string getCharData();

    /**
     * Similar to the previous method, but fills a string passed in by the user for efficiency.
     * @param data The string to be filled with this element's character content. The
     * string is set to an empty string if this element can't have character data.
     */
    void getCharData(std::string& data);

    /**
     * Sets this element's character data.
     * @param data The new character data of this element.
     * @return Returns true if this element can have character data and the character data
     * was successfully changed, false otherwise.
     */
    daeBool setCharData(const std::string& data);

    // These functions are deprecated.
    daeMemoryRef getAttributeValue(daeString name); // Use getAttribute or getAttributeObject instead.
    daeBool hasValue(); // Use hasCharData instead.
    daeMemoryRef getValuePointer(); // Use getCharData or getCharDataObject instead.

    /**
     * Finds the database document associated with @c this element.
     * @return Returns the @c daeDocument representing the containing file or database
     * group.
     */
    daeDocument* getDocument() const {
        return _document;
    }

    /**
     * Deprecated.
     */
    daeDocument* getCollection() const {
        return _document;
    }

    /**
     * Get the associated DAE object.
     * @return The associated DAE object.
     */
    DAE* getDAE();

    /**
     * Sets the database document associated with this element.
     * @param c The daeDocument to associate with this element.
     */
    void setDocument(daeDocument* c) {
        setDocument( c, true );
    }
    /**
     * Deprecated.
     */
    void setCollection(daeDocument* c );

    /**
     * Gets the URI of the document containing this element, note that this is NOT the URI of the element.
     * @return Returns a pointer to the daeURI of the document containing this element.
     */
    daeURI* getDocumentURI() const;

    /**
     * Creates an element via the element factory system.  This creation
     * is based @em only on potential child elements of this element.
     * @param elementName Class name of the subelement to create.
     * @return Returns the created @c daeElement, if it was successfully created.
     */
    daeSmartRef<daeElement> createElement(daeString elementName);

    /**
     * Gets the container element for @c this element.
     * If @c createAndPlace() was used to create the element, its parent is the the caller of @c createAndPlace().
     * @return Returns the parent element, if @c this is not the top level element.
     */
    daeElement* getParentElement() {
        return _parent;
    }
    /**
     * Deprecated. Use getParentElement()
     * @deprecated
     */
    daeElement* getXMLParentElement() {
        return _parent;
    }
    /**
     * Sets the parent element for this element.
     * @param newParent The element which is the new parent element for this element.
     * @note This function is called internally and not meant to be called form the client application.
     */
    void setParentElement( daeElement *parent ) {
        _parent = parent;
    }

    // These are helper structures to let the xml hierarchy search functions know when we've
    // found a match. You can implement a custom matcher by inheriting from this structure,
    // just like matchName and matchType.
    struct DLLSPEC matchElement {
        virtual bool operator()(daeElement* elt) const = 0;
        virtual ~matchElement() {
        };
    };

    // Matches an element by name
    struct DLLSPEC matchName : public matchElement {
        matchName(daeString name);
        virtual bool operator()(daeElement* elt) const;
        std::string name;
    };

    // Matches an element by schema type
    struct DLLSPEC matchType : public matchElement {
        matchType(daeInt typeID);
        virtual bool operator()(daeElement* elt) const;
        daeInt typeID;
    };

    // Returns a matching child element. By "child", I mean one hierarchy level beneath the
    // current element. This function is basically the same as getDescendant, except that it
    // only goes one level deep.
    daeElement* getChild(const matchElement& matcher);

    // Performs a breadth-first search and returns a matching descendant element. A "descendant
    // element" is an element beneath the current element in the xml hierarchy.
    daeElement* getDescendant(const matchElement& matcher);

    // Returns the parent element.
    daeElement* getParent();

    // Searches up through the xml hiearchy and returns a matching element.
    daeElement* getAncestor(const matchElement& matcher);

    // These functions perform the same as the functions above, except that they take the element
    // name to match as a string. This makes these functions a little simpler to use if you're
    // matching based on element name, which is assumed to be the most common case. Instead of
    // "getChild(matchName(eltName))", you can just write "getChild(eltName)".
    daeElement* getChild(daeString eltName);
    daeElement* getDescendant(daeString eltName);
    daeElement* getAncestor(daeString eltName);

    /**
     * Gets the associated Meta information for this element.  This
     * Meta also acts as a factory.  See @c daeMetaElement documentation for more
     * information.
     * @return Returns the associated meta information.
     */
    inline daeMetaElement* getMeta() {
        return _meta;
    }

    // These functions are deprecated. Use typeID instead.
    //virtual COLLADA_TYPE::TypeEnum getElementType() const { return (COLLADA_TYPE::TypeEnum)0; }
    daeString getTypeName() const;

    /**
     * Returns this element's type ID. Every element is an instance of a type specified in
     * the Collada schema, and every schema type has a unique ID.
     * @return The element's type ID.
     */
    virtual daeInt typeID() const = 0;

    /**
     * Gets this element's name.
     * @return Returns the string for the name.
     * @remarks This function returns NULL if the element's name is identical to it's type's name.
     */
    daeString getElementName() const;
    /**
     * Sets this element's name.
     * @param nm Specifies the string to use as the element's name.
     * @remarks Use caution when using this function since you can easily create invalid COLLADA documents.
     */
    void setElementName( daeString nm );

    /**
     * Gets the element ID if it exists.
     * @return Returns the value of the ID attribute, if there is such
     * an attribute on this element type.
     * @return the string for the element ID if it exists.
     */
    daeString getID() const;

    /**
     * Gets the children/sub-elements of this element.
     * This is a helper function used to easily access an element's children without the use of the
     * _meta objects.  This function adds the convenience of the _contents array to elements that do
     * not contain a _contents array.
     * @return The return value.  An elementref array to append this element's children to.
     */
    daeTArray< daeSmartRef<daeElement> > getChildren();

    /**
     * Same as the previous function, but returns the result via a parameter instead
     * of a return value, for extra efficiency.
     * @param array The return value.  An elementref array to append this element's children to.
     */
    //void getChildren( daeElementRefArray &array );
    void getChildren( daeTArray<daeSmartRef<daeElement> > &array );

    /**
     * Gets all the children of a particular type.
     * @return An array containing the matching child elements.
     */
    template<typename T>
    daeTArray< daeSmartRef<T> > getChildrenByType() {
        daeTArray< daeSmartRef<T> > result;
        getChildrenByType(result);
        return result;
    }

    /**
     * Same as the previous function, but returns the result via a parameter instead
     * of a return value, for extra efficiency.
     * @return An array containing the matching child elements.
     */
    template<typename T>
    void getChildrenByType(daeTArray< daeSmartRef<T> >& matchingChildren) {
        matchingChildren.setCount(0);
        daeTArray< daeSmartRef<daeElement> > children;
        getChildren(children);
        for (size_t i = 0; i < children.getCount(); i++)
            if (children[i]->typeID() == T::ID())
                matchingChildren.append((T*)children[i].cast());
    }

    /**
     * Clones/deep copies this @c daeElement and all of it's subtree.
     * @param idSuffix A string to append to the copied element's ID, if one exists.
     *        Default is no ID mangling.
     * @param nameSuffix A string to append to the copied element's name, if one exists.
     *        Default is no name mangling.
     * @return Returns a @c daeElement smartref of the copy of this element.
     */
    daeSmartRef<daeElement> clone( daeString idSuffix = NULL, daeString nameSuffix = NULL );

    // Class for reporting info about element comparisons
    struct DLLSPEC compareResult {
        int compareValue; // > 0 if elt1 > elt2,
                          // < 0 if elt1 < elt2,
                          // = 0 if elt1 = elt2
        daeElement* elt1;
        daeElement* elt2;
        bool nameMismatch; // true if the names didn't match
        std::string attrMismatch; // The name of the mismatched attribute, or "" if there was no attr mismatch
        bool charDataMismatch; // true if the char data didn't match
        bool childCountMismatch; // true if the number of children didn't match

        compareResult();
        std::string format(); // Write to a string
    };

    // Function for doing a generic, recursive comparison of two xml elements. It
    // also provides a full element ordering, so that you could store elements in
    // a map or a set. Return val is > 0 if elt1 > elt2, < 0 if elt1 < elt2, and 0
    // if elt1 == elt2.
    static int compare(daeElement& elt1, daeElement& elt2);

    // Same as the previous function, but returns a full compareResult object.
    static compareResult compareWithFullResult(daeElement& elt1, daeElement& elt2);

    /**
     * Sets the user data pointer attached to this element.
     * @param data User's custom data to store.
     */
    void setUserData(void* data);

    /**
     * Gets the user data pointer attached to this element.
     * @return User data pointer previously set with setUserData.
     */
    void* getUserData();

public:
    // This function is called internally
    static void deleteCMDataArray(daeTArray<daeCharArray*>& cmData);
};

#include <dae/daeSmartRef.h>
typedef daeSmartRef<daeElement> daeElementRef;
typedef daeSmartRef<const daeElement> daeElementConstRef;
//#include <dae/daeArray.h>
typedef daeTArray<daeElementRef> daeElementRefArray;

#endif //__DAE_ELEMENT_H__