Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/new_class_id/src/lib/util/executor/executor_substring.h @ 9745

Last change on this file since 9745 was 9745, checked in by bensch, 18 years ago

Extension possible now

File size: 3.2 KB
RevLine 
[4838]1/*!
[9737]2 * @file executor_generic.h
3 * Definition of a Generic Executor
[5391]4 */
[1853]5
[7716]6/*
7   orxonox - the future of 3D-vertical-scrollers
[1853]8
[7716]9   Copyright (C) 2004 orx
[1853]10
[7716]11   This program is free software; you can redistribute it and/or modify
12   it under the terms of the GNU General Public License as published by
13   the Free Software Foundation; either version 2, or (at your option)
14   any later version.
[5141]15
[7716]16### File Specific:
17   main-programmer: Benjamin Grauer
18   co-programmer: ...
19*/
[5652]20
[5328]21
[9740]22
[9742]23#ifndef __EXECUTOR_SUBSTRING_H_
24#define __EXECUTOR_SUBSTRING_H_
[5641]25
[9740]26
[9742]27#include "executor_generic.h"
[9728]28#include "substring.h"
[9745]29#ifdef FUNCTOR_CALL_TYPE
30 #undef FUNCTOR_CALL_TYPE
31#endif
32#define FUNCTOR_CALL_TYPE const SubString
[5641]33
[8035]34template<typename type> type fromString(const std::string& input, type defaultValue) { return defaultValue; };
[7721]35template<> bool fromString<bool>(const std::string& input, bool defaultValue);
36template<> int fromString<int>(const std::string& input, int defaultValue);
37template<> unsigned int fromString<unsigned int>(const std::string& input, unsigned int defaultValue);
38template<> float fromString<float>(const std::string& input, float defaultValue);
39template<> char fromString<char>(const std::string& input, char defaultValue);
40template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue);
[5641]41
[8035]42template<typename type> type fromMulti(const MultiType& multi) { /* return defaultValue; */ };
43template<> bool fromMulti<bool>(const MultiType& multi);
44template<> int fromMulti<int>(const MultiType& multi);
45template<> unsigned int fromMulti<unsigned int>(const MultiType& multi);
46template<> float fromMulti<float>(const MultiType& multi);
47template<> char fromMulti<char>(const MultiType& multi);
48template<> const std::string& fromMulti<const std::string&>(const MultiType& multi);
49
50
[7716]51template<typename type> type getDefault(const MultiType* const defaultValues, unsigned int i) { return (type)0; };
[7721]52template<> bool getDefault<bool>(const MultiType* const defaultValues, unsigned int i);
53template<> int getDefault<int>(const MultiType* const defaultValues, unsigned int i);
54template<> unsigned int getDefault<unsigned int>(const MultiType* const defaultValues, unsigned int i);
55template<> float getDefault<float>(const MultiType* const defaultValues, unsigned int i);
56template<> char getDefault<char>(const MultiType* const defaultValues, unsigned int i);
57template<> const std::string& getDefault<const std::string&>(const MultiType* const defaultValues, unsigned int i);
[5161]58
[9730]59
60/**
61 * @brief to remove writing errors, this function is Used.
62 * @param sub The SubString to use
63 * @param default The default Values.
64 */
[9736]65template<> class ExecutorEvaluater <const SubString>
[9730]66{
[9731]67public:
[9736]68  /** @brief Executes the Evaluater
[9735]69   * @param CallValue the Value that should be converted
70   * @param defaults the default Values.
71   */
[9736]72  template <typename ToType, int index>
73  ToType operator()(const SubString& CallValue, const MultiType* const defaults)
[9731]74  {
[9732]75    return (CallValue.size() > index) ?
76           fromString<ToType>(CallValue[index], getDefault<ToType>(defaults, index)) :
[9731]77           fromMulti<ToType>(defaults[index]);
78  }
[9736]79  static const SubString& defaultValue() { return SubString::NullSubString; };
[9730]80};
81
[9742]82#endif /* __EXECUTOR_SUBSTRING_H_ */
Note: See TracBrowser for help on using the repository browser.