Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 16, 2006, 10:09:59 PM (18 years ago)
Author:
bensch
Message:

completely documented Executors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/util/executor/executor_substring.cc

    r9742 r9748  
    1717#include "helper_functions.h"
    1818
     19/**
     20 * @brief converts an input string into a value, if no value was converted, uses defaultValue.
     21 * @param input the input as a String.
     22 * @param defaultValue the Default Value set, if the input could not be converted into type.
     23 * @returns either the converted value or defaultValue.
     24 */
    1925template<> bool fromString<bool>(const std::string& input, bool defaultValue) { return isBool(input, defaultValue); };
     26/**
     27 * @brief converts an input string into a value, if no value was converted, uses defaultValue.
     28 * @param input the input as a String.
     29 * @param defaultValue the Default Value set, if the input could not be converted into type.
     30 * @returns either the converted value or defaultValue.
     31 */
    2032template<> int fromString<int>(const std::string& input, int defaultValue) { return isInt(input, defaultValue); };
     33/**
     34 * @brief converts an input string into a value, if no value was converted, uses defaultValue.
     35 * @param input the input as a String.
     36 * @param defaultValue the Default Value set, if the input could not be converted into type.
     37 * @returns either the converted value or defaultValue.
     38 */
    2139template<> unsigned int fromString<unsigned int>(const std::string& input, unsigned int defaultValue) { return isInt(input, defaultValue); };
     40/**
     41 * @brief converts an input string into a value, if no value was converted, uses defaultValue.
     42 * @param input the input as a String.
     43 * @param defaultValue the Default Value set, if the input could not be converted into type.
     44 * @returns either the converted value or defaultValue.
     45 */
    2246template<> float fromString<float>(const std::string& input, float defaultValue) { return isFloat(input, defaultValue); };
     47/**
     48 * @brief converts an input string into a value, if no value was converted, uses defaultValue.
     49 * @param input the input as a String.
     50 * @param defaultValue the Default Value set, if the input could not be converted into type.
     51 * @returns either the converted value or defaultValue.
     52 */
    2353template<> char fromString<char>(const std::string& input, char defaultValue) { return isInt(input, defaultValue); };
     54/**
     55 * @brief converts an input string into a value, if no value was converted, uses defaultValue.
     56 * @param input the input as a String.
     57 * @param defaultValue the Default Value set, if the input could not be converted into type.
     58 * @returns either the converted value or defaultValue.
     59 */
    2460template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue) { return (input.size() > 0) ? input : defaultValue; };
    2561
    2662
     63/**
     64 * @brief converts to any type from a MultiType
     65 * @param multi the MultiType to convert.
     66 * @returns the converted Value.
     67 */
    2768template<> bool fromMulti<bool>(const MultiType& multi) { return multi.getBool(); };
     69/**
     70 * @brief converts to any type from a MultiType
     71 * @param multi the MultiType to convert.
     72 * @returns the converted Value.
     73 */
    2874template<> int fromMulti<int>(const MultiType& multi) { return multi.getInt(); }
     75/**
     76 * @brief converts to any type from a MultiType
     77 * @param multi the MultiType to convert.
     78 * @returns the converted Value.
     79 */
    2980template<> unsigned int fromMulti<unsigned int>(const MultiType& multi) { return multi.getInt(); };
     81/**
     82 * @brief converts to any type from a MultiType
     83 * @param multi the MultiType to convert.
     84 * @returns the converted Value.
     85 */
    3086template<> float fromMulti<float>(const MultiType& multi) { return multi.getFloat(); };
     87/**
     88 * @brief converts to any type from a MultiType
     89 * @param multi the MultiType to convert.
     90 * @returns the converted Value.
     91 */
    3192template<> char fromMulti<char>(const MultiType& multi) { return multi.getChar(); };
     93/**
     94 * @brief converts to any type from a MultiType
     95 * @param multi the MultiType to convert.
     96 * @returns the converted Value.
     97 */
    3298template<> const std::string& fromMulti<const std::string&>(const MultiType& multi) { return multi.getConstString(); };
    3399
    34100
     101/**
     102 * @brief retrieves a default value from an array of default values, at possition i.
     103 * @param defaultValues the Array of default values.
     104 * @param i the index.
     105 * @returns the Default Value at Position i
     106 */
    35107template<> bool getDefault<bool>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getBool(); };
     108/**
     109 * @brief retrieves a default value from an array of default values, at possition i.
     110 * @param defaultValues the Array of default values.
     111 * @param i the index.
     112 * @returns the Default Value at Position i
     113 */
    36114template<> int getDefault<int>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getInt(); };
     115/**
     116 * @brief retrieves a default value from an array of default values, at possition i.
     117 * @param defaultValues the Array of default values.
     118 * @param i the index.
     119 * @returns the Default Value at Position i
     120 */
    37121template<> unsigned int getDefault<unsigned int>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getInt(); };
     122/**
     123 * @brief retrieves a default value from an array of default values, at possition i.
     124 * @param defaultValues the Array of default values.
     125 * @param i the index.
     126 * @returns the Default Value at Position i
     127 */
    38128template<> float getDefault<float>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getFloat(); };
     129/**
     130 * @brief retrieves a default value from an array of default values, at possition i.
     131 * @param defaultValues the Array of default values.
     132 * @param i the index.
     133 * @returns the Default Value at Position i
     134 */
    39135template<> char getDefault<char>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getChar(); };
     136/**
     137 * @brief retrieves a default value from an array of default values, at possition i.
     138 * @param defaultValues the Array of default values.
     139 * @param i the index.
     140 * @returns the Default Value at Position i
     141 */
    40142template<> const std::string& getDefault<const std::string&>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getStoredString(); };
    41 
    42 
    43 
    44 
    45 
    46 
    47 
    48 /**
    49  * A LITTLE TESTING SUITE FOR THE EXECUTOR.
    50  *
    51 #include "executor/executor_functional.h"
    52 
    53 #define EXECUTOR_FUNCTIONAL_USE_STATIC
    54 #include "executor/executor_functional.h"
    55 
    56 class TestClass : public BaseObject
    57 {
    58   public:
    59     TestClass() {};
    60 
    61     void printTest() { printf ("TEST\n"); };
    62     void printTestInt(int i) { printf ("%d\n", i); };
    63     void printTestBool(bool b) { printf("%d\n", (int)b); };
    64     void printTwoVals(int b, int i) { printf ("%d %d\n", b, i); };
    65     void printStrings(const std::string& name) { printf("String:: '%s'\n", name.c_str()); };
    66     static void printStatic() { printf("STATIC\n");};
    67 };
    68 
    69 void TEST()
    70 {
    71   TestClass test;
    72   SubString testStrings("1 SCHEISSE, 2, 3", ",", SubString::WhiteSpaces, false);
    73   (*createExecutor<TestClass>(&TestClass::printTest))(&test, testStrings);
    74   (*createExecutor<TestClass>(&TestClass::printTestInt))(&test, testStrings);
    75   (*createExecutor<TestClass>(&TestClass::printTestBool))(&test, testStrings);
    76   (*createExecutor<TestClass>(&TestClass::printTwoVals))(&test, testStrings);
    77   (*createExecutor<TestClass>(&TestClass::printStatic))(&test, testStrings);
    78   (*createExecutor<TestClass>(&TestClass::printStrings))(&test, testStrings);
    79 
    80 }
    81 */
Note: See TracChangeset for help on using the changeset viewer.