<commit_before>// $Id: options.h,v 1.7 2000/07/26 14:38:21 amoll Exp $

#ifndef BALL_DATATYPE_OPTIONS_H
#define BALL_DATATYPE_OPTIONS_H

#ifndef BALL_COMMON_H
#	include <BALL/common.h>
#endif

#ifndef BALL_DATATYPE_STRING_H
#	include <BALL/DATATYPE/string.h>
#endif

#ifndef BALL_DATATYPE_STRINGHASHMAP_H
#	include <BALL/DATATYPE/stringHashMap.h>
#endif

#ifndef BALL_MATHS_VECTOR3_H
#	include <BALL/MATHS/vector3.h>
#endif

namespace BALL 
{

	/**		Options class.
				This object is intended to store options for complex
				method calls. These options are stored as key/value pairs
				of \Ref{String}s.\\
				Using this datastructure, options for force fields (\Ref{ForceField}),
				finit difference Poisson Boltzmann calculations (\Ref{FDPB}), or the results
				of calculations can be given, retrieved, stored into a file and retrieved from a file.
				This simplifies the handling of such complex parameter sets.\\

				{\bf Definition:} \URL{BALL/DATATYPE/options.h}
				\\
	*/
	class Options
		: public StringHashMap<String> 
	{
		
		public:

		/**	@name	Constants */
		//@{

		/**	Maximum length for each entry (key + value): 1024 byte.
				@memo
		*/
		static const Size MAX_ENTRY_LENGTH;

		//@}

		/**	@name Constructors and Destructors	
		*/
		//@{			

		/**	Default constructor. Creates a new and empty Options object.
				@memo
		*/
		Options();

		/**	Copy constructor.	
				Creates a new option table from an existing one.
				@param	options the options to be copied
				@param	deep bool, no effect		
				@memo
		*/
		Options(const Options& options, bool deep = true);

		/**		Destructor.
					Destructs the option table and frees all 
					allocated memory.
					@see	clear
					@memo
		*/
		virtual ~Options();

		//@}

		
		/**@name		Predicates
		*/
		//@{
		/**		Returns true, if the value associated with the 
					given key is an integer
					@param	key String
					@return	bool, true/false
					@memo
		*/
		bool isInteger(const String& key) const;

		/**		Returns true, if the value associated with the 
					given key is a boolean.
					A boolean entry has either the value {\tt true}
					or {\tt false}. 
					@param					key String
					@return					bool, true/false
					@memo
		*/
		bool isBool(const String& key) const;

		/**		Returns true, if the value associated with the 
					given key is a real number
					@param					key String
					@return					bool, true/false
					@memo
		*/
		bool isReal(const String& key) const;


		/**		Returns true, if the value associated with the given key 
					can be read as a vector.
					This method simply checks whether the value is of the form
					#(<float> <float> <float>)# where #<float>#
					represents an arbitrary floating point number.
					@param					key String
					@return					bool, true/false
					@memo
		*/
		bool isVector(const String& key) const;

		/**		Returns true, if a value is defined for the given 
					key
					@param					key String
					@return					bool, true/false
					@memo
		*/
		bool isSet(const String& key) const;

		//@}

		/**@name Inspectors and mutators
		*/
		//@{

		/**		Sets the option table's name.
					@memo
		*/
		void setName(const String& name);

		/**		Returns the option table's name.
					@memo
		*/
		const String& getName() const;

		/**		Returns the value associated with the key.
					@param	key the key
					@return	String, the value
					@memo
		*/
		String get(const String& key) const;

		/**		Returns the value associated with the key as bool.
					This method tries to convert the value associated
					with {\bf key} to a bool value.\\
					If the value is neither "true", nor "false", false is returned!
					You might want to check the value's validity as a bool first
					by calling \Ref{isBool}.
					@param	key the key
					@return	bool, boolean value
					@memo
		*/
		bool	getBool(const String& key) const;

		/**		Returns the value associated with the key as a floting point number.
					If the value could not be converted to a floating point number, a
					value of #0.0# is returned.\\
					You might want to check the value's validity as a floating point 
					number first by calling \Ref{isReal}.
					@param	key the key
					@return float, floating point value
					@memo
		*/
		double getReal(const String& key) const;

		/**		Returns the value associated with the key as a Vector3 object.
					This method is useful to read threedimensional coordinates, points, etc.
					The value corresponding to {\bf key} has to be of the form
					#(<float> <float> <float>)# (i.e. three floating point numbers separated
					by white blanks and surrounded by round brackets).\\
					If the content of the value is of a differnet format, the content
					of the returned vector is undefined. You might therefore check 
					the value's validity first by calling \Ref{isVector}.
					@param	key the key
					@return	Vector3	vector containing the three coordinates
					@memo
		*/
		Vector3	getVector(const String& key) const;

		/**		Returns the value associated with the key as an integer.
					If the value corresponding to {\bf key} could not be converted to an
					integer number, zero is returned. It is possible to check for the validity 
					of this conversion by calling \Ref{isInteger}.
					@return 	long the integer value
					@param	key the key
					@memo
		*/
		long getInteger(const String& key) const;

		/** 	Assigns value to key. 
					The string given as {\bf value} is assigned to the {\bf key}.
					If {\bf key} didn't exist in the internal hash table, it 
					is inserted.
					@param key the key
					@memo
		*/
		void set(const String& key, const String& value);

		/** 	Assigns the real number given by value to key.
					{\bf value} is first converted to a string, which is <commit_msg>added: commentary<commit_after>// $Id: options.h,v 1.8 2000/07/26 15:11:18 amoll Exp $

#ifndef BALL_DATATYPE_OPTIONS_H
#define BALL_DATATYPE_OPTIONS_H

#ifndef BALL_COMMON_H
#	include <BALL/common.h>
#endif

#ifndef BALL_DATATYPE_STRING_H
#	include <BALL/DATATYPE/string.h>
#endif

#ifndef BALL_DATATYPE_STRINGHASHMAP_H
#	include <BALL/DATATYPE/stringHashMap.h>
#endif

#ifndef BALL_MATHS_VECTOR3_H
#	include <BALL/MATHS/vector3.h>
#endif

namespace BALL 
{

	/**		Options class.
				This object is intended to store options for complex
				method calls. These options are stored as key/value pairs
				of \Ref{String}s.\\
				Using this datastructure, options for force fields (\Ref{ForceField}),
				finit difference Poisson Boltzmann calculations (\Ref{FDPB}), or the results
				of calculations can be given, retrieved, stored into a file and retrieved from a file.
				This simplifies the handling of such complex parameter sets.\\

				{\bf Definition:} \URL{BALL/DATATYPE/options.h}
				\\
	*/
	class Options
		: public StringHashMap<String> 
	{
		
		public:

		/**	@name	Constants */
		//@{

		/**	Maximum length for each entry (key + value): 1024 byte.
				@memo
		*/
		static const Size MAX_ENTRY_LENGTH;

		//@}

		/**	@name Constructors and Destructors	
		*/
		//@{			

		/**	Default constructor. Creates a new and empty Options object.
				@memo
		*/
		Options();

		/**	Copy constructor.	
				Creates a new option table from an existing one.
				@param	options the options to be copied
				@param	deep bool, no effect		
				@memo
		*/
		Options(const Options& options, bool deep = true);

		/**		Destructor.
					Destructs the option table and frees all 
					allocated memory.
					@see	clear
					@memo
		*/
		virtual ~Options();

		//@}

		
		/**@name		Predicates
		*/
		//@{
		/**		Returns true, if the value associated with the 
					given key is an integer
					@param	key String
					@return	bool, true/false
					@memo
		*/
		bool isInteger(const String& key) const;

		/**		Returns true, if the value associated with the 
					given key is a boolean.
					A boolean entry has either the value {\tt true}
					or {\tt false}. 
					@param					key String
					@return					bool, true/false
					@memo
		*/
		bool isBool(const String& key) const;

		/**		Returns true, if the value associated with the 
					given key is a real number
					@param					key String
					@return					bool, true/false
					@memo
		*/
		bool isReal(const String& key) const;


		/**		Returns true, if the value associated with the given key 
					can be read as a vector.
					This method simply checks whether the value is of the form
					#(<float> <float> <float>)# where #<float>#
					represents an arbitrary floating point number.
					@param					key String
					@return					bool, true/false
					@memo
		*/
		bool isVector(const String& key) const;

		/**		Returns true, if a value is defined for the given 
					key
					@param					key String
					@return					bool, true/false
					@memo
		*/
		bool isSet(const String& key) const;

		//@}

		/**@name Inspectors and mutators
		*/
		//@{

		/**		Sets the option table's name.
					@memo
		*/
		void setName(const String& name);

		/**		Returns the option table's name.
					@memo
		*/
		const String& getName() const;

		/**		Returns the value associated with the key.
					If the key does not exists an empty string is returned.
					@param	key the key
					@return	String, the value
					@memo
		*/
		String get(const String& key) const;

		/**		Returns the value associated with the key as bool.
					This method tries to convert the value associated
					with {\bf key} to a bool value.\\
					If the value is neither "true", nor "false" or the key does
					not exist false is returned!
					You might want to check the value's validity as a bool first
					by calling \Ref{isBool}.
					@param	key the key
					@return	bool, boolean value
					@memo
		*/
		bool	getBool(const String& key) const;

		/**		Returns the value associated with the key as a floting point number.
					If the value could not be converted to a floating point number or the key
					does not exist a value of #0.0# is returned.\\
					You might want to check the value's validity as a floating point 
					number first by calling \Ref{isReal}.
					@param	key the key
					@return float, floating point value
					@memo
		*/
		double getReal(const String& key) const;

		/**		Returns the value associated with the key as a Vector3 object.
					This method is useful to read threedimensional coordinates, points, etc.
					The value corresponding to {\bf key} has to be of the form
					#(<float> <float> <float>)# (i.e. three floating point numbers separated
					by white blanks and surrounded by round brackets).\\
					If the content of the value is of a differnet format or the key does not
					exists, the content	of the returned vector is undefined.
					You might therefore check the value's validity first
					by calling \Ref{isVector}.
					@param	key the key
					@return	Vector3	vector containing the three coordinates
					@memo
		*/
		Vector3	getVector(const String& key) const;

		/**		Returns the value associated with the key as an integer.
					If the value corresponding to {\bf key} could not be converted to an
					integer number or the key does not exists, zero is returned.
					It is possible to check for the validity 
					of this conversion by calling \Ref{isInteger}.
					@return 	long the integer value
					@param	key the key
					@memo
		*/
		long getInteger(const String& key) const;

		/** 	Assigns value to key. 
					The string given as {\bf value} is assigned to the {\bf key}.
					If {\bf key} didn't exist in the internal hash table, it 
					is inserted.
					@param key the key
					@memo
		*/
		void set(const String& key, const String& value);

		/** 	Assigns the real number given by value to key.
					{\bf value} is first converted to a string, which is 
{'fraction_non_alphanumeric': 0.08535020952706748, 'fraction_numerical': 0.004618147609681006, 'mean_word_length': 2.5685077815074764, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2112470', 'n_tokens_mistral': 4532, 'n_tokens_neox': 3526, 'n_words': 1494}