Loading...
Searching...
No Matches
paramFile.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#ifndef BALL_FORMAT_PARAMFILE_H
#define BALL_FORMAT_PARAMFILE_H
#include <BALL/SYSTEM/file.h>
#include <BALL/DATATYPE/string.h>
#include <QtCore/QXmlStreamReader>
#include <QtCore/QXmlStreamWriter>
#include <QtCore/QFile>
#include <map>
#include <list>
#include <set>
namespace BALL
{
class BALL_EXPORT ParamFile : public File
{
public:
enum ParameterType
{
INFILE,
OUTFILE,
STRING,
INT,
DOUBLE,
INFILELIST,
OUTFILELIST,
STRINGLIST,
INTLIST,
DOUBLELIST,
//TODO: do we REALLY need these two openly galaxy specific parameter types?
// couldn't we do it with tags or something more elegant?
GALAXY_OPT_OUTDIR,
GALAXY_OPT_OUTID
};
struct ParameterDescription
{
// constructor
ParameterDescription()
{
name = "";
description = "";
category = "";
mandatory = false;
advanced = false;
type = INFILE;
allowed_values.clear();
supported_formats.clear();
hidden = false;
}
String name;
String description;
String category;
bool mandatory;
bool advanced;
ParameterType type;
list<String> allowed_values;
list<String> supported_formats;
// if parameters shall be hidden in galaxy
bool hidden;
};
ParamFile(const String& name, File::OpenMode open_mode);
~ParamFile();
void writeSection(String section_name, String section_description, String version, const String& section_helptext,
const String& category, const std::list<std::pair<String,ParameterDescription> >& descriptions,
const std::map<String,list<String> >& values);
void readSection(String& tool_name, String& section_description, String& version, String& section_helptext,
String& category, std::list<std::pair<String, ParameterDescription> >& descriptions,
std::map<String,list<String> >& values,
bool overwrite_existing=false);
void close();
static String buildNestedParameterName(const String& category, const String& parameter_name);
static Size parseNestedParameterName(const String& parameter_name, String string_array[]);
protected:
String filename_;
File::OpenMode open_mode_;
bool mode_read_;
QXmlStreamReader* xmlIn_;
QXmlStreamWriter* xmlOut_;
QFile* file_;
private:
std::set<String> getTags(QXmlStreamAttributes& attributes);
};
}
#endif
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
BALL::File::File
File()
BALL::File::OpenMode
std::ios::openmode OpenMode
Definition file.h:165
BALL::ParamFile::readSection
void readSection(String &tool_name, String &section_description, String &version, String &section_helptext, String &category, std::list< std::pair< String, ParameterDescription > > &descriptions, std::map< String, list< String > > &values, bool overwrite_existing=false)
BALL::ParamFile::close
void close()
BALL::ParamFile::ParameterType
ParameterType
Definition paramFile.h:28
BALL::ParamFile::INFILE
@ INFILE
Definition paramFile.h:29
BALL::ParamFile::DOUBLE
@ DOUBLE
Definition paramFile.h:33
BALL::ParamFile::GALAXY_OPT_OUTDIR
@ GALAXY_OPT_OUTDIR
Definition paramFile.h:41
BALL::ParamFile::OUTFILE
@ OUTFILE
Definition paramFile.h:30
BALL::ParamFile::OUTFILELIST
@ OUTFILELIST
Definition paramFile.h:35
BALL::ParamFile::STRING
@ STRING
Definition paramFile.h:31
BALL::ParamFile::INTLIST
@ INTLIST
Definition paramFile.h:37
BALL::ParamFile::INFILELIST
@ INFILELIST
Definition paramFile.h:34
BALL::ParamFile::DOUBLELIST
@ DOUBLELIST
Definition paramFile.h:38
BALL::ParamFile::GALAXY_OPT_OUTID
@ GALAXY_OPT_OUTID
Definition paramFile.h:42
BALL::ParamFile::STRINGLIST
@ STRINGLIST
Definition paramFile.h:36
BALL::ParamFile::INT
@ INT
Definition paramFile.h:32
BALL::ParamFile::mode_read_
bool mode_read_
Definition paramFile.h:114
BALL::ParamFile::ParamFile
ParamFile(const String &name, File::OpenMode open_mode)
BALL::ParamFile::buildNestedParameterName
static String buildNestedParameterName(const String &category, const String &parameter_name)
BALL::ParamFile::file_
QFile * file_
Definition paramFile.h:117
BALL::ParamFile::xmlOut_
QXmlStreamWriter * xmlOut_
Definition paramFile.h:116
BALL::ParamFile::filename_
String filename_
Definition paramFile.h:112
BALL::ParamFile::parseNestedParameterName
static Size parseNestedParameterName(const String &parameter_name, String string_array[])
BALL::ParamFile::xmlIn_
QXmlStreamReader * xmlIn_
Definition paramFile.h:115
BALL::ParamFile::writeSection
void writeSection(String section_name, String section_description, String version, const String &section_helptext, const String &category, const std::list< std::pair< String, ParameterDescription > > &descriptions, const std::map< String, list< String > > &values)
BALL::ParamFile::open_mode_
File::OpenMode open_mode_
Definition paramFile.h:113
BALL::ParamFile::~ParamFile
~ParamFile()
BALL::String
Definition string.h:57
file.h
BALL
Definition constants.h:13
BALL::Size
BALL_SIZE_TYPE Size
Definition COMMON/global.h:114
string.h
BALL::ParamFile::ParameterDescription::allowed_values
list< String > allowed_values
Definition paramFile.h:69
BALL::ParamFile::ParameterDescription::name
String name
Definition paramFile.h:61
BALL::ParamFile::ParameterDescription::type
ParameterType type
Definition paramFile.h:66
BALL::ParamFile::ParameterDescription::advanced
bool advanced
Definition paramFile.h:65
BALL::ParamFile::ParameterDescription::category
String category
Definition paramFile.h:63
BALL::ParamFile::ParameterDescription::hidden
bool hidden
Definition paramFile.h:76
BALL::ParamFile::ParameterDescription::ParameterDescription
ParameterDescription()
Definition paramFile.h:48
BALL::ParamFile::ParameterDescription::supported_formats
list< String > supported_formats
Definition paramFile.h:73
BALL::ParamFile::ParameterDescription::mandatory
bool mandatory
Definition paramFile.h:64
BALL::ParamFile::ParameterDescription::description
String description
Definition paramFile.h:62