1 /* 2 ============================================================================== 3 4 This file is part of the JUCE library. 5 Copyright (c) 2020 - Raw Material Software Limited 6 7 JUCE is an open source library subject to commercial or open-source 8 licensing. 9 10 By using JUCE, you agree to the terms of both the JUCE 6 End-User License 11 Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020). 12 13 End User License Agreement: www.juce.com/juce-6-licence 14 Privacy Policy: www.juce.com/juce-privacy-policy 15 16 Or: You may also use this code under the terms of the GPL v3 (see 17 www.gnu.org/licenses). 18 19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER 20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE 21 DISCLAIMED. 22 23 ============================================================================== 24 */ 25 26 #pragma once 27 28 29 //============================================================================== 30 class ModuleDescription 31 { 32 public: 33 ModuleDescription() = default; 34 ModuleDescription(const File & folder)35 ModuleDescription (const File& folder) 36 : moduleFolder (folder), 37 moduleInfo (parseJUCEHeaderMetadata (getHeader())) 38 { 39 } 40 isValid()41 bool isValid() const { return getID().isNotEmpty(); } 42 getID()43 String getID() const { return moduleInfo [Ids::ID_uppercase].toString(); } getVendor()44 String getVendor() const { return moduleInfo [Ids::vendor].toString(); } getVersion()45 String getVersion() const { return moduleInfo [Ids::version].toString(); } getName()46 String getName() const { return moduleInfo [Ids::name].toString(); } getDescription()47 String getDescription() const { return moduleInfo [Ids::description].toString(); } getLicense()48 String getLicense() const { return moduleInfo [Ids::license].toString(); } getMinimumCppStandard()49 String getMinimumCppStandard() const { return moduleInfo [Ids::minimumCppStandard].toString(); } getPreprocessorDefs()50 String getPreprocessorDefs() const { return moduleInfo [Ids::defines].toString(); } getExtraSearchPaths()51 String getExtraSearchPaths() const { return moduleInfo [Ids::searchpaths].toString(); } getModuleInfo()52 var getModuleInfo() const { return moduleInfo; } getModuleFolder()53 File getModuleFolder() const { return moduleFolder; } 54 getFolder()55 File getFolder() const 56 { 57 jassert (moduleFolder != File()); 58 59 return moduleFolder; 60 } 61 getHeader()62 File getHeader() const 63 { 64 if (moduleFolder != File()) 65 { 66 static const char* extensions[] = { ".h", ".hpp", ".hxx" }; 67 68 for (auto e : extensions) 69 { 70 auto header = moduleFolder.getChildFile (moduleFolder.getFileName() + e); 71 72 if (header.existsAsFile()) 73 return header; 74 } 75 } 76 77 return {}; 78 } 79 getDependencies()80 StringArray getDependencies() const 81 { 82 auto moduleDependencies = StringArray::fromTokens (moduleInfo ["dependencies"].toString(), " \t;,", "\"'"); 83 moduleDependencies.trim(); 84 moduleDependencies.removeEmptyStrings(); 85 86 return moduleDependencies; 87 } 88 89 private: 90 File moduleFolder; 91 var moduleInfo; 92 URL url; 93 }; 94