mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Remove ConditionalMetadata
While it makes sense, it doesn't really add any value and there is value in having all the relevant data and methods in a single class.
This commit is contained in:
@@ -1,68 +0,0 @@
|
||||
/* LOOT
|
||||
|
||||
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
|
||||
Fallout: New Vegas.
|
||||
|
||||
Copyright (C) 2012-2016 WrinklyNinja
|
||||
|
||||
This file is part of LOOT.
|
||||
|
||||
LOOT is free software: you can redistribute
|
||||
it and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
LOOT is distributed in the hope that it will
|
||||
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LOOT. If not, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef LOOT_METADATA_CONDITIONAL_METADATA
|
||||
#define LOOT_METADATA_CONDITIONAL_METADATA
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "loot/api_decorator.h"
|
||||
|
||||
namespace loot {
|
||||
/**
|
||||
* A base class for metadata that can be conditional based on the result of
|
||||
* evaluating a condition string.
|
||||
*/
|
||||
class ConditionalMetadata {
|
||||
public:
|
||||
/**
|
||||
* Construct a ConditionalMetadata object with an empty condition string.
|
||||
*/
|
||||
LOOT_API ConditionalMetadata() = default;
|
||||
|
||||
/**
|
||||
* Construct a ConditionalMetadata object with a given condition string.
|
||||
* @param condition
|
||||
* A condition string, as defined in the LOOT metadata syntax
|
||||
* documentation.
|
||||
*/
|
||||
LOOT_API explicit ConditionalMetadata(std::string_view condition);
|
||||
|
||||
/**
|
||||
* Check if the condition string is non-empty.
|
||||
* @return True if the condition string is not empty, false otherwise.
|
||||
*/
|
||||
LOOT_API bool IsConditional() const;
|
||||
|
||||
/**
|
||||
* Get the condition string.
|
||||
* @return The object's condition string.
|
||||
*/
|
||||
LOOT_API std::string GetCondition() const;
|
||||
|
||||
private:
|
||||
std::string condition_;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <string_view>
|
||||
|
||||
#include "loot/api_decorator.h"
|
||||
#include "loot/metadata/conditional_metadata.h"
|
||||
#include "loot/metadata/filename.h"
|
||||
#include "loot/metadata/message_content.h"
|
||||
|
||||
@@ -36,7 +35,7 @@ namespace loot {
|
||||
/**
|
||||
* Represents a file in a game's Data folder, including files in subdirectories.
|
||||
*/
|
||||
class File : public ConditionalMetadata {
|
||||
class File {
|
||||
public:
|
||||
/**
|
||||
* Construct a File with blank name, display and condition strings.
|
||||
@@ -87,6 +86,12 @@ public:
|
||||
*/
|
||||
LOOT_API std::vector<MessageContent> GetDetail() const;
|
||||
|
||||
/**
|
||||
* Get the condition string.
|
||||
* @return The file's condition string.
|
||||
*/
|
||||
LOOT_API std::string GetCondition() const;
|
||||
|
||||
/**
|
||||
* Get the constraint that applies to the file.
|
||||
* @return The file's constraint.
|
||||
@@ -97,6 +102,7 @@ private:
|
||||
Filename name_;
|
||||
std::string display_;
|
||||
std::vector<MessageContent> detail_;
|
||||
std::string condition_;
|
||||
std::string constraint_;
|
||||
};
|
||||
|
||||
|
||||
@@ -30,14 +30,13 @@
|
||||
|
||||
#include "loot/api_decorator.h"
|
||||
#include "loot/enum/message_type.h"
|
||||
#include "loot/metadata/conditional_metadata.h"
|
||||
#include "loot/metadata/message_content.h"
|
||||
|
||||
namespace loot {
|
||||
/**
|
||||
* Represents a message with localisable text content.
|
||||
*/
|
||||
class Message : public ConditionalMetadata {
|
||||
class Message {
|
||||
public:
|
||||
/**
|
||||
* Construct a Message object of type 'say' with blank content and condition
|
||||
@@ -85,9 +84,16 @@ public:
|
||||
*/
|
||||
LOOT_API std::vector<MessageContent> GetContent() const;
|
||||
|
||||
/**
|
||||
* Get the condition string.
|
||||
* @return The message's condition string.
|
||||
*/
|
||||
LOOT_API std::string GetCondition() const;
|
||||
|
||||
private:
|
||||
MessageType type_{MessageType::say};
|
||||
std::vector<MessageContent> content_;
|
||||
std::string condition_;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,13 +28,12 @@
|
||||
#include <string_view>
|
||||
|
||||
#include "loot/api_decorator.h"
|
||||
#include "loot/metadata/conditional_metadata.h"
|
||||
|
||||
namespace loot {
|
||||
/**
|
||||
* Represents a Bash Tag suggestion for a plugin.
|
||||
*/
|
||||
class Tag : public ConditionalMetadata {
|
||||
class Tag {
|
||||
public:
|
||||
/**
|
||||
* Construct a Tag object with an empty tag name suggested for addition, with
|
||||
@@ -68,9 +67,16 @@ public:
|
||||
*/
|
||||
LOOT_API std::string GetName() const;
|
||||
|
||||
/**
|
||||
* Get the condition string.
|
||||
* @return The tag's condition string.
|
||||
*/
|
||||
LOOT_API std::string GetCondition() const;
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
bool addTag_{true};
|
||||
std::string condition_;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user