Add initial bits for Qt6 support
[carla.git] / source / modules / water / xml / XmlElement.h
blob7b02f32681041097d9adb887d4b3220c6391cd75
1 /*
2 ==============================================================================
4 This file is part of the Water library.
5 Copyright (c) 2016 ROLI Ltd.
6 Copyright (C) 2017-2022 Filipe Coelho <falktx@falktx.com>
8 Permission is granted to use this software under the terms of the ISC license
9 http://www.isc.org/downloads/software-support-policy/isc-license/
11 Permission to use, copy, modify, and/or distribute this software for any
12 purpose with or without fee is hereby granted, provided that the above
13 copyright notice and this permission notice appear in all copies.
15 THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
16 TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
18 OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
19 USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
21 OF THIS SOFTWARE.
23 ==============================================================================
26 #ifndef WATER_XMLELEMENT_H_INCLUDED
27 #define WATER_XMLELEMENT_H_INCLUDED
29 #include "../containers/LinkedListPointer.h"
30 #include "../memory/HeapBlock.h"
31 #include "../text/Identifier.h"
33 namespace water {
35 //==============================================================================
36 /** A handy macro to make it easy to iterate all the child elements in an XmlElement.
38 The parentXmlElement should be a reference to the parent XML, and the childElementVariableName
39 will be the name of a pointer to each child element.
41 E.g. @code
42 XmlElement* myParentXml = createSomeKindOfXmlDocument();
44 forEachXmlChildElement (*myParentXml, child)
46 if (child->hasTagName ("FOO"))
47 doSomethingWithXmlElement (child);
50 @endcode
52 @see forEachXmlChildElementWithTagName
54 #define __forEachXmlChildElement(parentXmlElement, childElementVariableName) \
56 for (water::XmlElement* childElementVariableName = (parentXmlElement).getFirstChildElement(); \
57 childElementVariableName != nullptr; \
58 childElementVariableName = childElementVariableName->getNextElement())
60 /** A macro that makes it easy to iterate all the child elements of an XmlElement
61 which have a specified tag.
63 This does the same job as the forEachXmlChildElement macro, but only for those
64 elements that have a particular tag name.
66 The parentXmlElement should be a reference to the parent XML, and the childElementVariableName
67 will be the name of a pointer to each child element. The requiredTagName is the
68 tag name to match.
70 E.g. @code
71 XmlElement* myParentXml = createSomeKindOfXmlDocument();
73 forEachXmlChildElementWithTagName (*myParentXml, child, "MYTAG")
75 // the child object is now guaranteed to be a <MYTAG> element..
76 doSomethingWithMYTAGElement (child);
79 @endcode
81 @see forEachXmlChildElement
83 #define __forEachXmlChildElementWithTagName(parentXmlElement, childElementVariableName, requiredTagName) \
85 for (water::XmlElement* childElementVariableName = (parentXmlElement).getChildByName (requiredTagName); \
86 childElementVariableName != nullptr; \
87 childElementVariableName = childElementVariableName->getNextElementWithTagName (requiredTagName))
90 //==============================================================================
91 /** Used to build a tree of elements representing an XML document.
93 An XML document can be parsed into a tree of XmlElements, each of which
94 represents an XML tag structure, and which may itself contain other
95 nested elements.
97 An XmlElement can also be converted back into a text document, and has
98 lots of useful methods for manipulating its attributes and sub-elements,
99 so XmlElements can actually be used as a handy general-purpose data
100 structure.
102 Here's an example of parsing some elements: @code
103 // check we're looking at the right kind of document..
104 if (myElement->hasTagName ("ANIMALS"))
106 // now we'll iterate its sub-elements looking for 'giraffe' elements..
107 forEachXmlChildElement (*myElement, e)
109 if (e->hasTagName ("GIRAFFE"))
111 // found a giraffe, so use some of its attributes..
113 String giraffeName = e->getStringAttribute ("name");
114 int giraffeAge = e->getIntAttribute ("age");
115 bool isFriendly = e->getBoolAttribute ("friendly");
119 @endcode
121 And here's an example of how to create an XML document from scratch: @code
122 // create an outer node called "ANIMALS"
123 XmlElement animalsList ("ANIMALS");
125 for (int i = 0; i < numAnimals; ++i)
127 // create an inner element..
128 XmlElement* giraffe = new XmlElement ("GIRAFFE");
130 giraffe->setAttribute ("name", "nigel");
131 giraffe->setAttribute ("age", 10);
132 giraffe->setAttribute ("friendly", true);
134 // ..and add our new element to the parent node
135 animalsList.addChildElement (giraffe);
138 // now we can turn the whole thing into a text document..
139 String myXmlDoc = animalsList.createDocument (String());
140 @endcode
142 @see XmlDocument
144 class XmlElement
146 public:
147 //==============================================================================
148 /** Creates an XmlElement with this tag name. */
149 explicit XmlElement (const String& tagName);
151 /** Creates an XmlElement with this tag name. */
152 explicit XmlElement (const char* tagName);
154 /** Creates an XmlElement with this tag name. */
155 explicit XmlElement (const Identifier& tagName);
157 /** Creates an XmlElement with this tag name. */
158 explicit XmlElement (StringRef tagName);
160 /** Creates an XmlElement with this tag name. */
161 XmlElement (CharPointer_UTF8 tagNameBegin, CharPointer_UTF8 tagNameEnd);
163 /** Creates a (deep) copy of another element. */
164 XmlElement (const XmlElement&);
166 /** Creates a (deep) copy of another element. */
167 XmlElement& operator= (const XmlElement&);
169 /** Deleting an XmlElement will also delete all of its child elements. */
170 ~XmlElement() noexcept;
172 //==============================================================================
173 /** Compares two XmlElements to see if they contain the same text and attiributes.
175 The elements are only considered equivalent if they contain the same attiributes
176 with the same values, and have the same sub-nodes.
178 @param other the other element to compare to
179 @param ignoreOrderOfAttributes if true, this means that two elements with the
180 same attributes in a different order will be
181 considered the same; if false, the attributes must
182 be in the same order as well
184 bool isEquivalentTo (const XmlElement* other,
185 bool ignoreOrderOfAttributes) const noexcept;
187 //==============================================================================
188 /** Returns an XML text document that represents this element.
190 The string returned can be parsed to recreate the same XmlElement that
191 was used to create it.
193 @param dtdToUse the DTD to add to the document
194 @param allOnOneLine if true, this means that the document will not contain any
195 linefeeds, so it'll be smaller but not very easy to read.
196 @param includeXmlHeader whether to add the "<?xml version..etc" line at the start of the
197 document
198 @param encodingType the character encoding format string to put into the xml
199 header
200 @param lineWrapLength the line length that will be used before items get placed on
201 a new line. This isn't an absolute maximum length, it just
202 determines how lists of attributes get broken up
203 @see writeToStream, writeToFile
205 String createDocument (StringRef dtdToUse,
206 bool allOnOneLine = false,
207 bool includeXmlHeader = true,
208 StringRef encodingType = "UTF-8",
209 int lineWrapLength = 60) const;
211 /** Writes the document to a stream as UTF-8.
213 @param output the stream to write to
214 @param dtdToUse the DTD to add to the document
215 @param allOnOneLine if true, this means that the document will not contain any
216 linefeeds, so it'll be smaller but not very easy to read.
217 @param includeXmlHeader whether to add the "<?xml version..etc" line at the start of the
218 document
219 @param encodingType the character encoding format string to put into the xml
220 header
221 @param lineWrapLength the line length that will be used before items get placed on
222 a new line. This isn't an absolute maximum length, it just
223 determines how lists of attributes get broken up
224 @see writeToFile, createDocument
226 void writeToStream (OutputStream& output,
227 StringRef dtdToUse,
228 bool allOnOneLine = false,
229 bool includeXmlHeader = true,
230 StringRef encodingType = "UTF-8",
231 int lineWrapLength = 60) const;
233 #if 0
234 /** Writes the element to a file as an XML document.
236 To improve safety in case something goes wrong while writing the file, this
237 will actually write the document to a new temporary file in the same
238 directory as the destination file, and if this succeeds, it will rename this
239 new file as the destination file (overwriting any existing file that was there).
241 @param destinationFile the file to write to. If this already exists, it will be
242 overwritten.
243 @param dtdToUse the DTD to add to the document
244 @param encodingType the character encoding format string to put into the xml
245 header
246 @param lineWrapLength the line length that will be used before items get placed on
247 a new line. This isn't an absolute maximum length, it just
248 determines how lists of attributes get broken up
249 @returns true if the file is written successfully; false if something goes wrong
250 in the process
251 @see createDocument
253 bool writeToFile (const File& destinationFile,
254 StringRef dtdToUse,
255 StringRef encodingType = "UTF-8",
256 int lineWrapLength = 60) const;
257 #endif
259 //==============================================================================
260 /** Returns this element's tag type name.
261 E.g. for an element such as \<MOOSE legs="4" antlers="2">, this would return "MOOSE".
262 @see hasTagName
264 const String& getTagName() const noexcept { return tagName; }
266 /** Returns the namespace portion of the tag-name, or an empty string if none is specified. */
267 String getNamespace() const;
269 /** Returns the part of the tag-name that follows any namespace declaration. */
270 String getTagNameWithoutNamespace() const;
272 /** Tests whether this element has a particular tag name.
273 @param possibleTagName the tag name you're comparing it with
274 @see getTagName
276 bool hasTagName (StringRef possibleTagName) const noexcept;
278 /** Tests whether this element has a particular tag name, ignoring any XML namespace prefix.
279 So a test for e.g. "xyz" will return true for "xyz" and also "foo:xyz", "bar::xyz", etc.
280 @see getTagName
282 bool hasTagNameIgnoringNamespace (StringRef possibleTagName) const;
284 //==============================================================================
285 /** Returns the number of XML attributes this element contains.
287 E.g. for an element such as \<MOOSE legs="4" antlers="2">, this would
288 return 2.
290 int getNumAttributes() const noexcept;
292 /** Returns the name of one of the elements attributes.
294 E.g. for an element such as \<MOOSE legs="4" antlers="2">, then
295 getAttributeName(1) would return "antlers".
297 @see getAttributeValue, getStringAttribute
299 const std::string& getAttributeName (int attributeIndex) const noexcept;
301 /** Returns the value of one of the elements attributes.
303 E.g. for an element such as \<MOOSE legs="4" antlers="2">, then
304 getAttributeName(1) would return "2".
306 @see getAttributeName, getStringAttribute
308 const String& getAttributeValue (int attributeIndex) const noexcept;
310 //==============================================================================
311 // Attribute-handling methods..
313 /** Checks whether the element contains an attribute with a certain name. */
314 bool hasAttribute (StringRef attributeName) const noexcept;
316 /** Returns the value of a named attribute.
317 @param attributeName the name of the attribute to look up
319 const String& getStringAttribute (StringRef attributeName) const noexcept;
321 /** Returns the value of a named attribute.
322 @param attributeName the name of the attribute to look up
323 @param defaultReturnValue a value to return if the element doesn't have an attribute
324 with this name
326 String getStringAttribute (StringRef attributeName, const String& defaultReturnValue) const;
328 /** Compares the value of a named attribute with a value passed-in.
330 @param attributeName the name of the attribute to look up
331 @param stringToCompareAgainst the value to compare it with
332 @param ignoreCase whether the comparison should be case-insensitive
333 @returns true if the value of the attribute is the same as the string passed-in;
334 false if it's different (or if no such attribute exists)
336 bool compareAttribute (StringRef attributeName,
337 StringRef stringToCompareAgainst,
338 bool ignoreCase = false) const noexcept;
340 /** Returns the value of a named attribute as an integer.
342 This will try to find the attribute and convert it to an integer (using
343 the String::getIntValue() method).
345 @param attributeName the name of the attribute to look up
346 @param defaultReturnValue a value to return if the element doesn't have an attribute
347 with this name
348 @see setAttribute
350 int getIntAttribute (StringRef attributeName, int defaultReturnValue = 0) const;
352 /** Returns the value of a named attribute as floating-point.
354 This will try to find the attribute and convert it to a double (using
355 the String::getDoubleValue() method).
357 @param attributeName the name of the attribute to look up
358 @param defaultReturnValue a value to return if the element doesn't have an attribute
359 with this name
360 @see setAttribute
362 double getDoubleAttribute (StringRef attributeName, double defaultReturnValue = 0.0) const;
364 /** Returns the value of a named attribute as a boolean.
366 This will try to find the attribute and interpret it as a boolean. To do this,
367 it'll return true if the value is "1", "true", "y", etc, or false for other
368 values.
370 @param attributeName the name of the attribute to look up
371 @param defaultReturnValue a value to return if the element doesn't have an attribute
372 with this name
374 bool getBoolAttribute (StringRef attributeName, bool defaultReturnValue = false) const;
376 /** Adds a named attribute to the element.
378 If the element already contains an attribute with this name, it's value will
379 be updated to the new value. If there's no such attribute yet, a new one will
380 be added.
382 Note that there are other setAttribute() methods that take integers,
383 doubles, etc. to make it easy to store numbers.
385 @param attributeName the name of the attribute to set
386 @param newValue the value to set it to
387 @see removeAttribute
389 void setAttribute (const Identifier& attributeName, const String& newValue);
391 /** Adds a named attribute to the element, setting it to an integer value.
393 If the element already contains an attribute with this name, it's value will
394 be updated to the new value. If there's no such attribute yet, a new one will
395 be added.
397 Note that there are other setAttribute() methods that take integers,
398 doubles, etc. to make it easy to store numbers.
400 @param attributeName the name of the attribute to set
401 @param newValue the value to set it to
403 void setAttribute (const Identifier& attributeName, int newValue);
405 /** Adds a named attribute to the element, setting it to a floating-point value.
407 If the element already contains an attribute with this name, it's value will
408 be updated to the new value. If there's no such attribute yet, a new one will
409 be added.
411 Note that there are other setAttribute() methods that take integers,
412 doubles, etc. to make it easy to store numbers.
414 @param attributeName the name of the attribute to set
415 @param newValue the value to set it to
417 void setAttribute (const Identifier& attributeName, double newValue);
419 /** Removes a named attribute from the element.
421 @param attributeName the name of the attribute to remove
422 @see removeAllAttributes
424 void removeAttribute (const Identifier& attributeName) noexcept;
426 /** Removes all attributes from this element. */
427 void removeAllAttributes() noexcept;
429 //==============================================================================
430 // Child element methods..
432 /** Returns the first of this element's sub-elements.
433 see getNextElement() for an example of how to iterate the sub-elements.
434 @see forEachXmlChildElement
436 XmlElement* getFirstChildElement() const noexcept { return firstChildElement; }
438 /** Returns the next of this element's siblings.
440 This can be used for iterating an element's sub-elements, e.g.
441 @code
442 XmlElement* child = myXmlDocument->getFirstChildElement();
444 while (child != nullptr)
446 ...do stuff with this child..
448 child = child->getNextElement();
450 @endcode
452 Note that when iterating the child elements, some of them might be
453 text elements as well as XML tags - use isTextElement() to work this
454 out.
456 Also, it's much easier and neater to use this method indirectly via the
457 forEachXmlChildElement macro.
459 @returns the sibling element that follows this one, or a nullptr if
460 this is the last element in its parent
462 @see getNextElement, isTextElement, forEachXmlChildElement
464 inline XmlElement* getNextElement() const noexcept { return nextListItem; }
466 /** Returns the next of this element's siblings which has the specified tag
467 name.
469 This is like getNextElement(), but will scan through the list until it
470 finds an element with the given tag name.
472 @see getNextElement, forEachXmlChildElementWithTagName
474 XmlElement* getNextElementWithTagName (StringRef requiredTagName) const;
476 /** Returns the number of sub-elements in this element.
477 @see getChildElement
479 int getNumChildElements() const noexcept;
481 /** Returns the sub-element at a certain index.
483 It's not very efficient to iterate the sub-elements by index - see
484 getNextElement() for an example of how best to iterate.
486 @returns the n'th child of this element, or nullptr if the index is out-of-range
487 @see getNextElement, isTextElement, getChildByName
489 XmlElement* getChildElement (int index) const noexcept;
491 /** Returns the first sub-element with a given tag-name.
493 @param tagNameToLookFor the tag name of the element you want to find
494 @returns the first element with this tag name, or nullptr if none is found
495 @see getNextElement, isTextElement, getChildElement, getChildByAttribute
497 XmlElement* getChildByName (StringRef tagNameToLookFor) const noexcept;
499 /** Returns the first sub-element which has an attribute that matches the given value.
501 @param attributeName the name of the attribute to check
502 @param attributeValue the target value of the attribute
503 @returns the first element with this attribute value, or nullptr if none is found
504 @see getChildByName
506 XmlElement* getChildByAttribute (StringRef attributeName,
507 StringRef attributeValue) const noexcept;
509 //==============================================================================
510 /** Appends an element to this element's list of children.
512 Child elements are deleted automatically when their parent is deleted, so
513 make sure the object that you pass in will not be deleted by anything else,
514 and make sure it's not already the child of another element.
516 Note that due to the XmlElement using a singly-linked-list, prependChildElement()
517 is an O(1) operation, but addChildElement() is an O(N) operation - so if
518 you're adding large number of elements, you may prefer to do so in reverse order!
520 @see getFirstChildElement, getNextElement, getNumChildElements,
521 getChildElement, removeChildElement
523 void addChildElement (XmlElement* newChildElement) noexcept;
525 /** Inserts an element into this element's list of children.
527 Child elements are deleted automatically when their parent is deleted, so
528 make sure the object that you pass in will not be deleted by anything else,
529 and make sure it's not already the child of another element.
531 @param newChildElement the element to add
532 @param indexToInsertAt the index at which to insert the new element - if this is
533 below zero, it will be added to the end of the list
534 @see addChildElement, insertChildElement
536 void insertChildElement (XmlElement* newChildElement,
537 int indexToInsertAt) noexcept;
539 /** Inserts an element at the beginning of this element's list of children.
541 Child elements are deleted automatically when their parent is deleted, so
542 make sure the object that you pass in will not be deleted by anything else,
543 and make sure it's not already the child of another element.
545 Note that due to the XmlElement using a singly-linked-list, prependChildElement()
546 is an O(1) operation, but addChildElement() is an O(N) operation - so if
547 you're adding large number of elements, you may prefer to do so in reverse order!
549 @see addChildElement, insertChildElement
551 void prependChildElement (XmlElement* newChildElement) noexcept;
553 /** Creates a new element with the given name and returns it, after adding it
554 as a child element.
556 This is a handy method that means that instead of writing this:
557 @code
558 XmlElement* newElement = new XmlElement ("foobar");
559 myParentElement->addChildElement (newElement);
560 @endcode
562 ..you could just write this:
563 @code
564 XmlElement* newElement = myParentElement->createNewChildElement ("foobar");
565 @endcode
567 XmlElement* createNewChildElement (StringRef tagName);
569 /** Replaces one of this element's children with another node.
571 If the current element passed-in isn't actually a child of this element,
572 this will return false and the new one won't be added. Otherwise, the
573 existing element will be deleted, replaced with the new one, and it
574 will return true.
576 bool replaceChildElement (XmlElement* currentChildElement,
577 XmlElement* newChildNode) noexcept;
579 /** Removes a child element.
581 @param childToRemove the child to look for and remove
582 @param shouldDeleteTheChild if true, the child will be deleted, if false it'll
583 just remove it
585 void removeChildElement (XmlElement* childToRemove,
586 bool shouldDeleteTheChild) noexcept;
588 /** Deletes all the child elements in the element.
589 @see removeChildElement, deleteAllChildElementsWithTagName
591 void deleteAllChildElements() noexcept;
593 /** Deletes all the child elements with a given tag name.
594 @see removeChildElement
596 void deleteAllChildElementsWithTagName (StringRef tagName) noexcept;
598 /** Returns true if the given element is a child of this one. */
599 bool containsChildElement (const XmlElement* possibleChild) const noexcept;
601 /** Recursively searches all sub-elements of this one, looking for an element
602 which is the direct parent of the specified element.
604 Because elements don't store a pointer to their parent, if you have one
605 and need to find its parent, the only way to do so is to exhaustively
606 search the whole tree for it.
608 If the given child is found somewhere in this element's hierarchy, then
609 this method will return its parent. If not, it will return nullptr.
611 XmlElement* findParentElementOf (const XmlElement* childToSearchFor) noexcept;
613 //==============================================================================
614 /** Returns true if this element is a section of text.
616 Elements can either be an XML tag element or a secton of text, so this
617 is used to find out what kind of element this one is.
619 @see getAllText, addTextElement, deleteAllTextElements
621 bool isTextElement() const noexcept;
623 /** Returns the text for a text element.
625 Note that if you have an element like this:
627 @code<xyz>hello</xyz>@endcode
629 then calling getText on the "xyz" element won't return "hello", because that is
630 actually stored in a special text sub-element inside the xyz element. To get the
631 "hello" string, you could either call getText on the (unnamed) sub-element, or
632 use getAllSubText() to do this automatically.
634 Note that leading and trailing whitespace will be included in the string - to remove
635 if, just call String::trim() on the result.
637 @see isTextElement, getAllSubText, getChildElementAllSubText
639 const String& getText() const noexcept;
641 /** Sets the text in a text element.
643 Note that this is only a valid call if this element is a text element. If it's
644 not, then no action will be performed. If you're trying to add text inside a normal
645 element, you probably want to use addTextElement() instead.
647 void setText (const String& newText);
649 /** Returns all the text from this element's child nodes.
651 This iterates all the child elements and when it finds text elements,
652 it concatenates their text into a big string which it returns.
654 E.g. @code<xyz>hello <x>there</x> world</xyz>@endcode
655 if you called getAllSubText on the "xyz" element, it'd return "hello there world".
657 Note that leading and trailing whitespace will be included in the string - to remove
658 if, just call String::trim() on the result.
660 @see isTextElement, getChildElementAllSubText, getText, addTextElement
662 String getAllSubText() const;
664 /** Returns all the sub-text of a named child element.
666 If there is a child element with the given tag name, this will return
667 all of its sub-text (by calling getAllSubText() on it). If there is
668 no such child element, this will return the default string passed-in.
670 @see getAllSubText
672 String getChildElementAllSubText (StringRef childTagName,
673 const String& defaultReturnValue) const;
675 /** Appends a section of text to this element.
676 @see isTextElement, getText, getAllSubText
678 void addTextElement (const String& text);
680 /** Removes all the text elements from this element.
681 @see isTextElement, getText, getAllSubText, addTextElement
683 void deleteAllTextElements() noexcept;
685 /** Creates a text element that can be added to a parent element. */
686 static XmlElement* createTextElement (const String& text);
688 /** Checks if a given string is a valid XML name */
689 static bool isValidXmlName (StringRef possibleName) noexcept;
691 //==============================================================================
692 private:
693 struct XmlAttributeNode
695 XmlAttributeNode (const XmlAttributeNode&) noexcept;
696 XmlAttributeNode (const Identifier&, const String&) noexcept;
697 XmlAttributeNode (CharPointer_UTF8, CharPointer_UTF8);
699 LinkedListPointer<XmlAttributeNode> nextListItem;
700 Identifier name;
701 String value;
703 private:
704 XmlAttributeNode& operator= (const XmlAttributeNode&) WATER_DELETED_FUNCTION;
707 friend class XmlDocument;
708 friend class LinkedListPointer<XmlAttributeNode>;
709 friend class LinkedListPointer<XmlElement>;
710 friend class LinkedListPointer<XmlElement>::Appender;
711 friend class NamedValueSet;
713 LinkedListPointer<XmlElement> nextListItem;
714 LinkedListPointer<XmlElement> firstChildElement;
715 LinkedListPointer<XmlAttributeNode> attributes;
716 String tagName;
718 XmlElement (int) noexcept;
719 void copyChildrenAndAttributesFrom (const XmlElement&);
720 void writeElementAsText (OutputStream&, int indentationLevel, int lineWrapLength) const;
721 void getChildElementsAsArray (XmlElement**) const noexcept;
722 void reorderChildElements (XmlElement**, int) noexcept;
723 XmlAttributeNode* getAttribute (StringRef) const noexcept;
728 #endif // WATER_XMLELEMENT_H_INCLUDED