bpp-core3  3.0.0
AttributesTools.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_UTILS_ATTRIBUTESTOOLS_H
6 #define BPP_UTILS_ATTRIBUTESTOOLS_H
7 
8 
9 #include "../Exceptions.h"
10 
11 // From the STL:
12 #include <cstdlib>
13 #include <map>
14 #include <string>
15 #include <vector>
16 
17 namespace bpp
18 {
94 {
95 private:
96  /*
97  * vector of param names already seen, to avoid infinite recursion
98  *
99  */
100 
101  static std::vector<std::string> vParam_;
102 
103 public:
105  virtual ~AttributesTools() {}
106 
114  static std::vector<std::string> getVector(int argc, char* argv[]);
115 
125  static std::map<std::string, std::string> getAttributesMap(
126  const std::vector<std::string>& argv,
127  const std::string& delimiter = "=");
128 
139  static void getAttributesMap(
140  const std::vector<std::string>& argv,
141  std::map<std::string, std::string>& am,
142  const std::string& delimiter = "=");
143 
151  static std::map<std::string, std::string> getAttributesMapFromFile(
152  const std::string& file,
153  const std::string& delimiter);
154 
163  static void getAttributesMapFromFile(
164  const std::string& file,
165  std::map<std::string, std::string>& params,
166  const std::string& delimiter);
167 
179  static void actualizeAttributesMap(
180  std::map<std::string, std::string>& attMap,
181  const std::map<std::string, std::string>& atts,
182  bool replace = true);
183 
196  static void resolveVariables(std::map<std::string, std::string>& am,
197  char varCode = '$',
198  char varBeg = '(',
199  char varEnd = ')');
200 
210  static std::map<std::string, std::string> parseOptions(int args, char** argv);
211 
212 private:
220  static std::string removeComments(const std::string& s, const std::string& begin, const std::string& end);
221 };
222 } // end of namespace bpp.
223 #endif // BPP_UTILS_ATTRIBUTESTOOLS_H
static std::vector< std::string > vParam_
static std::string removeComments(const std::string &s, const std::string &begin, const std::string &end)
Remove comments from a string.
static std::map< std::string, std::string > getAttributesMapFromFile(const std::string &file, const std::string &delimiter)
Get an attribute map from a file.
static std::vector< std::string > getVector(int argc, char *argv[])
Get attributes a vector of strings from command line arguments.
static void actualizeAttributesMap(std::map< std::string, std::string > &attMap, const std::map< std::string, std::string > &atts, bool replace=true)
Actualizes an attribute map with another.
static std::map< std::string, std::string > parseOptions(int args, char **argv)
Global function that reads all parameters from command line and files, and set the values in a map...
static void resolveVariables(std::map< std::string, std::string > &am, char varCode='$', char varBeg='(', char varEnd=')')
Resolve the variables.
static std::map< std::string, std::string > getAttributesMap(const std::vector< std::string > &argv, const std::string &delimiter="=")
Get an attribute map from a vector of arguments.
Some functions to deal with attributes, i.e. parameters passed to a program/method.