File indexing completed on 2024-06-23 05:49:06

0001 /*
0002     This file is part of the Okteta Kasten Framework, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2009, 2010, 2012 Alex Richardson <alex.richardson@gmx.de>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #ifndef KASTEN_STRUCTUREDEFINITIONFILE_HPP
0010 #define KASTEN_STRUCTUREDEFINITIONFILE_HPP
0011 
0012 // tool
0013 #include "datatypes/primitive/enumdefinition.hpp"
0014 #include "structuremetadata.hpp"
0015 // Qt
0016 #include <QString>
0017 #include <QVector>
0018 #include <QDir>
0019 #include <QStringList>
0020 #include <QDomNodeList>
0021 #include <QFileInfo>
0022 // Std
0023 #include <memory>
0024 
0025 class TopLevelDataInformation;
0026 class AbstractStructureParser;
0027 
0028 namespace Kasten {
0029 
0030 /**
0031  *  This class takes care of all the XML parsing and stores the result.
0032  */
0033 class StructureDefinitionFile
0034 {
0035 public:
0036     /**
0037      * This class uses lazy parsing
0038      * @param info the information about this structure definition
0039      *      (passed by value so nothing bad can happen)
0040      */
0041     explicit StructureDefinitionFile(const StructureMetaData& metaData);
0042     StructureDefinitionFile(const StructureDefinitionFile&) = delete;
0043 
0044     virtual ~StructureDefinitionFile();
0045 
0046     StructureDefinitionFile& operator=(const StructureDefinitionFile&) = delete;
0047 
0048 public:
0049     QVector<TopLevelDataInformation*> structures() const;
0050     QStringList structureNames() const;
0051     TopLevelDataInformation* structure(const QString& name) const;
0052     /** @return the absolute path to the directory containing the .desktop file */
0053     QString absolutePath() const;
0054     StructureMetaData metaData() const;
0055     bool isValid() const;
0056 
0057 private:
0058     StructureMetaData mMetaData;
0059     std::unique_ptr<AbstractStructureParser> mParser;
0060 };
0061 
0062 } // namespace Kasten
0063 
0064 #endif /* KASTEN_STRUCTUREDEFINITIONFILE_HPP */