You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
3.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the dRowAudio JUCE module
  4. Copyright 2004-13 by dRowAudio.
  5. ------------------------------------------------------------------------------
  6. dRowAudio is provided under the terms of The MIT License (MIT):
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in all
  14. copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. SOFTWARE.
  22. ==============================================================================
  23. */
  24. #ifndef __DROWAUDIO_ITUNESLIBRARYPARSER_H__
  25. #define __DROWAUDIO_ITUNESLIBRARYPARSER_H__
  26. #include "dRowAudio_Utility.h"
  27. //==============================================================================
  28. /** Parses an iTunes Xml library into a ValueTree using a background thread.
  29. If the tree passed in already contains a generated library this will merge
  30. any new data from the file into it preserving any sub-trees or attributes
  31. that may have been added.
  32. You shouldn't need to use this directly, use the higher-level iTunesLibrary
  33. instead.
  34. */
  35. class ITunesLibraryParser : public Thread
  36. {
  37. public:
  38. //==============================================================================
  39. /** Creates a parser with a given valid library file and a ValueTree with which
  40. to put the parsed data.
  41. */
  42. ITunesLibraryParser (const File& iTunesLibraryFileToUse, const ValueTree& elementToFill,
  43. const CriticalSection& lockToUse);
  44. /** Destructor.
  45. */
  46. ~ITunesLibraryParser();
  47. /** Returns true if the parser has finished.
  48. */
  49. bool hasFinished() { return finished; }
  50. /** @internal */
  51. void run();
  52. /** Returns the lock being used.
  53. */
  54. const CriticalSection& getLock () { return lock; }
  55. private:
  56. //==============================================================================
  57. const CriticalSection& lock;
  58. const File iTunesLibraryFile;
  59. ValueTree treeToFill, partialTree;
  60. ScopedPointer<XmlElement> iTunesDatabase;
  61. XmlElement *iTunesLibraryTracks, *currentElement;
  62. int numAdded;
  63. bool finished;
  64. //==============================================================================
  65. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ITunesLibraryParser);
  66. };
  67. #endif // __DROWAUDIO_ITUNESLIBRARYPARSER_H__