src/RequestedField.h
author František Kučera <franta-hg@frantovo.cz>
Sun, 25 Apr 2021 18:47:57 +0200
branchv_0
changeset 89 25a11859975b
parent 44 dc5c210295d0
permissions -rw-r--r--
streamlet examples: QR: rename qr to qr-decode + simplify Makefile

/**
 * Relational pipes
 * Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
 *
 * This program 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, version 3 of the License.
 *
 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
 */
#pragma once

#include <vector>

#include <relpipe/writer/typedefs.h>

namespace relpipe {
namespace in {
namespace filesystem {

using namespace relpipe::writer;

class RequestedField {
public:
	static const string_t GROUP_FILE;
	static const string_t GROUP_XATTR;
	static const string_t GROUP_STREAMLET;
	integer_t id;
	string_t group;
	string_t name;
	std::vector<string_t> aliases;
	/**
	 * used as an ordered multi-map
	 * option name, value, name, value,…
	 */
	std::vector<string_t> options;

	RequestedField(const string_t& group, const string_t& name, const std::vector<string_t>& aliases = {}, const std::vector<string_t>& options = {}) : group(group), name(name), aliases(aliases), options(options) {
	}

	/**
	 * @return aliases (might be empty)
	 */
	std::vector<string_t> getAliases() const {
		return aliases;
	}

	/**
	 * @return aliases or vector with single item (name), if aliases are empty
	 */
	std::vector<string_t> getAliasesOrName() const {
		if (aliases.empty()) return {name};
		else return aliases;
	}

	virtual ~RequestedField() {
	}
};

const string_t RequestedField::GROUP_FILE = L"file";
const string_t RequestedField::GROUP_XATTR = L"xattr";
const string_t RequestedField::GROUP_STREAMLET = L"streamlet";

}
}
}