Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7203 in orxonox.OLD for branches


Ignore:
Timestamp:
Mar 9, 2006, 5:28:10 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: compiles again, BUT well…. i do not expect it to run anymore

Location:
branches/std/src
Files:
60 edited

Legend:

Unmodified
Added
Removed
  • branches/std/src/lib/Makefile.am

    r7193 r7203  
    5555
    5656SUBDIRS = \
     57        . \
    5758        math \
    5859        graphics \
     
    6566        parser \
    6667        shell \
    67         gui \
    68         .
     68        gui
  • branches/std/src/lib/event/key_mapper.cc

    r6998 r7203  
    129129 * @param filename: The path and name of the file to load the bindings from
    130130*/
    131 void KeyMapper::loadKeyBindings (const char* fileName)
     131void KeyMapper::loadKeyBindings (const std::string& fileName)
    132132{
    133133  IniParser parser(fileName);
     
    145145
    146146  iniParser->firstVar();
    147   while(iniParser->getCurrentName())
     147  while(iniParser->getCurrentName() != "")
    148148  {
    149149    PRINTF(3)("Keys: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue());
     
    164164
    165165  iniParser->firstVar();
    166   while(iniParser->getCurrentName())
     166  while(iniParser->getCurrentName() != "")
    167167  {
    168168    PRINTF(3)("MISC: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue());
     
    177177 * @param the name of the button
    178178*/
    179 int* KeyMapper::nameToIndex (const char* name)
     179int* KeyMapper::nameToIndex (const std::string& name)
    180180{
    181181  coord[0] = -1;
     
    199199 * @param id of the key
    200200*/
    201 void KeyMapper::mapKeys(const char* name, int* index)
     201void KeyMapper::mapKeys(const std::string& name, int* index)
    202202{
    203203  for( int i = 0; map[i].pValue != NULL; ++i )
    204204    {
    205       if( !strcmp (name, map[i].pName))
     205      if( name == map[i].pName)
    206206      {
    207207        if( index[0] == 0)
  • branches/std/src/lib/event/key_mapper.h

    r6998 r7203  
    2929  virtual ~KeyMapper();
    3030
    31   void loadKeyBindings(const char* fileName = NULL);
     31  void loadKeyBindings(const std::string& fileName = NULL);
    3232  void loadKeyBindings(IniParser* iniParser);
    3333
     
    3535
    3636 private:
    37   int* nameToIndex (const char* name);
    38   void mapKeys(const char* name, int* index);
     37  int* nameToIndex (const std::string& name);
     38  void mapKeys(const std::string& name, int* index);
    3939
    4040 public:
  • branches/std/src/lib/event/key_names.cc

    r5476 r7203  
    2323using namespace std;
    2424
    25 int buttonnameToSDLB(const char* name)
     25int buttonnameToSDLB(const std::string& name)
    2626{
    27         if( !strcmp (name, "BUTTON_LEFT")) return EV_MOUSE_BUTTON_LEFT;
    28         if( !strcmp (name, "BUTTON_MIDDLE")) return EV_MOUSE_BUTTON_MIDDLE;
    29         if( !strcmp (name, "BUTTON_RIGHT")) return EV_MOUSE_BUTTON_RIGHT;
    30         if( !strcmp (name, "BUTTON_WHEELUP")) return EV_MOUSE_BUTTON_WHEELUP;
    31         if( !strcmp (name, "BUTTON_WHEELDOWN")) return EV_MOUSE_BUTTON_WHEELDOWN;
     27        if((name == "BUTTON_LEFT")) return EV_MOUSE_BUTTON_LEFT;
     28        if((name == "BUTTON_MIDDLE")) return EV_MOUSE_BUTTON_MIDDLE;
     29        if((name == "BUTTON_RIGHT")) return EV_MOUSE_BUTTON_RIGHT;
     30        if((name == "BUTTON_WHEELUP")) return EV_MOUSE_BUTTON_WHEELUP;
     31        if((name == "BUTTON_WHEELDOWN")) return EV_MOUSE_BUTTON_WHEELDOWN;
    3232        return -1;
    3333}
     
    4343}
    4444
    45 int keynameToSDLK(const char* name)
     45int keynameToSDLK(const std::string& name)
    4646{
    47         if( !strcmp (name, "BACKSPACE")) return SDLK_BACKSPACE;
    48         if( !strcmp (name, "TAB")) return SDLK_TAB;
    49         if( !strcmp (name, "CLEAR")) return SDLK_CLEAR;
    50         if( !strcmp (name, "RETURN")) return SDLK_RETURN;
    51         if( !strcmp (name, "ESCAPE")) return SDLK_ESCAPE;
    52         if( !strcmp (name, "SPACE")) return SDLK_SPACE;
    53         if( !strcmp (name, "EXCLAIM")) return SDLK_EXCLAIM;
    54         if( !strcmp (name, "QUOTEDBL")) return SDLK_QUOTEDBL;
    55         if( !strcmp (name, "HASH")) return SDLK_HASH;
    56         if( !strcmp (name, "PAUSE")) return SDLK_PAUSE;
    57         if( !strcmp (name, "DOLLAR")) return SDLK_DOLLAR;
    58         if( !strcmp (name, "AMPERSAND")) return SDLK_AMPERSAND;
    59         if( !strcmp (name, "QUOTE")) return SDLK_QUOTE;
    60         if( !strcmp (name, "LEFTPAREN")) return SDLK_LEFTPAREN;
    61         if( !strcmp (name, "RIGHTPAREN")) return SDLK_RIGHTPAREN;
    62         if( !strcmp (name, "ASTERISK")) return SDLK_ASTERISK;
    63         if( !strcmp (name, "PLUS")) return SDLK_PLUS;
    64         if( !strcmp (name, "COMMA")) return SDLK_COMMA;
    65         if( !strcmp (name, "MINUS")) return SDLK_MINUS;
    66         if( !strcmp (name, "PERIOD")) return SDLK_PERIOD;
    67         if( !strcmp (name, "SLASH")) return SDLK_SLASH;
    68         if( !strcmp (name, "0")) return SDLK_0;
    69         if( !strcmp (name, "1")) return SDLK_1;
    70         if( !strcmp (name, "2")) return SDLK_2;
    71         if( !strcmp (name, "3")) return SDLK_3;
    72         if( !strcmp (name, "4")) return SDLK_4;
    73         if( !strcmp (name, "5")) return SDLK_5;
    74         if( !strcmp (name, "6")) return SDLK_6;
    75         if( !strcmp (name, "7")) return SDLK_7;
    76         if( !strcmp (name, "8")) return SDLK_8;
    77         if( !strcmp (name, "9")) return SDLK_9;
    78         if( !strcmp (name, "COLON")) return SDLK_COLON;
    79         if( !strcmp (name, "SEMICOLON")) return SDLK_SEMICOLON;
    80         if( !strcmp (name, "LESS")) return SDLK_LESS;
    81         if( !strcmp (name, "EQUALS")) return SDLK_EQUALS;
    82         if( !strcmp (name, "GREATER")) return SDLK_GREATER;
    83         if( !strcmp (name, "QUESTION")) return SDLK_QUESTION;
    84         if( !strcmp (name, "AT")) return SDLK_AT;
    85         if( !strcmp (name, "LEFTBRACKET")) return SDLK_LEFTBRACKET;
    86         if( !strcmp (name, "BACKSLASH")) return SDLK_BACKSLASH;
    87         if( !strcmp (name, "RIGHTBRACKET")) return SDLK_RIGHTBRACKET;
    88         if( !strcmp (name, "CARET")) return SDLK_CARET;
    89         if( !strcmp (name, "UNDERSCORE")) return SDLK_UNDERSCORE;
    90         if( !strcmp (name, "BACKQUOTE")) return SDLK_BACKQUOTE;
    91         if( !strcmp (name, "a")) return SDLK_a;
    92         if( !strcmp (name, "b")) return SDLK_b;
    93         if( !strcmp (name, "c")) return SDLK_c;
    94         if( !strcmp (name, "d")) return SDLK_d;
    95         if( !strcmp (name, "e")) return SDLK_e;
    96         if( !strcmp (name, "f")) return SDLK_f;
    97         if( !strcmp (name, "g")) return SDLK_g;
    98         if( !strcmp (name, "h")) return SDLK_h;
    99         if( !strcmp (name, "i")) return SDLK_i;
    100         if( !strcmp (name, "j")) return SDLK_j;
    101         if( !strcmp (name, "k")) return SDLK_k;
    102         if( !strcmp (name, "l")) return SDLK_l;
    103         if( !strcmp (name, "m")) return SDLK_m;
    104         if( !strcmp (name, "n")) return SDLK_n;
    105         if( !strcmp (name, "o")) return SDLK_o;
    106         if( !strcmp (name, "p")) return SDLK_p;
    107         if( !strcmp (name, "q")) return SDLK_q;
    108         if( !strcmp (name, "r")) return SDLK_r;
    109         if( !strcmp (name, "s")) return SDLK_s;
    110         if( !strcmp (name, "t")) return SDLK_t;
    111         if( !strcmp (name, "u")) return SDLK_u;
    112         if( !strcmp (name, "v")) return SDLK_v;
    113         if( !strcmp (name, "w")) return SDLK_w;
    114         if( !strcmp (name, "x")) return SDLK_x;
    115         if( !strcmp (name, "y")) return SDLK_y;
    116         if( !strcmp (name, "z")) return SDLK_z;
    117         if( !strcmp (name, "DELETE")) return SDLK_DELETE;
    118         if( !strcmp (name, "KP0")) return SDLK_KP0;
    119         if( !strcmp (name, "KP1")) return SDLK_KP1;
    120         if( !strcmp (name, "KP2")) return SDLK_KP2;
    121         if( !strcmp (name, "KP3")) return SDLK_KP3;
    122         if( !strcmp (name, "KP4")) return SDLK_KP4;
    123         if( !strcmp (name, "KP5")) return SDLK_KP5;
    124         if( !strcmp (name, "KP6")) return SDLK_KP6;
    125         if( !strcmp (name, "KP7")) return SDLK_KP7;
    126         if( !strcmp (name, "KP8")) return SDLK_KP8;
    127         if( !strcmp (name, "KP9")) return SDLK_KP9;
    128         if( !strcmp (name, "KP_PERIOD")) return SDLK_KP_PERIOD;
    129         if( !strcmp (name, "KP_DIVIDE")) return SDLK_KP_DIVIDE;
    130         if( !strcmp (name, "KP_MULTIPLY")) return SDLK_KP_MULTIPLY;
    131         if( !strcmp (name, "KP_MINUS")) return SDLK_KP_MINUS;
    132         if( !strcmp (name, "KP_PLUS")) return SDLK_KP_PLUS;
    133         if( !strcmp (name, "KP_ENTER")) return SDLK_KP_ENTER;
    134         if( !strcmp (name, "KP_EQUALS")) return SDLK_KP_EQUALS;
    135         if( !strcmp (name, "UP")) return SDLK_UP;
    136         if( !strcmp (name, "DOWN")) return SDLK_DOWN;
    137         if( !strcmp (name, "RIGHT")) return SDLK_RIGHT;
    138         if( !strcmp (name, "LEFT")) return SDLK_LEFT;
    139         if( !strcmp (name, "INSERT")) return SDLK_INSERT;
    140         if( !strcmp (name, "HOME")) return SDLK_HOME;
    141         if( !strcmp (name, "END")) return SDLK_END;
    142         if( !strcmp (name, "PAGEUP")) return SDLK_PAGEUP;
    143         if( !strcmp (name, "PAGEDOWN")) return SDLK_PAGEDOWN;
    144         if( !strcmp (name, "F1")) return SDLK_F1;
    145         if( !strcmp (name, "F2")) return SDLK_F2;
    146         if( !strcmp (name, "F3")) return SDLK_F3;
    147         if( !strcmp (name, "F4")) return SDLK_F4;
    148         if( !strcmp (name, "F5")) return SDLK_F5;
    149         if( !strcmp (name, "F6")) return SDLK_F6;
    150         if( !strcmp (name, "F7")) return SDLK_F7;
    151         if( !strcmp (name, "F8")) return SDLK_F8;
    152         if( !strcmp (name, "F9")) return SDLK_F9;
    153         if( !strcmp (name, "F10")) return SDLK_F10;
    154         if( !strcmp (name, "F11")) return SDLK_F11;
    155         if( !strcmp (name, "F12")) return SDLK_F12;
    156         if( !strcmp (name, "F13")) return SDLK_F13;
    157         if( !strcmp (name, "F14")) return SDLK_F14;
    158         if( !strcmp (name, "F15")) return SDLK_F15;
    159         if( !strcmp (name, "NUMLOCK")) return SDLK_NUMLOCK;
    160         if( !strcmp (name, "CAPSLOCK")) return SDLK_CAPSLOCK;
    161         if( !strcmp (name, "SCROLLOCK")) return SDLK_SCROLLOCK;
    162         if( !strcmp (name, "RSHIFT")) return SDLK_RSHIFT;
    163         if( !strcmp (name, "LSHIFT")) return SDLK_LSHIFT;
    164         if( !strcmp (name, "RCTRL")) return SDLK_RCTRL;
    165         if( !strcmp (name, "LCTRL")) return SDLK_LCTRL;
    166         if( !strcmp (name, "RALT")) return SDLK_RALT;
    167         if( !strcmp (name, "LALT")) return SDLK_LALT;
    168         if( !strcmp (name, "RMETA")) return SDLK_RMETA;
    169         if( !strcmp (name, "LMETA")) return SDLK_LMETA;
    170         if( !strcmp (name, "LSUPER")) return SDLK_LSUPER;
    171         if( !strcmp (name, "RSUPER")) return SDLK_RSUPER;
    172         if( !strcmp (name, "MODE")) return SDLK_MODE;
    173         if( !strcmp (name, "HELP")) return SDLK_HELP;
    174         if( !strcmp (name, "PRINT")) return SDLK_PRINT;
    175         if( !strcmp (name, "SYSREQ")) return SDLK_SYSREQ;
    176         if( !strcmp (name, "BREAK")) return SDLK_BREAK;
    177         if( !strcmp (name, "MENU")) return SDLK_MENU;
    178         if( !strcmp (name, "POWER")) return SDLK_POWER;
    179         if( !strcmp (name, "EURO")) return SDLK_EURO;
     47        if((name == "BACKSPACE")) return SDLK_BACKSPACE;
     48        if((name == "TAB")) return SDLK_TAB;
     49        if((name == "CLEAR")) return SDLK_CLEAR;
     50        if((name == "RETURN")) return SDLK_RETURN;
     51        if((name == "ESCAPE")) return SDLK_ESCAPE;
     52        if((name == "SPACE")) return SDLK_SPACE;
     53        if((name == "EXCLAIM")) return SDLK_EXCLAIM;
     54        if((name == "QUOTEDBL")) return SDLK_QUOTEDBL;
     55        if((name == "HASH")) return SDLK_HASH;
     56        if((name == "PAUSE")) return SDLK_PAUSE;
     57        if((name == "DOLLAR")) return SDLK_DOLLAR;
     58        if((name == "AMPERSAND")) return SDLK_AMPERSAND;
     59        if((name == "QUOTE")) return SDLK_QUOTE;
     60        if((name == "LEFTPAREN")) return SDLK_LEFTPAREN;
     61        if((name == "RIGHTPAREN")) return SDLK_RIGHTPAREN;
     62        if((name == "ASTERISK")) return SDLK_ASTERISK;
     63        if((name == "PLUS")) return SDLK_PLUS;
     64        if((name == "COMMA")) return SDLK_COMMA;
     65        if((name == "MINUS")) return SDLK_MINUS;
     66        if((name == "PERIOD")) return SDLK_PERIOD;
     67        if((name == "SLASH")) return SDLK_SLASH;
     68        if((name == "0")) return SDLK_0;
     69        if((name == "1")) return SDLK_1;
     70        if((name == "2")) return SDLK_2;
     71        if((name == "3")) return SDLK_3;
     72        if((name == "4")) return SDLK_4;
     73        if((name == "5")) return SDLK_5;
     74        if((name == "6")) return SDLK_6;
     75        if((name == "7")) return SDLK_7;
     76        if((name == "8")) return SDLK_8;
     77        if((name == "9")) return SDLK_9;
     78        if((name == "COLON")) return SDLK_COLON;
     79        if((name == "SEMICOLON")) return SDLK_SEMICOLON;
     80        if((name == "LESS")) return SDLK_LESS;
     81        if((name == "EQUALS")) return SDLK_EQUALS;
     82        if((name == "GREATER")) return SDLK_GREATER;
     83        if((name == "QUESTION")) return SDLK_QUESTION;
     84        if((name == "AT")) return SDLK_AT;
     85        if((name == "LEFTBRACKET")) return SDLK_LEFTBRACKET;
     86        if((name == "BACKSLASH")) return SDLK_BACKSLASH;
     87        if((name == "RIGHTBRACKET")) return SDLK_RIGHTBRACKET;
     88        if((name == "CARET")) return SDLK_CARET;
     89        if((name == "UNDERSCORE")) return SDLK_UNDERSCORE;
     90        if((name == "BACKQUOTE")) return SDLK_BACKQUOTE;
     91        if((name == "a")) return SDLK_a;
     92        if((name == "b")) return SDLK_b;
     93        if((name == "c")) return SDLK_c;
     94        if((name == "d")) return SDLK_d;
     95        if((name == "e")) return SDLK_e;
     96        if((name == "f")) return SDLK_f;
     97        if((name == "g")) return SDLK_g;
     98        if((name == "h")) return SDLK_h;
     99        if((name == "i")) return SDLK_i;
     100        if((name == "j")) return SDLK_j;
     101        if((name == "k")) return SDLK_k;
     102        if((name == "l")) return SDLK_l;
     103        if((name == "m")) return SDLK_m;
     104        if((name == "n")) return SDLK_n;
     105        if((name == "o")) return SDLK_o;
     106        if((name == "p")) return SDLK_p;
     107        if((name == "q")) return SDLK_q;
     108        if((name == "r")) return SDLK_r;
     109        if((name == "s")) return SDLK_s;
     110        if((name == "t")) return SDLK_t;
     111        if((name == "u")) return SDLK_u;
     112        if((name == "v")) return SDLK_v;
     113        if((name == "w")) return SDLK_w;
     114        if((name == "x")) return SDLK_x;
     115        if((name == "y")) return SDLK_y;
     116        if((name == "z")) return SDLK_z;
     117        if((name == "DELETE")) return SDLK_DELETE;
     118        if((name == "KP0")) return SDLK_KP0;
     119        if((name == "KP1")) return SDLK_KP1;
     120        if((name == "KP2")) return SDLK_KP2;
     121        if((name == "KP3")) return SDLK_KP3;
     122        if((name == "KP4")) return SDLK_KP4;
     123        if((name == "KP5")) return SDLK_KP5;
     124        if((name == "KP6")) return SDLK_KP6;
     125        if((name == "KP7")) return SDLK_KP7;
     126        if((name == "KP8")) return SDLK_KP8;
     127        if((name == "KP9")) return SDLK_KP9;
     128        if((name == "KP_PERIOD")) return SDLK_KP_PERIOD;
     129        if((name == "KP_DIVIDE")) return SDLK_KP_DIVIDE;
     130        if((name == "KP_MULTIPLY")) return SDLK_KP_MULTIPLY;
     131        if((name == "KP_MINUS")) return SDLK_KP_MINUS;
     132        if((name == "KP_PLUS")) return SDLK_KP_PLUS;
     133        if((name == "KP_ENTER")) return SDLK_KP_ENTER;
     134        if((name == "KP_EQUALS")) return SDLK_KP_EQUALS;
     135        if((name == "UP")) return SDLK_UP;
     136        if((name == "DOWN")) return SDLK_DOWN;
     137        if((name == "RIGHT")) return SDLK_RIGHT;
     138        if((name == "LEFT")) return SDLK_LEFT;
     139        if((name == "INSERT")) return SDLK_INSERT;
     140        if((name == "HOME")) return SDLK_HOME;
     141        if((name == "END")) return SDLK_END;
     142        if((name == "PAGEUP")) return SDLK_PAGEUP;
     143        if((name == "PAGEDOWN")) return SDLK_PAGEDOWN;
     144        if((name == "F1")) return SDLK_F1;
     145        if((name == "F2")) return SDLK_F2;
     146        if((name == "F3")) return SDLK_F3;
     147        if((name == "F4")) return SDLK_F4;
     148        if((name == "F5")) return SDLK_F5;
     149        if((name == "F6")) return SDLK_F6;
     150        if((name == "F7")) return SDLK_F7;
     151        if((name == "F8")) return SDLK_F8;
     152        if((name == "F9")) return SDLK_F9;
     153        if((name == "F10")) return SDLK_F10;
     154        if((name == "F11")) return SDLK_F11;
     155        if((name == "F12")) return SDLK_F12;
     156        if((name == "F13")) return SDLK_F13;
     157        if((name == "F14")) return SDLK_F14;
     158        if((name == "F15")) return SDLK_F15;
     159        if((name == "NUMLOCK")) return SDLK_NUMLOCK;
     160        if((name == "CAPSLOCK")) return SDLK_CAPSLOCK;
     161        if((name == "SCROLLOCK")) return SDLK_SCROLLOCK;
     162        if((name == "RSHIFT")) return SDLK_RSHIFT;
     163        if((name == "LSHIFT")) return SDLK_LSHIFT;
     164        if((name == "RCTRL")) return SDLK_RCTRL;
     165        if((name == "LCTRL")) return SDLK_LCTRL;
     166        if((name == "RALT")) return SDLK_RALT;
     167        if((name == "LALT")) return SDLK_LALT;
     168        if((name == "RMETA")) return SDLK_RMETA;
     169        if((name == "LMETA")) return SDLK_LMETA;
     170        if((name == "LSUPER")) return SDLK_LSUPER;
     171        if((name == "RSUPER")) return SDLK_RSUPER;
     172        if((name == "MODE")) return SDLK_MODE;
     173        if((name == "HELP")) return SDLK_HELP;
     174        if((name == "PRINT")) return SDLK_PRINT;
     175        if((name == "SYSREQ")) return SDLK_SYSREQ;
     176        if((name == "BREAK")) return SDLK_BREAK;
     177        if((name == "MENU")) return SDLK_MENU;
     178        if((name == "POWER")) return SDLK_POWER;
     179        if((name == "EURO")) return SDLK_EURO;
    180180        return -1;
    181181}
    182182
    183 const char* SDLKToKeyname( int key)
     183const char* SDLKToKeyname(int key)
    184184{
    185185        if( key == SDLK_BACKSPACE) return "BACKSPACE";
  • branches/std/src/lib/event/key_names.h

    r5474 r7203  
    11/*!
    22 * @file keynames.h
    3   *  Key/button naming functions
    4 
    5                Converts strings to SDLK/SDL_BUTTON values and vice versa
    6 */
     3 *  Key/button naming functions
     4 *
     5 * Converts strings to SDLK/SDL_BUTTON values and vice versa
     6 */
    77#ifndef _KEY_NAMES_H
    88#define _KEY_NAMES_H
    99
    10 /**
    11       *  converts a button name string to a integer representing the corresponding SDL mouse button identifier
    12       * @param name: the name of the mouse button
    13       * @return an int containing the SDL identifier of the mouse button or -1 if the button name is not valid
    14 */
    15 int buttonnameToSDLB(const char* name);
     10#include <string>
    1611
    1712/**
    18       *  converst a SDL mouse button identifier to a name string
    19       * @param button: an SDL mouse button identifier
    20       * @return a pointer to a string containing the name of the mouse button
    21 */
     13 *  converts a button name string to a integer representing the corresponding SDL mouse button identifier
     14 * @param name: the name of the mouse button
     15 * @return an int containing the SDL identifier of the mouse button or -1 if the button name is not valid
     16 */
     17int buttonnameToSDLB(const std::string& name);
     18
     19/**
     20 *  converst a SDL mouse button identifier to a name string
     21 * @param button: an SDL mouse button identifier
     22 * @return a pointer to a string containing the name of the mouse button
     23 */
    2224const char* SDLBToButtonname( int button);
    2325
    2426/**
    25       *  converts a key name string to a integer representing the corresponding SDLK sym
    26       * @param name: the name of the key
    27       * @return the SDLK sym of the named key or -1 if the key name is not valid
    28 */
    29 int keynameToSDLK(const char* name);
     27 *  converts a key name string to a integer representing the corresponding SDLK sym
     28 * @param name: the name of the key
     29 * @return the SDLK sym of the named key or -1 if the key name is not valid
     30 */
     31int keynameToSDLK(const std::string& name);
    3032
    3133/**
    32       *  converts an SDLK sym to a name string
    33       * @param key: the SDLK sym
    34       * @return a pointer to a string containig the name of the key
    35 */
     34 *  converts an SDLK sym to a name string
     35 * @param key: the SDLK sym
     36 * @return a pointer to a string containig the name of the key
     37 */
    3638const char* SDLKToKeyname( int key);
    3739
  • branches/std/src/lib/graphics/graphics_engine.cc

    r7193 r7203  
    169169{
    170170  // looking if we are in fullscreen-mode
    171   const char* fullscreen = iniParser->getVar(CONFIG_NAME_FULLSCREEN, CONFIG_SECTION_VIDEO, "0");
    172   if (strchr(fullscreen, '1') || !strcasecmp(fullscreen, "true"))
     171  const std::string fullscreen = iniParser->getVar(CONFIG_NAME_FULLSCREEN, CONFIG_SECTION_VIDEO, "0");
     172  if (fullscreen[0] == '1' || fullscreen == "true")
    173173    this->fullscreenFlag = SDL_FULLSCREEN;
    174174
    175175  // looking if we are in fullscreen-mode
    176   const char* textures = iniParser->getVar(CONFIG_NAME_TEXTURES, CONFIG_SECTION_VIDEO_ADVANCED, "0");
    177   if (strchr(textures, '1') || !strcasecmp(textures, "true"))
     176  const std::string textures = iniParser->getVar(CONFIG_NAME_TEXTURES, CONFIG_SECTION_VIDEO_ADVANCED, "0");
     177  if (textures[0] == '1' || textures == "true")
    178178    Texture::setTextureEnableState( true);
    179179  else
     
    181181
    182182  // searching for a usefull resolution
    183   SubString resolution(iniParser->getVar(CONFIG_NAME_RESOLUTION, CONFIG_SECTION_VIDEO, "640x480"), 'x');
     183  SubString resolution(iniParser->getVar(CONFIG_NAME_RESOLUTION, CONFIG_SECTION_VIDEO, "640x480").c_str(), 'x'); ///FIXME
    184184  //resolution.debug();
    185185
     
    262262 * @param icon The name of the Icon on the Disc
    263263 */
    264 void GraphicsEngine::setWindowName(const char* windowName, const char* icon)
    265 {
    266   SDL_Surface* iconSurf = SDL_LoadBMP(icon);
     264void GraphicsEngine::setWindowName(const std::string& windowName, const std::string& icon)
     265{
     266  SDL_Surface* iconSurf = SDL_LoadBMP(icon.c_str());
    267267  if (iconSurf != NULL)
    268268  {
    269269    Uint32 colorkey = SDL_MapRGB(iconSurf->format, 0, 0, 0);
    270270    SDL_SetColorKey(iconSurf, SDL_SRCCOLORKEY, colorkey);
    271     SDL_WM_SetIcon(iconSurf,NULL);
     271    SDL_WM_SetIcon(iconSurf, NULL);
    272272    SDL_FreeSurface(iconSurf);
    273273  }
    274274
    275   SDL_WM_SetCaption (windowName, icon);
     275  SDL_WM_SetCaption (windowName.c_str(), icon.c_str());
    276276}
    277277
  • branches/std/src/lib/graphics/graphics_engine.h

    r6990 r7203  
    4141    int initFromIniFile(IniParser* iniParser);
    4242
    43     void setWindowName(const char* windowName, const char* icon);
     43    void setWindowName(const std::string& windowName, const std::string& icon);
    4444
    4545    int setResolution(int width, int height, int bpp);
  • branches/std/src/lib/graphics/importer/height_map.cc

    r7193 r7203  
    333333}
    334334
    335 HeightMap::HeightMap(const char* height_map_name = NULL) : VertexArrayModel()
     335HeightMap::HeightMap(const std::string& height_map_name = "")
     336  : VertexArrayModel()
    336337{
    337338   this->setClassID(CL_HEIGHT_MAP, "HeightMap");
    338    heightMap =  IMG_Load(height_map_name);
     339   heightMap =  IMG_Load(height_map_name.c_str());
    339340   if(heightMap!=NULL) {
    340341
    341                  PRINTF(0)("loading Image %s\n", height_map_name);
     342     PRINTF(0)("loading Image %s\n", height_map_name.c_str());
    342343                 PRINTF(0)("width : %i\n", heightMap->w);
    343344                 PRINTF(0)("height : %i\n", heightMap->h);
     
    350351                }
    351352
    352      else       PRINTF(4)("oops! couldn't load %s for some reason.\n", height_map_name);
     353                else       PRINTF(4)("oops! couldn't load %s for some reason.\n", height_map_name.c_str());
    353354
    354355
     
    361362}
    362363
    363 HeightMap::HeightMap(const char* height_map_name = NULL, const char* colour_map_name = NULL) : VertexArrayModel()
     364HeightMap::HeightMap(const std::string& height_map_name = NULL, const std::string& colour_map_name = NULL)
     365  : VertexArrayModel()
    364366{
    365367this->setClassID(CL_HEIGHT_MAP, "HeightMap");
    366368
    367    heightMap =  IMG_Load(height_map_name);
     369   heightMap =  IMG_Load(height_map_name.c_str());
    368370   if(heightMap!=NULL) {
    369371
    370                  PRINTF(0)("loading Image %s\n", height_map_name);
     372     PRINTF(0)("loading Image %s\n", height_map_name.c_str());
    371373                 PRINTF(0)("width : %i\n", heightMap->w);
    372374                 PRINTF(0)("height : %i\n", heightMap->h);
     
    379381                }
    380382
    381      else       PRINTF(4)("oops! couldn't load %s for some reason.\n", height_map_name);
     383                else       PRINTF(4)("oops! couldn't load %s for some reason.\n", height_map_name.c_str());
    382384
    383385
     
    385387
    386388  colourMap=NULL;
    387   if(colour_map_name != NULL)
     389  if(colour_map_name != "")
    388390  {
    389   colourMap = IMG_Load(colour_map_name);
     391    colourMap = IMG_Load(colour_map_name.c_str());
    390392  }
    391393
    392394  if(colourMap != NULL)
    393395                {
    394                  PRINTF(0)("loading Image %s\n", colour_map_name);
     396                  PRINTF(0)("loading Image %s\n", colour_map_name.c_str());
    395397                 PRINTF(0)("width : %i\n", colourMap->w);
    396398                 PRINTF(0)("height : %i\n", colourMap->h);
  • branches/std/src/lib/graphics/importer/height_map.h

    r6981 r7203  
    5959void load();
    6060void load(int Mode);
    61 void load(const char*, int Mode);
     61void load(const std::string&, int Mode);
    6262void scale( Vector V);
    6363void setAbsCoor(Vector V);
     
    6565float getNormal(float x, float y);
    6666HeightMap();
    67 HeightMap(const char*);
    68 HeightMap(const char*, const char*);
     67HeightMap(const std::string&);
     68HeightMap(const std::string&, const std::string&);
    6969virtual ~HeightMap();
    7070
  • branches/std/src/lib/graphics/importer/material.cc

    r7193 r7203  
    3434 * @param mtlName Name of the Material to be added to the Material List
    3535 */
    36 Material::Material (const char* mtlName)
     36Material::Material (const std::string& mtlName)
    3737{
    3838  this->setClassID(CL_MATERIAL, "Material");
     
    278278 * @param pathName The Path to add.
    279279*/
    280 void Material::addTexturePath(const char* pathName)
     280void Material::addTexturePath(const std::string& pathName)
    281281{
    282282  ResourceManager::getInstance()->addImageDir(pathName);
     
    289289 * @param dMap the Name of the Image to Use
    290290*/
    291 void Material::setDiffuseMap(const char* dMap, GLenum target)
     291void Material::setDiffuseMap(const std::string& dMap, GLenum target)
    292292{
    293293  PRINTF(5)("setting Diffuse Map %s\n", dMap);
     
    297297  //! @todo check if RESOURCE MANAGER is availiable
    298298  //! @todo Textures from .mtl-file need special care.
    299   if (dMap != NULL)
     299  if (!dMap.empty())
    300300    this->diffuseTexture = (Texture*)ResourceManager::getInstance()->load(dMap, IMAGE, RP_GAME, (int)target);
    301301  else
     
    308308   @todo implement this
    309309*/
    310 void Material::setAmbientMap(const char* aMap, GLenum target)
     310void Material::setAmbientMap(const std::string& aMap, GLenum target)
    311311{
    312312  SDL_Surface* ambientMap;
     
    319319   @todo implement this
    320320*/
    321 void Material::setSpecularMap(const char* sMap, GLenum target)
     321void Material::setSpecularMap(const std::string& sMap, GLenum target)
    322322{
    323323  SDL_Surface* specularMap;
     
    330330   @todo implemet this
    331331*/
    332 void Material::setBump(const char* bump)
    333 {
    334 
    335 }
     332void Material::setBump(const std::string& bump)
     333{
     334
     335}
  • branches/std/src/lib/graphics/importer/material.h

    r7057 r7203  
    2626{
    2727 public:
    28   Material (const char* mtlName = NULL);
     28  Material (const std::string& mtlName = "");
    2929  virtual ~Material ();
    3030
     
    4949
    5050 // MAPPING //
    51   void setDiffuseMap(const char* dMap, GLenum target = GL_TEXTURE_2D);
    52   void setAmbientMap(const char* aMap, GLenum target = GL_TEXTURE_2D);
    53   void setSpecularMap(const char* sMap, GLenum target = GL_TEXTURE_2D);
    54   void setBump(const char* bump);
     51  void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D);
     52  void setAmbientMap(const std::string& aMap, GLenum target = GL_TEXTURE_2D);
     53  void setSpecularMap(const std::string& sMap, GLenum target = GL_TEXTURE_2D);
     54  void setBump(const std::string& bump);
    5555  GLuint getDiffuseTexture() const { return (this->diffuseTexture)? this->diffuseTexture->getTexture() : 0; };
    5656
    57   static void addTexturePath(const char* pathName);
     57  static void addTexturePath(const std::string& pathName);
    5858
    5959  private:
  • branches/std/src/lib/graphics/importer/md2Model.cc

    r7193 r7203  
    7575  \brief simple constructor initializing all variables
    7676*/
    77 MD2Model::MD2Model(const char* modelFileName, const char* skinFileName, float scale)
     77MD2Model::MD2Model(const std::string& modelFileName, const std::string& skinFileName, float scale)
    7878{
    7979  this->setClassID(CL_MD2_MODEL, "MD2Model");
     
    352352{
    353353  PRINT(0)("\n==========================| MD2Model::debug() |===\n");
    354   PRINT(0)("=  Model FileName:\t%s\n", this->data->fileName);
    355   PRINT(0)("=  Skin FileName:\t%s\n", this->data->skinFileName);
     354  PRINT(0)("=  Model FileName:\t%s\n", this->data->fileName.c_str());
     355  PRINT(0)("=  Skin FileName:\t%s\n", this->data->skinFileName.c_str());
    356356  PRINT(0)("=  Size in Memory:\t%i Bytes\n", this->data->header->frameSize * this->data->header->numFrames + 64); // 64bytes is the header size
    357357  PRINT(0)("=  Number of Vertices:\t%i\n", this->data->header->numVertices);
     
    370370  \brief simple constructor
    371371*/
    372 MD2Data::MD2Data(const char* modelFileName, const char* skinFileName, float scale)
     372MD2Data::MD2Data(const std::string& modelFileName, const std::string& skinFileName, float scale)
    373373{
    374374  scale *= 0.1f;
     
    387387  this->scaleFactor = scale;
    388388
    389   this->fileName = NULL;
    390   this->skinFileName = NULL;
     389  this->fileName = "";
     390  this->skinFileName = "";
    391391  this->loadModel(modelFileName);
    392392  this->loadSkin(skinFileName);
     
    401401MD2Data::~MD2Data()
    402402{
    403   delete [] this->fileName;
    404   delete [] this->skinFileName;
    405403  delete this->header;
    406404
     
    419417  \return true if success
    420418*/
    421 bool MD2Data::loadModel(const char* fileName)
     419bool MD2Data::loadModel(const std::string& fileName)
    422420{
    423421  FILE *pFile;                            //file stream
     
    428426
    429427  //! @todo this chek should include deleting a loaded model (eventually)
    430   if (fileName == NULL)
     428  if (fileName.empty())
    431429    return false;
    432430
    433   pFile = fopen(fileName, "rb");
     431  pFile = fopen(fileName.c_str(), "rb");
    434432  if( unlikely(!pFile))
    435433    {
     
    442440  if( unlikely(this->header->version != MD2_VERSION) && unlikely(this->header->ident != MD2_IDENT))
    443441    {
    444       PRINTF(1)("Couldn't load file %s: invalid file format: stop loading\n", fileName);
     442      PRINTF(1)("Couldn't load file %s: invalid file format: stop loading\n", fileName.c_str());
    445443      return false;
    446444    }
    447445
    448   this->fileName = new char[strlen(fileName)+1];
    449   strcpy(this->fileName, fileName);
     446  this->fileName =fileName;
    450447  /* got the data: map it to locals */
    451448  this->numFrames = this->header->numFrames;
     
    507504  \return true if success
    508505*/
    509 bool MD2Data::loadSkin(const char* fileName)
    510 {
    511   if( fileName == NULL)
    512     {
    513       this->skinFileName = NULL;
     506bool MD2Data::loadSkin(const std::string& fileName)
     507{
     508  if( fileName.empty())
     509    {
     510      this->skinFileName = "";
    514511      return false;
    515512    }
    516513
    517   this->skinFileName = new char[strlen(fileName)+1];
    518   strcpy(this->skinFileName, fileName);
     514  this->skinFileName =fileName;
    519515
    520516  this->material.setName("md2ModelMaterial");
  • branches/std/src/lib/graphics/importer/md2Model.h

    r7123 r7203  
    189189{
    190190 public:
    191    MD2Data(const char* modelFileName, const char* skinFileName, float scale = 1.0f);
     191   MD2Data(const std::string& modelFileName, const std::string& skinFileName, float scale = 1.0f);
    192192  virtual ~MD2Data();
    193193
    194194 private:
    195   bool loadModel(const char* fileName);
    196   bool loadSkin(const char* fileName = NULL);
     195   bool loadModel(const std::string& fileName);
     196   bool loadSkin(const std::string& fileName = NULL);
    197197
    198198 public:
     
    202202  int                numTexCoor;            //!< number of texture coordinates
    203203  int                numGLCommands;         //!< number of gl commands in the glList (tells how to draw)
    204   char*              fileName;              //!< file name of the model File
    205   char*              skinFileName;          //!< file name of the skin file
     204  std::string        fileName;              //!< file name of the model File
     205  std::string        skinFileName;          //!< file name of the skin file
    206206  MD2Header*         header;                //!< the header file
    207207
     
    223223
    224224public:
    225   MD2Model(const char* modelFileName, const char* skinFileName = NULL, float scale = 1.0f);
     225  MD2Model(const std::string& modelFileName, const std::string& skinFileName = NULL, float scale = 1.0f);
    226226  virtual ~MD2Model();
    227227
  • branches/std/src/lib/graphics/importer/media_container.cc

    r7193 r7203  
    101101
    102102  // Open video file
    103   if (av_open_input_file(&format_context, ResourceManager::getFullName(filename), NULL, 0, NULL) !=0 )
    104   {
    105     PRINTF(1)("Could not open %s\n", ResourceManager::getFullName(filename));
     103  if (av_open_input_file(&format_context, ResourceManager::getFullName(filename).c_str(), NULL, 0, NULL) !=0 )
     104  {
     105    PRINTF(1)("Could not open %s\n", ResourceManager::getFullName(filename).c_str());
    106106    return false;
    107107  }
     
    110110  if (av_find_stream_info(format_context) < 0)
    111111  {
    112     PRINTF(1)("Could not find stream information in %s\n", ResourceManager::getFullName(filename));
     112    PRINTF(1)("Could not find stream information in %s\n", ResourceManager::getFullName(filename).c_str());
    113113    return false;
    114114  }
     
    116116  // Find the first video stream and take it
    117117  video_stream = av_find_default_stream_index(format_context);
    118  
     118
    119119  if(video_stream == -1)
    120120  {
    121     PRINTF(1)("Could not find a video stream in %s\n", ResourceManager::getFullName(filename));
     121    PRINTF(1)("Could not find a video stream in %s\n", ResourceManager::getFullName(filename).c_str());
    122122    return false;
    123123  }
     
    202202      // Free the packet that was allocated by av_read_frame
    203203      av_free_packet(&packet);
    204      
     204
    205205      // Did we get a video frame?
    206206      if(frame_finished)
     
    216216          memcpy(&data[i*codec_context->width*3],
    217217                 ((AVPicture*)RGB_frame)->data[0]+i *
    218                  ((AVPicture*)RGB_frame)->linesize[0], 
     218                 ((AVPicture*)RGB_frame)->linesize[0],
    219219                  codec_context->width*sizeof(uint8_t)*3);
    220220
     
    258258  }
    259259  else
    260     return NULL;
    261 }
     260    return 0;
     261}
  • branches/std/src/lib/graphics/importer/movie_player.cc

    r7193 r7203  
    3131
    3232
    33 MoviePlayer::MoviePlayer(const char* filename)
     33MoviePlayer::MoviePlayer(const std::string& filename)
    3434{
    3535  // set the class id for the base object
     
    8383
    8484
    85 bool MoviePlayer::loadMovie(const char* filename)
     85bool MoviePlayer::loadMovie(const std::string& filename)
    8686{
    8787  this->unloadMedia();
    8888
    89   if(filename == NULL)
     89  if(filename.empty())
    9090    return false;
    9191  // check whether file exists
    9292  if(!ResourceManager::isInDataDir(filename))
    9393  {
    94     PRINTF(1)("Could not find %s\n", filename);
     94    PRINTF(1)("Could not find %s\n", filename.c_str());
    9595    return false;
    9696  }
     
    100100
    101101  // Open video file
    102   if (av_open_input_file(&format_context, ResourceManager::getFullName(filename), NULL, 0, NULL) !=0 )
    103   {
    104     PRINTF(1)("Could not open %s\n", ResourceManager::getFullName(filename));
     102  if (av_open_input_file(&format_context, ResourceManager::getFullName(filename).c_str(), NULL, 0, NULL) !=0 )
     103  {
     104    PRINTF(1)("Could not open %s\n", ResourceManager::getFullName(filename).c_str());
    105105    return false;
    106106  }
     
    109109  if (av_find_stream_info(format_context) < 0)
    110110  {
    111     PRINTF(1)("Could not find stream information in %s\n", ResourceManager::getFullName(filename));
     111    PRINTF(1)("Could not find stream information in %s\n", ResourceManager::getFullName(filename).c_str());
    112112    return false;
    113113  }
     
    118118  if(video_stream == -1)
    119119  {
    120     PRINTF(1)("Could not find a video stream in %s\n", ResourceManager::getFullName(filename));
     120    PRINTF(1)("Could not find a video stream in %s\n", ResourceManager::getFullName(filename).c_str());
    121121    return false;
    122122  }
  • branches/std/src/lib/graphics/importer/movie_player.h

    r6981 r7203  
    5858public:
    5959
    60   MoviePlayer(const char* filename = NULL);
     60  MoviePlayer(const std::string& filename = NULL);
    6161  virtual ~MoviePlayer();
    6262
    63   bool loadMovie(const char* filename);
     63  bool loadMovie(const std::string& filename);
    6464
    6565  void start(float start_time);
  • branches/std/src/lib/graphics/importer/objModel.cc

    r6162 r7203  
    3232 * @param scaling The factor that the model will be scaled with.
    3333*/
    34 OBJModel::OBJModel(const char* fileName, float scaling) : StaticModel(fileName)
     34OBJModel::OBJModel(const std::string& fileName, float scaling)
     35  : StaticModel(fileName)
    3536{
    3637  this->setClassID(CL_OBJ_MODEL, "OBJModel");
     
    5152*/
    5253OBJModel::~OBJModel()
    53 {
    54   PRINTF(4)("Deleting the obj-names\n");
    55   if (this->objPath)
    56     delete []this->objPath;
    57 }
     54{ }
    5855
    5956/**
     
    6360   Splits the FileName from the DirectoryName
    6461*/
    65 bool OBJModel::importFile (const char* fileName)
    66 {
     62bool OBJModel::importFile (const std::string& fileNameInput)
     63{
     64  const char* fileName = fileNameInput.c_str();
    6765  PRINTF(4)("preparing to read in file: %s\n", fileName);
    6866  // splitting the
     
    7472    {
    7573      int len = split - fileName+1;
    76       this->objPath = new char[len +2];
    77       strncpy(this->objPath, fileName, len);
     74      this->objPath =  fileName;
     75      this->objPath.erase(len, this->objPath.size());
    7876      this->objPath[len] = '\0';
    7977      PRINTF(4)("Resolved file %s to Path %s.\n", fileName, this->objPath);
     
    9189   This function does read the file, parses it for the occurence of things like vertices, faces and so on, and executes the specific tasks
    9290*/
    93 bool OBJModel::readFromObjFile(const char* fileName)
     91bool OBJModel::readFromObjFile(const std::string& fileName)
    9492{
    9593  FILE* stream;
    96   if( (stream = fopen (fileName, "r")) == NULL)
    97     {
    98       PRINTF(2)("Object File Could not be Opened %s\n", fileName);
     94  if( (stream = fopen (fileName.c_str(), "r")) == NULL)
     95    {
     96      PRINTF(2)("Object File Could not be Opened %s\n", fileName.c_str());
    9997      return false;
    10098    }
     
    162160 * that a material does not have to be able to read itself in from a File.
    163161 */
    164 bool OBJModel::readMtlLib (const char* mtlFile)
    165 {
    166   char* fileName = new char [strlen(this->objPath) + strlen(mtlFile)+1];
    167   sprintf(fileName, "%s%s", this->objPath, mtlFile);
     162bool OBJModel::readMtlLib (const std::string& mtlFile)
     163{
     164  std::string fileName = this->objPath + mtlFile;
    168165
    169166  FILE* stream;
    170   if( (stream = fopen (fileName, "r")) == NULL)
    171     {
    172       PRINTF(2)("MaterialLibrary could not be opened %s\n", fileName);
    173       delete[] fileName;
     167  if( (stream = fopen (fileName.c_str(), "r")) == NULL)
     168    {
     169      PRINTF(2)("MaterialLibrary could not be opened %s\n", fileName.c_str());
    174170      return false;
    175171    }
     
    258254    }
    259255  fclose(stream);
    260   delete []fileName;
    261256  return true;
    262257}
  • branches/std/src/lib/graphics/importer/objModel.h

    r6022 r7203  
    1313{
    1414 public:
    15   OBJModel(const char* fileName, float scaling = 1.0);
     15   OBJModel(const std::string& fileName, float scaling = 1.0);
    1616  virtual ~OBJModel();
    1717
    1818 private:
    1919  ///// readin /////
    20   bool importFile (const char* fileName);
    21   bool readFromObjFile (const char* fileName);
    22   bool readMtlLib (const char* matFile);
     20   bool importFile (const std::string& fileName);
     21   bool readFromObjFile (const std::string& fileName);
     22   bool readMtlLib (const std::string& matFile);
    2323
    2424 private:
    25   char*       objPath;     //!< The Path where the obj and mtl-file are located.
     25   std::string       objPath;     //!< The Path where the obj and mtl-file are located.
    2626};
    2727
  • branches/std/src/lib/graphics/importer/static_model.cc

    r6423 r7203  
    2323#include <stdarg.h>
    2424
    25 #include "vector.h"
    26 
    2725using namespace std;
    2826
     
    8684{
    8785  PRINTF(4)("Adding new Group\n");
    88   this->name = NULL;
     86  this->name = "";
    8987  this->faceMode = -1;
    9088  this->faceCount = 0;
     
    109107  if (this->listNumber != 0)
    110108    glDeleteLists(this->listNumber, 1);
    111 
    112   if (this->name != NULL)
    113     delete[] this->name;
    114109
    115110  if (this->next !=NULL)
     
    142137 * assigns it a Name and a Type
    143138 */
    144 StaticModel::StaticModel(const char* modelName)
     139StaticModel::StaticModel(const std::string& modelName)
    145140{
    146141  this->setClassID(CL_STATIC_MODEL, "StaticModel");
     
    276271 * It does this by just calling the List that must have been created earlier.
    277272 */
    278 void StaticModel::draw (char* groupName) const
    279 {
    280   if (groupName == NULL)
    281      return;
     273void StaticModel::draw (const std::string& groupName) const
     274{
    282275  PRINTF(4)("drawing the requested 3D-Models if found.\n");
    283276  ModelGroup* tmpGroup = this->firstGroup;
    284277  while (tmpGroup != NULL)
    285278    {
    286       if (tmpGroup->name != NULL && !strcmp(tmpGroup->name, groupName))
     279      if (tmpGroup->name == groupName)
    287280        {
    288           PRINTF(4)("Drawing model %s\n", tmpGroup->name);
     281          PRINTF(4)("Drawing model %s\n", tmpGroup->name.c_str());
    289282          glCallList (tmpGroup->listNumber);
    290283          return;
     
    292285      tmpGroup = tmpGroup->next;
    293286    }
    294   PRINTF(2)("Model Named %s in %s not Found.\n", groupName, this->getName());
     287    PRINTF(2)("Model Named %s in %s not Found.\n", groupName.c_str(), this->getName());
    295288  return;
    296289}
     
    341334 * @returns the added material
    342335 */
    343 Material* StaticModel::addMaterial(const char* materialName)
     336Material* StaticModel::addMaterial(const std::string& materialName)
    344337{
    345338  ModelMaterial* modMat = new ModelMaterial;
     
    357350 * @returns the Material if found, NULL otherwise
    358351 */
    359 Material* StaticModel::findMaterialByName(const char* materialName)
     352Material* StaticModel::findMaterialByName(const std::string& materialName)
    360353{
    361354  list<ModelMaterial*>::iterator modMat;
    362355  for  (modMat = this->materialList.begin(); modMat != this->materialList.end(); modMat++)
    363     if (!strcmp((*modMat)->material->getName(), materialName))
     356    if (materialName == (*modMat)->material->getName())
    364357      return (*modMat)->material;
    365358  return NULL;
     
    373366 * With it you should be able to create Models with more than one SubModel inside
    374367 */
    375 bool StaticModel::addGroup(const char* groupString)
     368bool StaticModel::addGroup(const std::string& groupString)
    376369{
    377370  PRINTF(5)("Read Group: %s.\n", groupString);
     
    382375    }
    383376  // setting the group name if not default.
    384   if (strcmp(groupString, "default"))
    385     {
    386       this->currentGroup->name = new char [strlen(groupString)+1];
    387       strcpy(this->currentGroup->name, groupString);
     377  if (groupString == "default")
     378    {
     379      this->currentGroup->name = groupString;
    388380    }
    389381  ++this->groupCount;
     
    396388 *  If a vertex line is found this function will inject it into the vertex-Array
    397389 */
    398 bool StaticModel::addVertex (const char* vertexString)
     390bool StaticModel::addVertex (const std::string& vertexString)
    399391{
    400392  float subbuffer1;
    401393  float subbuffer2;
    402394  float subbuffer3;
    403   sscanf (vertexString, "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
     395  sscanf (vertexString.c_str(), "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
    404396  this->vertices.push_back(subbuffer1*scaleFactor);
    405397  this->vertices.push_back(subbuffer2*scaleFactor);
     
    431423 * If a vertexNormal line is found this function will inject it into the vertexNormal-Array
    432424 */
    433 bool StaticModel::addVertexNormal (const char* normalString)
     425bool StaticModel::addVertexNormal (const std::string& normalString)
    434426{
    435427  float subbuffer1;
    436428  float subbuffer2;
    437429  float subbuffer3;
    438   sscanf (normalString, "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
     430  sscanf (normalString.c_str(), "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
    439431  this->normals.push_back(subbuffer1);
    440432  this->normals.push_back(subbuffer2);
     
    471463 * !! WARNING THIS IS DIFFERNT FROM addVervexTexture(float, float); because it changes the second entry to 1-v !!
    472464 */
    473 bool StaticModel::addVertexTexture (const char* vTextureString)
     465bool StaticModel::addVertexTexture (const std::string& vTextureString)
    474466{
    475467  float subbuffer1;
    476468  float subbuffer2;
    477   sscanf (vTextureString, "%f %f", &subbuffer1, &subbuffer2);
     469  sscanf (vTextureString.c_str(), "%f %f", &subbuffer1, &subbuffer2);
    478470  this->vTexture.push_back(subbuffer1);
    479471  this->vTexture.push_back(1 - subbuffer2);
     
    508500 * in this, that the first Vertex/Normal/Texcoord is 1 instead of 0
    509501 */
    510 bool StaticModel::addFace (const char* faceString)
    511 {
     502bool StaticModel::addFace (const std::string& faceStringInput)
     503{
     504  const char* faceString = faceStringInput.c_str();
    512505  if (this->currentGroup->faceCount >0)
    513506    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new ModelFace;
     
    596589 * @param matString the Material that will be set.
    597590*/
    598 bool StaticModel::setMaterial(const char* matString)
     591bool StaticModel::setMaterial(const std::string& matString)
    599592{
    600593  if (this->currentGroup->faceCount > 0)
  • branches/std/src/lib/graphics/importer/static_model.h

    r6423 r7203  
    1313#include <vector>
    1414#include <list>
    15 
    16 // FORWARD DECLARATION //
    17 template<class T> class tArray;
    1815
    1916// definition of different modes for setting up Faces
     
    7067  void cleanup();
    7168
    72   char*        name;           //!< the Name of the Group. this is an identifier, that can be accessed via the draw (char* name) function.
     69  std::string  name;           //!< the Name of the Group. this is an identifier, that can be accessed via the draw (std::string name) function.
    7370  GLubyte*     indices;        //!< The indices of the Groups. Needed for vertex-arrays
    7471  GLuint       listNumber;     //!< The number of the GL-List this Group gets.
     
    9895{
    9996 public:
    100   StaticModel(const char* modelName = NULL);
     97  StaticModel(const std::string& modelName = NULL);
    10198  virtual ~StaticModel();
    10299
    103100  virtual void draw() const;
    104101  void draw(int groupNumber) const;
    105   void draw(char* groupName) const;
     102  void draw(const std::string& groupName) const;
    106103
    107104  void rebuild();
    108105
    109106  Material* addMaterial(Material* material);
    110   Material* addMaterial(const char* materialName);
     107  Material* addMaterial(const std::string& materialName);
    111108
    112   bool addGroup(const char* groupString);
     109  bool addGroup(const std::string& groupString);
    113110
    114   bool addVertex(const char* vertexString);
     111  bool addVertex(const std::string& vertexString);
    115112  bool addVertex(float x, float y, float z);
    116113
    117   bool addFace(const char* faceString);
     114  bool addFace(const std::string& faceString);
    118115  bool addFace(int faceElemCount, VERTEX_FORMAT type, ...);
    119116
    120   bool addVertexNormal(const char* normalString);
     117  bool addVertexNormal(const std::string& normalString);
    121118  bool addVertexNormal(float x, float y, float z);
    122119
    123   bool addVertexTexture(const char* vTextureString);
     120  bool addVertexTexture(const std::string& vTextureString);
    124121  bool addVertexTexture(float u, float v);
    125122
    126   bool setMaterial(const char* mtlString);
     123  bool setMaterial(const std::string& mtlString);
    127124  bool setMaterial(Material* mtl);
    128125
     
    133130  void cubeModel();
    134131
    135   Material* findMaterialByName(const char* materialName);
     132  Material* findMaterialByName(const std::string& materialName);
    136133
    137134 protected:
  • branches/std/src/lib/graphics/importer/texture.cc

    r6871 r7203  
    3232 *  Constructor for a Texture
    3333*/
    34 Texture::Texture(const char* imageName, GLenum target)
     34Texture::Texture(const std::string& imageName, GLenum target)
    3535{
    3636  this->setClassID(CL_TEXTURE, "Texture");
     
    4141  this->priority = 0.5;
    4242
    43   if (imageName != NULL)
     43  if (!imageName.empty())
    4444  {
    4545    this->setName(imageName);
     
    6767 * @param imageName The image to load
    6868*/
    69 bool Texture::loadImage(const char* imageName, GLenum target)
     69bool Texture::loadImage(const std::string& imageName, GLenum target)
    7070{
    7171  if (Texture::texturesEnabled)
     
    8181      this->texture = 0;
    8282    }
    83     if (imageName != NULL)
     83    if (!imageName.empty())
    8484    {
    8585      SDL_Surface* tmpSurf;
     
    8787        glDeleteTextures(1, &this->texture);
    8888      // load the new Image to memory
    89       tmpSurf = IMG_Load(imageName);
     89      tmpSurf = IMG_Load(imageName.c_str());
    9090      if(tmpSurf != NULL)
    9191      {
  • branches/std/src/lib/graphics/importer/texture.h

    r6981 r7203  
    1818  {
    1919    public:
    20       Texture(const char* imageName = NULL, GLenum target = GL_TEXTURE_2D);
     20      Texture(const std::string& imageName = NULL, GLenum target = GL_TEXTURE_2D);
    2121  //  Texture(TEXTURE_TYPE type, int resolution);
    2222      virtual ~Texture();
    2323
    24       bool loadImage(const char* imageName, GLenum target = GL_TEXTURE_2D);
     24      bool loadImage(const std::string& imageName, GLenum target = GL_TEXTURE_2D);
    2525      virtual bool rebuild();
    2626
  • branches/std/src/lib/graphics/shader.cc

    r7193 r7203  
    3636 * standard constructor
    3737*/
    38 Shader::Shader (const char* vertexShaderFile, const char* fragmentShaderFile)
     38Shader::Shader (const std::string& vertexShaderFile, const std::string& fragmentShaderFile)
    3939{
    4040   this->setClassID(CL_SHADER, "Shader");
    4141
    42    this->fragmentShaderFile = NULL;
    43    this->vertexShaderFile = NULL;
     42   this->fragmentShaderFile = "";
     43   this->vertexShaderFile = "";
    4444   this->shaderProgram = 0;
    4545   this->vertexShader = 0;
     
    5252       this->shaderProgram = glCreateProgramObjectARB();
    5353
    54        if (vertexShaderFile != NULL)
     54       if (!vertexShaderFile.empty())
    5555         this->loadShaderProgramm(SHADER_VERTEX, vertexShaderFile);
    56        if (fragmentShaderFile != NULL)
     56       if (!fragmentShaderFile.empty())
    5757         this->loadShaderProgramm(SHADER_FRAGMENT, fragmentShaderFile);
    5858       glLinkProgramARB(this->shaderProgram);
     
    103103}
    104104
    105 Shader* Shader::getShader(const char* vertexShaderFile, const char* fragmentShaderFile)
     105Shader* Shader::getShader(const std::string& vertexShaderFile, const std::string& fragmentShaderFile)
    106106{
    107107  return (Shader*)ResourceManager::getInstance()->load(vertexShaderFile, SHADER,  RP_LEVEL, fragmentShaderFile);
     
    116116
    117117
    118 bool Shader::loadShaderProgramm(SHADER_TYPE type, const char* fileName)
     118bool Shader::loadShaderProgramm(SHADER_TYPE type, const std::string& fileName)
    119119{
    120120  GLhandleARB shader = 0;
     
    129129  if (type == SHADER_VERTEX && GLEW_ARB_vertex_shader)
    130130  {
    131     this->vertexShaderFile = new char[strlen(fileName)+1];
    132     strcpy(this->vertexShaderFile, fileName);
     131    this->vertexShaderFile = fileName;
    133132
    134133    shader = this->vertexShader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
     
    137136  if (type == SHADER_FRAGMENT && GLEW_ARB_fragment_shader)
    138137  {
    139     this->fragmentShaderFile = new char[strlen(fileName)+1];
    140     strcpy(this->fragmentShaderFile, fileName);
     138    this->fragmentShaderFile = fileName;
    141139
    142140    shader = this->fragmentShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
     
    146144  {
    147145    GLint status = 0;
    148     glShaderSourceARB(shader, program->size(), (const char**)&(*program)[0], NULL);
     146    /// FIXME do it back
     147    //    glShaderSourceARB(shader, program->size(), (const std::string&)&(*program)[0], NULL);
    149148    glCompileShaderARB(shader);
    150149    // checking on error.
     
    160159}
    161160
    162 char* Shader::fileRead(const char* fileName)
     161char* Shader::fileRead(const std::string& fileName)
    163162{
    164163  FILE* fileHandle;
     
    167166  int count = 0;
    168167
    169   if (fileName == NULL)
     168  if (fileName.empty())
    170169    return NULL;
    171170
    172   fileHandle = fopen(fileName, "rt");
     171  fileHandle = fopen(fileName.c_str(), "rt");
    173172
    174173  if (fileHandle == NULL)
     
    187186
    188187
    189 std::vector<char*>* Shader::fileReadArray(const char* fileName)
     188std::vector<char*>* Shader::fileReadArray(const std::string& fileName)
    190189{
    191190  FILE*    stream;           //< The stream we use to read the file.
    192191
    193   if( (stream = fopen (fileName, "rt")) == NULL)
    194   {
    195     PRINTF(1)("Shader could not open %s\n", fileName);
     192  if( (stream = fopen (fileName.c_str(), "rt")) == NULL)
     193  {
     194    PRINTF(1)("Shader could not open %s\n", fileName.c_str());
    196195    return NULL;
    197196  }
     
    234233  if (type == SHADER_VERTEX && this->vertexShader != 0)
    235234  {
    236     delete[] this->vertexShaderFile;
    237     this->vertexShaderFile = NULL;
     235    this->vertexShaderFile = "";
    238236    glDetachObjectARB(this->shaderProgram, this->vertexShader);
    239237    glDeleteObjectARB(this->vertexShader);
     
    245243  else if (type == SHADER_FRAGMENT && this->fragmentShader != 0)
    246244  {
    247     delete[] this->fragmentShaderFile;
    248     this->fragmentShaderFile = NULL;
     245    this->fragmentShaderFile = "";
    249246    glDetachObjectARB(this->shaderProgram, this->fragmentShader);
    250247    glDeleteObjectARB(this->fragmentShader);
  • branches/std/src/lib/graphics/shader.h

    r7195 r7203  
    2727
    2828  public:
    29   Shader(const char* vertexShaderFile = NULL, const char* fragmentShaderFile = NULL);
     29  Shader(const std::string& vertexShaderFile = NULL, const std::string& fragmentShaderFile = NULL);
    3030  virtual ~Shader();
    31   static Shader* getShader(const char* vertexShaderFile, const char* fragmentShaderFile);
     31  static Shader* getShader(const std::string& vertexShaderFile, const std::string& fragmentShaderFile);
    3232  static bool unload(Shader* shader);
    3333
    34   bool loadShaderProgramm(SHADER_TYPE type, const char* fileName);
     34  bool loadShaderProgramm(SHADER_TYPE type, const std::string& fileName);
    3535  void activateShader();
    3636  static void deactivateShader();
    3737  void deleteProgram(SHADER_TYPE type);
    3838
    39   char* fileRead(const char* fileName);
    40   std::vector<char*>* fileReadArray(const char* fileName);
     39  char* fileRead(const std::string& fileName);
     40  std::vector<char*>* fileReadArray(const std::string& fileName);
    4141
    4242  static bool checkShaderAbility();
     
    5454
    5555 private:
    56    char*                  fragmentShaderFile;
    57    char*                  vertexShaderFile;
     56   std::string            fragmentShaderFile;
     57   std::string            vertexShaderFile;
    5858   GLhandleARB            shaderProgram;
    5959   GLhandleARB            vertexShader;
  • branches/std/src/lib/graphics/text_engine/font.cc

    r6609 r7203  
    3737 * @param fontSize the Size of the Font in Pixels
    3838 */
    39 Font::Font(const char* fontFile, unsigned int renderSize)
     39Font::Font(const std::string& fontFile, unsigned int renderSize)
    4040{
    4141  this->init();
     
    4444  this->setStyle("c");
    4545
    46   if (fontFile != NULL)
     46  if (!fontFile.empty())
    4747    this->loadFontFromTTF(fontFile);
    4848}
     
    5252 * @param imageFile the ImageFile to load the Font From.
    5353 */
    54 Font::Font(const char* imageFile)
     54Font::Font(const std::string& imageFile)
    5555{
    5656  this->init();
     
    5858  //  this->setSize(fontSize);
    5959  SDL_Surface* image = NULL;
    60   if (imageFile != NULL)
    61     image = IMG_Load(imageFile);
     60  if (!imageFile.empty())
     61    image = IMG_Load(imageFile.c_str());
    6262  else
    6363    return;
     
    6868  }
    6969  else
    70     PRINTF(1)("loading from surface %s failed: %s\n", imageFile, IMG_GetError());
     70    PRINTF(1)("loading from surface %s failed: %s\n", imageFile.c_str(), IMG_GetError());
    7171}
    7272
     
    114114
    115115  //! @todo check if we really do not need to delete the fastTextureID here.
    116 //   if (this->fastTextureID != 0)
    117 //     if(glIsTexture(this->fastTextureID))
    118 //       glDeleteTextures(1, &this->fastTextureID);
     116  //   if (this->fastTextureID != 0)
     117  //     if(glIsTexture(this->fastTextureID))
     118  //       glDeleteTextures(1, &this->fastTextureID);
    119119
    120120  // erease this font out of the memory.
     
    140140 * @returns true if loaded, false if something went wrong, or if a font was loaded before.
    141141 */
    142 bool Font::loadFontFromTTF(const char* fontFile)
     142bool Font::loadFontFromTTF(const std::string& fontFile)
    143143{
    144144  // checking for existent Font.
     
    222222 *   i: italic, b: bold, u, underline
    223223 */
    224 void Font::setStyle(const char* renderStyle)
     224void Font::setStyle(const std::string& renderStyle)
    225225{
    226226  this->renderStyle = TTF_STYLE_NORMAL;
    227227
    228   for (int i = 0; i < strlen(renderStyle); i++)
    229     if (strncmp(renderStyle+i, "b", 1) == 0)
     228  for (int i = 0; i < renderStyle.size(); i++)
     229  {
     230    if (renderStyle[i] == 'b')
    230231      this->renderStyle |= TTF_STYLE_BOLD;
    231   else if (strncmp(renderStyle+i, "i", 1) == 0)
    232     this->renderStyle |= TTF_STYLE_ITALIC;
    233   else if (strncmp(renderStyle+i, "u", 1) == 0)
    234     this->renderStyle |= TTF_STYLE_UNDERLINE;
    235 
     232    else if (renderStyle[i] == 'i')
     233      this->renderStyle |= TTF_STYLE_ITALIC;
     234    else if (renderStyle[i] == 'u')
     235      this->renderStyle |= TTF_STYLE_UNDERLINE;
     236  }
    236237  if (likely(this->fontTTF != NULL))
    237238    TTF_SetFontStyle(this->fontTTF, this->renderStyle);
    238 //  else
    239 //    PRINTF(2)("Font was not initialized, please do so before setting the Font-Style.\n");
     239  //  else
     240  //    PRINTF(2)("Font was not initialized, please do so before setting the Font-Style.\n");
    240241}
    241242
     
    247248 * @param fileName the File to write the image into.
    248249 */
    249 void Font::createAsciiImage(const char* fileName, unsigned int size) const
     250void Font::createAsciiImage(const std::string& fileName, unsigned int size) const
    250251{
    251252  if (this->fontTTF == NULL)
     
    258259  SDL_Rect tmpRect; // this represents a Rectangle for blitting.
    259260  SDL_Surface* tmpSurf =  SDL_CreateRGBSurface(SDL_SWSURFACE,
    260                                                height*size, height*size,
    261                                                32,
     261                          height*size, height*size,
     262                          32,
    262263#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
    263                                                0x000000FF,
    264                                                0x0000FF00,
    265                                                0x00FF0000,
    266                                                0xFF000000
     264                          0x000000FF,
     265                          0x0000FF00,
     266                          0x00FF0000,
     267                          0xFF000000
    267268#else
    268                                                0xFF000000,
    269                                                0x00FF0000,
    270                                                0x0000FF00,
    271                                                0x000000FF
     269                          0xFF000000,
     270                          0x00FF0000,
     271                          0x0000FF00,
     272                          0x000000FF
    272273#endif
    273274                                              );
     
    299300    }
    300301  }
    301   SDL_SaveBMP(tmpSurf, fileName);
     302  SDL_SaveBMP(tmpSurf, fileName.c_str());
    302303  SDL_FreeSurface(tmpSurf);
    303304}
     
    409410
    410411  this->initGlyphs(32, numberOfGlyphs);
    411 //  this->glyphArray[32]->width = .5f; //!< @todo find out the real size of a Space
     412  //  this->glyphArray[32]->width = .5f; //!< @todo find out the real size of a Space
    412413
    413414  int rectSize = this->findOptimalFastTextureSize();
     
    418419  SDL_Rect tmpRect; // this represents a Rectangle for blitting.
    419420  SDL_Surface* tmpSurf =  SDL_CreateRGBSurface(SDL_SWSURFACE,
    420                                                rectSize, rectSize,
    421                                                32,
     421                          rectSize, rectSize,
     422                          32,
    422423#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
    423                                                0x000000FF,
    424                                                0x0000FF00,
    425                                                0x00FF0000,
    426                                                0xFF000000
     424                          0x000000FF,
     425                          0x0000FF00,
     426                          0x00FF0000,
     427                          0xFF000000
    427428#else
    428                                                0xFF000000,
    429                                                0x00FF0000,
    430                                                0x0000FF00,
    431                                                0x000000FF
     429                          0xFF000000,
     430                          0x00FF0000,
     431                          0x0000FF00,
     432                          0x000000FF
    432433#endif
    433434                                              );
     
    457458        break;
    458459      }
    459           // reading in the new Glyph
     460      // reading in the new Glyph
    460461      if (likely(this->fontTTF != NULL))
    461462      {
     
    521522  for (int i = from; i <= lastGlyph; i++)
    522523  {
    523       // setting up all the Glyphs we like.
     524    // setting up all the Glyphs we like.
    524525    glyphArray[i] = getGlyphMetrics(i);
    525526  }
     
    555556      if((tmpGlyph = this->glyphArray[i]) != NULL)
    556557      {
    557               // getting the height of the highest Glyph in the Line.
     558        // getting the height of the highest Glyph in the Line.
    558559        if (tmpGlyph->height*this->renderSize > maxLineHeight)
    559560          maxLineHeight = (int)(tmpGlyph->height*this->renderSize);
     
    563564          x = 0;
    564565          y = y + maxLineHeight;
    565                   //maxLineHeight = 0;
     566          //maxLineHeight = 0;
    566567        }
    567568        if (y + maxLineHeight + 1 > size)
     
    592593  if(style==TTF_STYLE_NORMAL)
    593594    PRINTF(0)(" normal");
    594   else {
     595  else
     596  {
    595597    if(style&TTF_STYLE_BOLD)
    596598      PRINTF(0)(" bold");
  • branches/std/src/lib/graphics/text_engine/font.h

    r6609 r7203  
    5555{
    5656  public:
    57     Font(const char* fontFile,
     57    Font(const std::string& fontFile,
    5858         unsigned int renderSize);
    59     Font(const char* imageFile);
     59    Font(const std::string& imageFile);
    6060    Font(char** xpmArray);
    6161    virtual ~Font();
     
    6464
    6565  //  font
    66     bool loadFontFromTTF(const char* fontFile);
     66    bool loadFontFromTTF(const std::string& fontFile);
    6767    bool loadFontFromSDL_Surface(SDL_Surface* surface);
    6868
    69     void setStyle(const char* renderStyle);
     69    void setStyle(const std::string& renderStyle);
    7070
    7171    /** @returns a Pointer to the Array of Glyphs */
     
    7878    inline static Font* getDefaultFont() { if (Font::defaultFont == NULL) initDefaultFont(); return Font::defaultFont; };
    7979
    80     void createAsciiImage(const char* fileName, unsigned int size) const;
     80    void createAsciiImage(const std::string& fileName, unsigned int size) const;
    8181    static void initDefaultFont();
    8282    static void removeDefaultFont();
  • branches/std/src/lib/gui/gtk_gui/gui_exec.cc

    r7193 r7203  
    4747  Frame* execFrame;            //!< The Frame that holds the ExecutionOptions.
    4848
    49   this->confFile = NULL;
    50   this->confDir = NULL;
     49  this->confFile = "";
     50  this->confDir = "";
    5151
    5252  execFrame = new Frame("Execute-Tags:");
     
    137137GuiExec::~GuiExec()
    138138{
    139   if(this->confFile)
    140     delete []this->confFile;
    141   if(this->confDir)
    142     delete []this->confDir;
    143139}
    144140
     
    156152  //! @todo F** Windows-support
    157153#ifndef __WIN32__
    158   mkdir(this->confDir, 0755);
     154  mkdir(this->confDir.c_str(), 0755);
    159155#else /* __WiN32__ */
    160   mkdir(this->confDir);
     156  mkdir(this->confDir.c_str());
    161157#endif /* __WIN32__ */
    162158}
     
    170166void GuiExec::setConfFile(const char* fileName)
    171167{
    172   if (!this->confDir)
     168  if (!this->confDir.empty())
    173169    this->setConfDir("~/");
    174   this->confFile = new char[strlen(this->confDir)+strlen(fileName)+2];
    175   sprintf(this->confFile, "%s/%s", this->confDir, fileName);
     170  this->confFile = this->confDir + "/" + fileName;
    176171  PRINTF(5)("ConfigurationFile is %s.\n", this->confFile);
    177172}
     
    182177const char* GuiExec::getConfigFile() const
    183178{
    184   return this->confFile;
     179  return this->confFile.c_str();
    185180}
    186181
     
    204199  IniParser iniParser;
    205200  this->writeFileText(widget, &iniParser, 0);
    206   char* fileName = ResourceManager::homeDirCheck(confFile);
     201  std::string fileName = ResourceManager::homeDirCheck(confFile);
    207202  iniParser.writeFile(fileName);
    208   delete[] fileName;
    209203}
    210204
     
    259253void GuiExec::readFromFile(Widget* widget)
    260254{
    261   char* fileName = ResourceManager::homeDirCheck(confFile);
     255  std::string fileName = ResourceManager::homeDirCheck(confFile);
    262256  IniParser iniParser(fileName);
    263   delete[] fileName;
    264257  if (!iniParser.isOpen())
    265258    return;
     
    267260  iniParser.firstSection();
    268261  Widget* groupWidget = widget;
    269   const char* groupName;
    270   const char* widgetName;
     262  std::string groupName;
     263  std::string widgetName;
    271264  VarInfo varInfo;
    272   while (groupName = iniParser.getCurrentSection())
     265  while ((groupName = iniParser.getCurrentSection()) != "")
    273266  {
    274     printf("GROUP:::%s\n", groupName);
    275     if((groupWidget = locateGroup(widget, groupName, 1))==NULL)
     267    PRINTF(4)("GROUP:::%s\n", groupName.c_str());
     268    if((groupWidget = locateGroup(widget, groupName.c_str(), 1))==NULL)
    276269      {
    277         PRINTF(2)("!!There is no group called %s in this GUI.\n First best Widget will get the Infos assigned.\n Config-File will be updated in next Save\n", groupName);
     270        PRINTF(2)("!!There is no group called %s in this GUI.\n First best Widget will get the Infos assigned.\n Config-File will be updated in next Save\n", groupName.c_str());
    278271        groupWidget = widget;
    279272        continue;
     
    282275      PRINT(4)("Group %s located.\n", static_cast<Packer*>(groupWidget)->groupName);
    283276
    284     const char* entryName;
     277    std::string entryName;
    285278    iniParser.firstVar();
    286     while(entryName = iniParser.getCurrentName())
    287     {
    288       PRINTF(4)("ENTRY:::%s = %s\n", entryName, iniParser.getCurrentValue());
    289       varInfo.variableName = entryName;
    290       varInfo.variableValue = iniParser.getCurrentValue();
     279    while((entryName = iniParser.getCurrentName()) != "")
     280    {
     281      PRINTF(4)("ENTRY:::%s = %s\n", entryName.c_str(), iniParser.getCurrentValue().c_str());
     282      varInfo.variableName = entryName.c_str();
     283      varInfo.variableValue = iniParser.getCurrentValue().c_str();
    291284      groupWidget->walkThrough(this->readFileText, &varInfo, 0);
    292285      iniParser.nextVar();
  • branches/std/src/lib/gui/gtk_gui/gui_exec.h

    r6981 r7203  
    1111#include "gui_gtk.h"
    1212
     13#include <string>
     14
    1315class Widget;
    1416class CheckButton;
     
    2224  CheckButton* saveSettings;   //!< A CheckBox for if the Options should be saved.
    2325
    24   char* confDir;               //!< The directory of the orxonox-configuration-files.
    25   char* confFile;              //!< The name of the .orxonox.conf(ig)-file.
     26  std::string confDir;         //!< The directory of the orxonox-configuration-files.
     27  std::string confFile;        //!< The name of the .orxonox.conf(ig)-file.
    2628
    2729  //! A struct that holds informations about variables.
     
    5860struct HashTable
    5961{
    60   char* name;           //!< name of the entry
    61   char* value;          //!< value of the entry
     62  std::string name;           //!< name of the entry
     63  std::string value;          //!< value of the entry
    6264  HashTable* next;      //!< pointer to the next entry
    6365};
  • branches/std/src/lib/lang/base_object.cc

    r7193 r7203  
    9595 * @brief set the name of the Object
    9696 */
    97 void BaseObject::setName (const char* objectName)
     97void BaseObject::setName (const std::string& objectName)
    9898{
    9999  if (this->objectName)
    100100    delete[] this->objectName;
    101   if (objectName != NULL)
    102   {
    103     this->objectName = new char[strlen(objectName)+1];
    104     strcpy(this->objectName, objectName);
     101  if (!objectName.empty())
     102  {
     103    this->objectName = new char[objectName.size()+1];
     104    strcpy(this->objectName, objectName.c_str());
    105105  }
    106106  else
  • branches/std/src/lib/lang/base_object.h

    r6587 r7203  
    1616#endif
    1717
     18#include <string>
    1819#include "stdincl.h"
    1920
     
    3031
    3132  virtual void loadParams(const TiXmlElement* root);
    32   void setName (const char* newName);
     33  void setName (const std::string& newName);
    3334  /** returns the Name of this Object */
    3435  inline const char* getName ()const { return this->objectName; };
  • branches/std/src/lib/parser/ini_parser/ini_parser.cc

    r5953 r7203  
    4040 * @param fileName: the path and name of the file to parse
    4141 */
    42 IniParser::IniParser (const char* fileName)
    43 {
    44   this->fileName = NULL;
    45   this->comment = NULL;
    46 
    47   if (fileName != NULL)
     42IniParser::IniParser (const std::string& fileName)
     43{
     44  this->fileName = "";
     45  this->comment = "";
     46
     47  if (!fileName.empty())
    4848    this->readFile(fileName);
    4949}
     
    5959}
    6060
     61const std::string IniParser::emptyString = "";
     62
    6163
    6264/**
     
    6870  while(!this->sections.empty())
    6971  {
    70      IniSection section = this->sections.front();
     72    IniSection section = this->sections.front();
    7173
    7274    // in all entries of the sections
     
    7577      // delete all strings of entries.
    7678      IniEntry entry = section.entries.front();
    77       delete[] entry.name;
    78       delete[] entry.value;
    79       delete[] entry.comment;
    8079      section.entries.pop_front();
    8180    }
    8281    // delete all Sections
    83     delete[] section.name;
    84     delete[] section.comment;
    8582    this->sections.pop_front();
    8683  }
     
    9592 * If fileName is NULL the new Name will be set to NULL too.
    9693 */
    97 void IniParser::setFileName(const char* fileName)
    98 {
    99   if (this->fileName != NULL)
    100     delete[] this->fileName;
    101   if  (this->comment != NULL)
    102     delete[] this->comment;
    103   this->comment = NULL;
    104 
    105   if (fileName != NULL)
    106   {
    107     this->fileName = new char[strlen(fileName)+1];
    108     strcpy(this->fileName, fileName);
    109   }
    110   else
    111     this->fileName = NULL;
     94void IniParser::setFileName(const std::string& fileName)
     95{
     96  this->comment = "";
     97
     98  if (!fileName.empty())
     99    this->fileName = fileName;
     100  else
     101    this->fileName = "";
    112102}
    113103
     
    121111 * and the new one will be opened.
    122112 */
    123 bool IniParser::readFile(const char* fileName)
     113bool IniParser::readFile(const std::string& fileName)
    124114{
    125115  FILE*    stream;           //< The stream we use to read the file.
    126116  int      lineCount = 0;    //< The Count of lines.
    127117
    128   if (this->fileName != NULL)
     118  if (!this->fileName.empty())
    129119    this->deleteSections();
    130   if( fileName == NULL)
    131     return false;
    132 
    133   if( (stream = fopen (fileName, "r")) == NULL)
    134   {
    135     PRINTF(1)("IniParser could not open %s\n", fileName);
     120  if( fileName.empty())
     121    return false;
     122
     123  if( (stream = fopen (fileName.c_str(), "r")) == NULL)
     124  {
     125    PRINTF(1)("IniParser could not open %s\n", fileName.c_str());
    136126    return false;
    137127  }
     
    191181          continue;
    192182        }
    193         if( ptr == lineBegin) {
     183        if( ptr == lineBegin)
     184        {
    194185          lineCount++;
    195186          continue;
     
    228219 * @return true on success false otherwise
    229220 */
    230 bool IniParser::writeFile(const char* fileName) const
     221bool IniParser::writeFile(const std::string& fileName) const
    231222{
    232223  FILE*    stream;           //!< The stream we use to read the file.
    233   if( fileName == NULL && (fileName = this->fileName) == NULL )
    234     return false;
    235 
    236   if( (stream = fopen (fileName, "w")) == NULL)
    237   {
    238     PRINTF(1)("IniParser could not open %s\n", fileName);
    239     return false;
    240   }
    241   else
    242   {
    243     if (this->comment != NULL)
    244       fprintf(stream, "%s\n\n", this->comment);
     224  if( fileName.empty())
     225    return false;
     226
     227  if( (stream = fopen (fileName.c_str(), "w")) == NULL)
     228  {
     229    PRINTF(1)("IniParser could not open %s\n", fileName.c_str());
     230    return false;
     231  }
     232  else
     233  {
     234    if (!this->comment.empty())
     235      fprintf(stream, "%s\n\n", this->comment.c_str());
    245236
    246237    std::list<IniSection>::const_iterator section;
    247238    for (section = this->sections.begin(); section != this->sections.end(); section++)
     239    {
     240      if (!(*section).comment.empty())
     241        fprintf(stream, "%s", (*section).comment.c_str());
     242      fprintf(stream, "\n [%s]\n", (*section).name.c_str());
     243
     244      std::list<IniEntry>::const_iterator entry;
     245      for (entry = (*section).entries.begin(); entry != (*section).entries.end(); entry++)
    248246      {
    249         if ((*section).comment != NULL)
    250           fprintf(stream, "%s", (*section).comment);
    251         fprintf(stream, "\n [%s]\n", (*section).name);
    252 
    253         std::list<IniEntry>::const_iterator entry;
    254         for (entry = (*section).entries.begin(); entry != (*section).entries.end(); entry++)
    255         {
    256           if ((*entry).comment != NULL)
    257             fprintf(stream, "%s", (*entry).comment);
    258           fprintf(stream, "   %s = %s\n", (*entry).name, (*entry).value);
    259          }
     247        if (!(*entry).comment.empty())
     248          fprintf(stream, "%s", (*entry).comment.c_str());
     249        fprintf(stream, "   %s = %s\n", (*entry).name.c_str(), (*entry).value.c_str());
    260250      }
     251    }
    261252  }
    262253  fclose(stream);
    263254}
    264255
    265 void IniParser::setFileComment(const char* fileComment)
    266 {
    267   if (this->comment != NULL)
    268     delete this->comment;
    269 
    270   if (fileComment != NULL)
    271   {
    272     this->comment = new char[strlen(fileComment)+1];
    273     strcpy(this->comment, fileComment);
    274   }
    275   else
    276     this->comment = NULL;
    277 }
    278 
     256void IniParser::setFileComment(const std::string& fileComment)
     257{
     258  this->comment = fileComment;
     259}
    279260
    280261/**
     
    284265 * @return true on success... there is only success or segfault :)
    285266 */
    286 bool IniParser::addSection(const char* sectionName)
    287 {
    288   if (sectionName == NULL)
     267bool IniParser::addSection(const std::string& sectionName)
     268{
     269  if (sectionName.empty())
    289270    return false;
    290271  this->sections.push_back(IniSection());
    291   this->sections.back().comment = NULL;
    292   this->sections.back().name = new char[strlen(sectionName)+1];
    293   strcpy(this->sections.back().name, sectionName);
     272  this->sections.back().comment = "";
     273  this->sections.back().name = sectionName;
    294274
    295275  this->currentSection = --this->sections.end();
    296276  if (!this->sections.empty())
    297       this->currentEntry = (*this->currentSection).entries.begin();
     277    this->currentEntry = (*this->currentSection).entries.begin();
    298278  PRINTF(5)("Added Section %s\n", sectionName);
    299279  return true;
     
    306286 * @return true on success or false if the section could not be found
    307287 */
    308 bool IniParser::getSection(const char* sectionName)
     288bool IniParser::getSection(const std::string& sectionName)
    309289{
    310290  this->currentSection = this->getSectionIT(sectionName);
     
    321301 *
    322302 */
    323 void IniParser::setSectionComment(const char* comment, const char* sectionName)
     303void IniParser::setSectionComment(const std::string& comment, const std::string& sectionName)
    324304{
    325305  std::list<IniSection>::iterator section = this->getSectionIT(sectionName);
     
    327307    return;
    328308
    329   if ((*section).comment != NULL)
    330     delete[] (*section).comment;
    331   if (comment != NULL)
    332   {
    333     (*section).comment = new char[strlen (comment)+1];
    334     strcpy((*section).comment, comment);
    335   }
    336   else
    337     (*section).comment = NULL;
     309  (*section).comment = comment;
    338310}
    339311
     
    342314 * @returns the Comment, or NULL on error.
    343315 */
    344 const char* IniParser::getSectionComment(const char* sectionName) const
     316const std::string& IniParser::getSectionComment(const std::string& sectionName) const
    345317{
    346318  std::list<IniSection>::const_iterator section = this->getSectionIT(sectionName);
     
    348320    return (*section).comment;
    349321  else
    350     return NULL;
     322    return IniParser::emptyString;
    351323}
    352324
     
    367339 * @returns the name of the section if found, NULL otherwise
    368340 */
    369 const char* IniParser::nextSection()
     341const std::string& IniParser::nextSection()
    370342{
    371343  if (this->currentSection == this->sections.end())
    372     return NULL;
     344    return IniParser::emptyString;
    373345
    374346  this->currentSection++;
    375347
    376348  if (this->currentSection != this->sections.end())
    377     {
    378       this->currentEntry = (*this->currentSection).entries.begin();
    379       return this->currentSection->name;
    380     }
    381   else
    382     return NULL;
     349  {
     350    this->currentEntry = (*this->currentSection).entries.begin();
     351    return this->currentSection->name;
     352  }
     353  else
     354    return IniParser::emptyString;
    383355}
    384356
     
    393365 * @return true if everything is ok false on error
    394366 */
    395 bool IniParser::addVar(const char* entryName, const char* value, const char* sectionName)
     367bool IniParser::addVar(const std::string& entryName, const std::string& value, const std::string& sectionName)
    396368{
    397369  std::list<IniSection>::iterator section;
    398370
    399   if (sectionName != NULL)
     371  if (!sectionName.empty())
    400372  {
    401373    for (section = this->sections.begin(); section != this->sections.end(); section++)
    402       if (!strcmp((*section).name, sectionName))
     374      if ((*section).name == sectionName)
    403375        break;
    404376  }
     
    411383  if (section == this->sections.end())
    412384  {
    413     PRINTF(2)("section '%s' not found for value '%s'\n", sectionName, entryName);
     385    PRINTF(2)("section '%s' not found for value '%s'\n", sectionName.c_str(), entryName.c_str());
    414386    return false;
    415387  }
     
    417389  {
    418390    (*section).entries.push_back(IniEntry());
    419     (*section).entries.back().comment = NULL;
    420     (*section).entries.back().name = new char[strlen(entryName)+1];
    421     strcpy((*section).entries.back().name, entryName);
    422     (*section).entries.back().value = new char[strlen(value)+1];
    423     strcpy((*section).entries.back().value, value);
     391    (*section).entries.back().comment = "";
     392    (*section).entries.back().name = entryName;
     393    (*section).entries.back().value = value;
    424394    PRINTF(5)("Added Entry %s with Value '%s' to Section %s\n",
    425               (*section).entries.back().name,
    426               (*section).entries.back().value,
    427               (*section).name);
     395              (*section).entries.back().name.c_str(),
     396              (*section).entries.back().value.c_str(),
     397              (*section).name.c_str());
    428398    this->currentEntry = --(*section).entries.end();
    429399    return true;
     
    442412 * lead to unwanted behaviour.
    443413*/
    444 const char* IniParser::getVar(const char* entryName, const char* sectionName, const char* defaultValue) const
    445 {
    446   if (this->fileName != NULL)
     414const std::string& IniParser::getVar(const std::string& entryName, const std::string& sectionName, const std::string& defaultValue) const
     415{
     416  if (!this->fileName.empty())
    447417  {
    448418    std::list<IniEntry>::const_iterator entry = this->getEntryIT(entryName, sectionName);
    449     if (entry != NULL &&  !strcmp((*entry).name, entryName))
     419    if (entry != NULL &&  (*entry).name == entryName)
    450420      return (*entry).value;
    451     PRINTF(2)("Entry '%s' in section '%s' not found.\n", entryName, sectionName);
     421    PRINTF(2)("Entry '%s' in section '%s' not found.\n", entryName.c_str(), sectionName.c_str());
    452422
    453423  }
     
    456426
    457427  return defaultValue;
    458 
    459428}
    460429
     
    465434 * @param sectionName the Name of the Section
    466435 */
    467 void IniParser::setEntryComment(const char* comment, const char* entryName, const char* sectionName)
     436void IniParser::setEntryComment(const std::string& comment, const std::string& entryName, const std::string& sectionName)
    468437{
    469438  std::list<IniEntry>::iterator entry = this->getEntryIT(entryName, sectionName);
    470 
    471   if ((*entry).comment != NULL)
    472     delete[] (*entry).comment;
    473   if (comment != NULL)
    474   {
    475     (*entry).comment = new char[strlen (comment)+1];
    476     strcpy((*entry).comment, comment);
    477   }
    478   else
    479     (*entry).comment = NULL;
    480 
    481 
     439  (*entry).comment = comment;
    482440}
    483441
     
    487445 * @returns the queried Comment.
    488446 */
    489 const char* IniParser::getEntryComment(const char* entryName, const char* sectionName) const
     447const std::string& IniParser::getEntryComment(const std::string& entryName, const std::string& sectionName) const
    490448{
    491449  std::list<IniEntry>::const_iterator entry = this->getEntryIT(entryName, sectionName);
     
    501459{
    502460  if (!this->sections.empty() &&
    503        this->currentSection != this->sections.end())
     461      this->currentSection != this->sections.end())
    504462    this->currentEntry = (*this->currentSection).entries.begin();
    505463}
     
    530488 * @returns the name of the Current selected Section
    531489 */
    532 const char* IniParser::getCurrentSection() const
     490const std::string& IniParser::getCurrentSection() const
    533491{
    534492  if (!this->sections.empty() &&
     
    536494    return this->currentSection->name;
    537495  else
    538     return NULL;
    539  }
     496    return IniParser::emptyString ;
     497}
    540498
    541499
     
    543501 * @returns the current entries Name, or NULL if we havn't selected a Entry
    544502 */
    545 const char* IniParser::getCurrentName() const
    546 {
    547  if (!this->sections.empty() &&
    548      this->currentSection != this->sections.end() &&
    549      this->currentEntry != (*this->currentSection).entries.end())
    550    return (*this->currentEntry).name;
    551  else
    552    return NULL;
     503const std::string& IniParser::getCurrentName() const
     504{
     505  if (!this->sections.empty() &&
     506      this->currentSection != this->sections.end() &&
     507      this->currentEntry != (*this->currentSection).entries.end())
     508    return (*this->currentEntry).name;
     509  else
     510    return emptyString;
    553511}
    554512
     
    556514 * @returns the current entries Value, or NULL if we havn't selected a Entry
    557515 */
    558 const char* IniParser::getCurrentValue() const
     516const std::string& IniParser::getCurrentValue() const
    559517{
    560518  if (!this->sections.empty() &&
     
    563521    return (*this->currentEntry).value;
    564522  else
    565     return NULL;
     523    return IniParser::emptyString;
    566524}
    567525
     
    571529 * @param sectionName the Name of the Section to get the Iterator from
    572530 */
    573 std::list<IniParser::IniSection>::const_iterator IniParser::getSectionIT(const char* sectionName) const
     531std::list<IniParser::IniSection>::const_iterator IniParser::getSectionIT(const std::string& sectionName) const
    574532{
    575533  std::list<IniSection>::const_iterator section = this->currentSection;
    576   if (sectionName == NULL)
     534  if (sectionName.empty())
    577535    return this->currentSection;
    578536  else
    579537    for (section = this->sections.begin(); section != this->sections.end(); section++)
    580       if (!strcmp((*section).name, sectionName))
     538      if ((*section).name == sectionName)
    581539        break;
    582540  return section;
     
    588546 * @param sectionName the Name of the Section to get the Iterator from
    589547 */
    590 std::list<IniParser::IniSection>::iterator IniParser::getSectionIT(const char* sectionName)
     548std::list<IniParser::IniSection>::iterator IniParser::getSectionIT(const std::string& sectionName)
    591549{
    592550  std::list<IniSection>::iterator section = this->currentSection;
    593   if (sectionName == NULL)
     551  if (sectionName.empty())
    594552    return this->currentSection;
    595553  else
    596554    for (section = this->sections.begin(); section != this->sections.end(); section++)
    597       if (!strcmp((*section).name, sectionName))
     555      if ((*section).name == sectionName)
    598556        break;
    599557  return section;
     
    606564 * @param sectionName the Name of the Section to get the Iterator from
    607565 */
    608 std::list<IniParser::IniEntry>::const_iterator IniParser::getEntryIT(const char* entryName, const char* sectionName) const
    609 {
    610   if (entryName == NULL)
     566std::list<IniParser::IniEntry>::const_iterator IniParser::getEntryIT(const std::string& entryName, const std::string& sectionName) const
     567{
     568  if (entryName.empty())
    611569    return this->currentEntry;
    612570  std::list<IniSection>::const_iterator section = this->getSectionIT(sectionName);
     
    615573  if (section != this->sections.end())
    616574    for (entry = (*section).entries.begin(); entry != (*section).entries.end(); entry++)
    617       if (!strcmp((*entry).name, entryName))
     575      if ((*entry).name == entryName)
    618576        break;
    619577  if (entry == (*section).entries.end())
     
    629587 * @param sectionName the Name of the Section to get the Iterator from
    630588 */
    631 std::list<IniParser::IniEntry>::iterator IniParser::getEntryIT(const char* entryName, const char* sectionName)
    632 {
    633   if (entryName == NULL)
     589std::list<IniParser::IniEntry>::iterator IniParser::getEntryIT(const std::string& entryName, const std::string& sectionName)
     590{
     591  if (entryName.empty())
    634592    return this->currentEntry;
    635593  std::list<IniSection>::iterator section = this->getSectionIT(sectionName);
     
    638596  if (section != this->sections.end())
    639597    for (entry = (*section).entries.begin(); entry != (*section).entries.end(); entry++)
    640       if (!strcmp((*entry).name, entryName))
     598      if ((*entry).name == entryName)
    641599        break;
    642600  if (entry == (*section).entries.end())
     
    652610void IniParser::setFileComment()
    653611{
    654   if (this->comment != NULL)
    655     delete[] this->comment;
    656 
    657   if (this->commentList.empty()) {
    658     this->comment = NULL;
     612  if (this->commentList.empty())
     613  {
     614    this->comment = "";
    659615    return;
    660616  }
    661617
    662   unsigned int stringLength = 1;
    663618  std::list<char*>::iterator comment;
    664   for (comment = this->commentList.begin(); comment != this->commentList.end(); comment++)
    665     stringLength += strlen((*comment)) +1;
    666 
    667   this->comment = new char[stringLength];
    668   this->comment[0] = '\0';
     619
    669620  while (!this->commentList.empty())
    670621  {
    671     if (*this->comment != '\0')
    672       strcat(this->comment, "\n");
    673     strcat(this->comment, this->commentList.front());
    674     delete[] this->commentList.front();
     622    if (this->comment[0] != '\0')
     623      this->comment += "\n";
     624    this->comment += this->commentList.front();
    675625    this->commentList.pop_front();
    676626  }
     
    682632void IniParser::setSectionComment()
    683633{
    684   if ((*this->currentSection).comment != NULL)
    685     delete[] (*this->currentSection).comment;
    686 
    687   if (this->commentList.empty()) {
    688     (*this->currentSection).comment = NULL;
     634  (*this->currentSection).comment = "";
     635
     636  if (this->commentList.empty())
    689637    return;
    690   }
    691 
    692   unsigned int stringLength = 1;
    693   std::list<char*>::iterator comment;
    694   for (comment = this->commentList.begin(); comment != this->commentList.end(); comment++)
    695     stringLength += strlen((*comment)) +1;
    696 
    697   (*this->currentSection).comment = new char[stringLength];
    698   (*this->currentSection).comment[0] = '\0';
     638
    699639  while (!this->commentList.empty())
    700640  {
    701     if (*(*this->currentSection).comment != '\0')
    702       strcat((*this->currentSection).comment, "\n");
    703     strcat((*this->currentSection).comment, this->commentList.front());
    704     delete[] this->commentList.front();
     641    if ((*this->currentSection).comment[0] != '\0')
     642      (*this->currentSection).comment += "\n";
     643    (*this->currentSection).comment += this->commentList.front();
    705644    this->commentList.pop_front();
    706645  }
     
    712651void IniParser::setEntryComment()
    713652{
    714   if ((*this->currentEntry).comment != NULL)
    715     delete[] (*this->currentEntry).comment;
    716 
    717   if (this->commentList.empty()) {
    718     (*this->currentEntry).comment = NULL;
     653  (*this->currentEntry).comment = "";
     654  if (this->commentList.empty())
    719655    return;
    720   }
    721 
    722   unsigned int stringLength = 1;
    723   std::list<char*>::iterator comment;
    724   for (comment = this->commentList.begin(); comment != this->commentList.end(); comment++)
    725     stringLength += strlen((*comment)) +1;
    726 
    727   (*this->currentEntry).comment = new char[stringLength];
    728   (*this->currentEntry).comment[0] = '\0';
     656
    729657  while (!this->commentList.empty())
    730658  {
    731     if (*(*this->currentEntry).comment != '\0')
    732       strcat((*this->currentEntry).comment, "\n");
    733     strcat((*this->currentEntry).comment, this->commentList.front());
    734     delete[] this->commentList.front();
     659    if ((*this->currentEntry).comment[0] != '\0')
     660      (*this->currentEntry).comment += "\n";
     661    (*this->currentEntry).comment += this->commentList.front();
    735662    this->commentList.pop_front();
    736663  }
    737 
    738664}
    739665
     
    744670void IniParser::debug() const
    745671{
    746   PRINTF(0)("Iniparser %s - debug\n", this->fileName);
    747   if (this->comment != NULL)
    748     PRINTF(0)("FileComment:\n %s\n\n", this->comment);
    749 
    750   if (this->fileName != NULL)
     672  PRINTF(0)("Iniparser %s - debug\n", this->fileName.c_str());
     673  if (!this->comment.empty())
     674    PRINTF(0)("FileComment:\n %s\n\n", this->comment.c_str());
     675
     676  if (!this->fileName.empty())
    751677  {
    752678    std::list<IniSection>::const_iterator section;
    753679    for (section = this->sections.begin(); section != this->sections.end(); section++)
    754680    {
    755       if ((*section).comment != NULL)
    756         PRINTF(0)(" %s\n", (*section).comment);
    757       PRINTF(0)(" [%s]\n", (*section).name);
     681      if (!(*section).comment.empty())
     682        PRINTF(0)(" %s\n", (*section).comment.c_str());
     683      PRINTF(0)(" [%s]\n", (*section).name.c_str());
    758684
    759685      std::list<IniEntry>::const_iterator entry;
    760686      for (entry = (*section).entries.begin(); entry != (*section).entries.end(); entry++)
    761687      {
    762         if ((*entry).comment != NULL)
    763           PRINTF(0)(" %s\n", (*entry).comment);
    764         PRINTF(0)("   '%s' -> '%s'\n", (*entry).name, (*entry).value);
     688        if (!(*entry).comment.empty())
     689          PRINTF(0)(" %s\n", (*entry).comment.c_str());
     690        PRINTF(0)("   '%s' -> '%s'\n", (*entry).name.c_str(), (*entry).value.c_str());
    765691      }
    766692    }
  • branches/std/src/lib/parser/ini_parser/ini_parser.h

    r6981 r7203  
    1515
    1616#include <list>
     17#include <string>
    1718
    1819//! ini-file parser
     
    2728    struct IniEntry
    2829    {
    29       char*               comment;  //!< A Comment that is appendet to the Top of this Entry.
    30       char*               name;     //!< name of a given Entry
    31       char*               value;    //!< value of a given Entry
     30      std::string         comment;  //!< A Comment that is appendet to the Top of this Entry.
     31      std::string         name;     //!< name of a given Entry
     32      std::string         value;    //!< value of a given Entry
    3233    };
    3334
     
    3536    struct IniSection
    3637    {
    37       char*               comment;  //!< A Comment that is appendet to the Top of this Section.
    38       char*               name;     //!< name of a given section
     38      std::string         comment;  //!< A Comment that is appendet to the Top of this Section.
     39      std::string         name;     //!< name of a given section
    3940      std::list<IniEntry> entries;  //!< a list of entries for this section
    4041    };
     
    4243
    4344  public:
    44     IniParser (const char* filename = NULL);
     45    IniParser (const std::string& filename = "");
    4546    virtual ~IniParser ();
    4647
    4748    /** @returns true if the file is opened, false otherwise*/
    48     bool isOpen() const { return (this->fileName != NULL)? true : false; };
     49    bool isOpen() const { return (!this->fileName.empty())? true : false; };
    4950    /** @returns the fileName we have opened. */
    50     const char* getFileName() const { return this->fileName; };
     51    const std::string& getFileName() const { return this->fileName; };
    5152
    52     bool readFile(const char* fileName);
    53     bool writeFile(const char* fileName) const;
     53    bool readFile(const std::string& fileName);
     54    bool writeFile(const std::string& fileName) const;
    5455
    55     void setFileComment(const char* fileComment);
    56     const char* getFileComment() const { return this->comment; };
     56    void setFileComment(const std::string& fileComment);
     57    const std::string& getFileComment() const { return this->comment; };
    5758
    58     bool addSection(const char* sectionName);
    59     bool getSection(const char* sectionName);
    60     void setSectionComment(const char* comment, const char* sectionName);
    61     const char* getSectionComment(const char* sectionNane) const;
     59    bool addSection(const std::string& sectionName);
     60    bool getSection(const std::string& sectionName);
     61    void setSectionComment(const std::string& comment, const std::string& sectionName);
     62    const std::string& getSectionComment(const std::string& sectionNane) const;
    6263
    6364    // iterate through sections with these Functions
    6465    void firstSection();
    65     const char* nextSection();
     66    const std::string& nextSection();
    6667
    6768
    68     bool addVar(const char* entryName, const char* value, const char* sectionName = NULL);
    69     const char* getVar(const char* entryName, const char* sectionName, const char* defaultValue = "") const;
    70     void setEntryComment(const char* comment, const char* entryName, const char* sectionName);
    71     const char* getEntryComment(const char* entryName, const char* sectionName) const;
     69    bool addVar(const std::string& entryName, const std::string& value, const std::string& sectionName = NULL);
     70    const std::string& getVar(const std::string& entryName, const std::string& sectionName, const std::string& defaultValue = "") const;
     71    void setEntryComment(const std::string& comment, const std::string& entryName, const std::string& sectionName);
     72    const std::string& getEntryComment(const std::string& entryName, const std::string& sectionName) const;
    7273
    7374    // iterate Through Variables with these Functions.
     
    7778
    7879    // retrieving functions when iterating.
    79     const char* getCurrentSection() const;
    80     const char* getCurrentName() const;
    81     const char* getCurrentValue() const;
     80    const std::string& getCurrentSection() const;
     81    const std::string& getCurrentName() const;
     82    const std::string& getCurrentValue() const;
    8283
    8384
     
    8889  private:
    8990    void deleteSections();
    90     void setFileName(const char* fileName);
     91    void setFileName(const std::string& fileName);
    9192
    9293    void setFileComment();
     
    9495    void setEntryComment();
    9596
    96     std::list<IniSection>::const_iterator getSectionIT(const char* sectionName) const;
    97     std::list<IniSection>::iterator getSectionIT(const char* sectionName);
     97    std::list<IniSection>::const_iterator getSectionIT(const std::string& sectionName) const;
     98    std::list<IniSection>::iterator getSectionIT(const std::string& sectionName);
    9899
    99     std::list<IniEntry>::const_iterator getEntryIT(const char* entryName, const char* sectionName = NULL) const;
    100     std::list<IniEntry>::iterator getEntryIT(const char* entryName, const char* sectionName = NULL);
     100    std::list<IniEntry>::const_iterator getEntryIT(const std::string& entryName, const std::string& sectionName = NULL) const;
     101    std::list<IniEntry>::iterator getEntryIT(const std::string& entryName, const std::string& sectionName = NULL);
    101102
    102103  private:
    103     char*                            fileName;        //!< The name of the File that was parsed.
    104     char*                            comment;         //!< A Comment for the header of this File.
     104    std::string                      fileName;        //!< The name of the File that was parsed.
     105    std::string                      comment;         //!< A Comment for the header of this File.
    105106    std::list<IniSection>            sections;        //!< a list of all stored Sections of the Parser
    106107    std::list<IniSection>::iterator  currentSection;  //!< the current selected Section
    107108    std::list<IniEntry>::iterator    currentEntry;    //!< the current selected entry (in currentSection)
    108109
    109     std::list<char*>                 commentList;     //!< A list of Comments. (this is for temporary saving of Comments, that are inserted in front of Sections/Entries.)
     110    std::list<std::string>           commentList;     //!< A list of Comments. (this is for temporary saving of Comments, that are inserted in front of Sections/Entries.)
     111
     112
     113    static const std::string         emptyString;
    110114};
    111115
  • branches/std/src/lib/parser/tinyxml/tinyxml.h

    r5819 r7203  
    2626#ifndef TINYXML_INCLUDED
    2727#define TINYXML_INCLUDED
     28
     29#define TIXML_USE_STL
    2830
    2931#ifdef _MSC_VER
     
    8183                #define TIXML_SNSCANF  snscanf
    8284        #endif
    83 #endif 
     85#endif
    8486
    8587class TiXmlDocument;
     
    9698const int TIXML_PATCH_VERSION = 2;
    9799
    98 /*      Internal structure for tracking location of items 
     100/*      Internal structure for tracking location of items
    99101        in the XML file.
    100102*/
     
    110112
    111113// Only used by Attribute::Query functions
    112 enum 
    113 { 
     114enum
     115{
    114116        TIXML_SUCCESS,
    115117        TIXML_NO_ATTRIBUTE,
     
    162164        /**     All TinyXml classes can print themselves to a filestream.
    163165                This is a formatted print, and will insert tabs and newlines.
    164                
     166
    165167                (For an unformatted stream, use the << operator.)
    166168        */
     
    206208        static const int utf8ByteTable[256];
    207209
    208         virtual const char* Parse(      const char* p, 
    209                                                                 TiXmlParsingData* data, 
     210        virtual const char* Parse(      const char* p,
     211                                                                TiXmlParsingData* data,
    210212                                                                TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
    211213
     
    245247
    246248        static const char*      SkipWhiteSpace( const char*, TiXmlEncoding encoding );
    247         inline static bool      IsWhiteSpace( char c )         
    248         { 
    249                 return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); 
     249        inline static bool      IsWhiteSpace( char c )
     250        {
     251                return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
    250252        }
    251253
     
    334336    /// Field containing a generic user pointer
    335337        void*                   userData;
    336        
     338
    337339        // None of these methods are reliable for any language except English.
    338340        // Good for approximation, not great for accuracy.
     
    386388
    387389public:
    388         #ifdef TIXML_USE_STL   
     390        #ifdef TIXML_USE_STL
    389391
    390392            /** An input stream operator, for every class. Tolerant of newlines and
     
    400402                    a node to a stream is very well defined. You'll get a nice stream
    401403                    of output, without any extra whitespace or newlines.
    402                    
     404
    403405                    But reading is not as well defined. (As it always is.) If you create
    404406                    a TiXmlElement (for example) and read that from an input stream,
     
    408410                    A TiXmlDocument will read nodes until it reads a root element, and
    409411                        all the children of that root element.
    410             */ 
     412            */
    411413            friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base);
    412414
     
    470472    #ifdef TIXML_USE_STL
    471473        /// STL std::string form.
    472         void SetValue( const std::string& _value )   
    473         {         
     474        void SetValue( const std::string& _value )
     475        {
    474476                StringToBuffer buf( _value );
    475                 SetValue( buf.buffer ? buf.buffer : "" );       
    476         }       
     477                SetValue( buf.buffer ? buf.buffer : "" );
     478        }
    477479        #endif
    478480
     
    492494        TiXmlNode* LastChild()  { return lastChild; }
    493495        const TiXmlNode* LastChild( const char * value ) const;                 /// The last child of this node matching 'value'. Will be null if there are no children.
    494         TiXmlNode* LastChild( const char * value );     
     496        TiXmlNode* LastChild( const char * value );
    495497
    496498    #ifdef TIXML_USE_STL
     
    649651
    650652        /** Create an exact duplicate of this node and return it. The memory must be deleted
    651                 by the caller. 
     653                by the caller.
    652654        */
    653655        virtual TiXmlNode* Clone() const = 0;
     
    731733        /** QueryIntValue examines the value string. It is an alternative to the
    732734                IntValue() method with richer error checking.
    733                 If the value is an integer, it is stored in 'value' and 
     735                If the value is an integer, it is stored in 'value' and
    734736                the call returns TIXML_SUCCESS. If it is not
    735737                an integer, it returns TIXML_WRONG_TYPE.
     
    750752    #ifdef TIXML_USE_STL
    751753        /// STL std::string form.
    752         void SetName( const std::string& _name )       
    753         {       
     754        void SetName( const std::string& _name )
     755        {
    754756                StringToBuffer buf( _name );
    755                 SetName ( buf.buffer ? buf.buffer : "error" ); 
    756         }
    757         /// STL std::string form.       
    758         void SetValue( const std::string& _value )     
    759         {       
     757                SetName ( buf.buffer ? buf.buffer : "error" );
     758        }
     759        /// STL std::string form.
     760        void SetValue( const std::string& _value )
     761        {
    760762                StringToBuffer buf( _value );
    761                 SetValue( buf.buffer ? buf.buffer : "error" ); 
     763                SetValue( buf.buffer ? buf.buffer : "error" );
    762764        }
    763765        #endif
     
    801803/*      A class used to manage a group of attributes.
    802804        It is only used internally, both by the ELEMENT and the DECLARATION.
    803        
     805
    804806        The set can be changed transparent to the Element and Declaration
    805807        classes that use it, but NOT transparent to the Attribute
     
    882884        /** QueryIntAttribute examines the attribute - it is an alternative to the
    883885                Attribute() method with richer error checking.
    884                 If the attribute is an integer, it is stored in 'value' and 
     886                If the attribute is an integer, it is stored in 'value' and
    885887                the call returns TIXML_SUCCESS. If it is not
    886888                an integer, it returns TIXML_WRONG_TYPE. If the attribute
    887889                does not exist, then TIXML_NO_ATTRIBUTE is returned.
    888         */     
     890        */
    889891        int QueryIntAttribute( const char* name, int* _value ) const;
    890892        /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
     
    913915
    914916        /// STL std::string form.
    915         void SetAttribute( const std::string& name, const std::string& _value ) 
    916         {       
     917        void SetAttribute( const std::string& name, const std::string& _value )
     918        {
    917919                StringToBuffer n( name );
    918920                StringToBuffer v( _value );
    919921                if ( n.buffer && v.buffer )
    920                         SetAttribute (n.buffer, v.buffer );     
    921         }       
     922                        SetAttribute (n.buffer, v.buffer );
     923        }
    922924        ///< STL std::string form.
    923         void SetAttribute( const std::string& name, int _value )       
    924         {       
     925        void SetAttribute( const std::string& name, int _value )
     926        {
    925927                StringToBuffer n( name );
    926928                if ( n.buffer )
    927                         SetAttribute (n.buffer, _value);       
    928         }       
     929                        SetAttribute (n.buffer, _value);
     930        }
    929931        #endif
    930932
     
    954956                and concise, GetText() is limited compared to getting the TiXmlText child
    955957                and accessing it directly.
    956        
     958
    957959                If the first child of 'this' is a TiXmlText, the GetText()
    958960                returns the character string of the Text node, else null is returned.
     
    964966                @endverbatim
    965967
    966                 'str' will be a pointer to "This is text". 
    967                
     968                'str' will be a pointer to "This is text".
     969
    968970                Note that this function can be misleading. If the element foo was created from
    969971                this XML:
    970972                @verbatim
    971                 <foo><b>This is text</b></foo> 
     973                <foo><b>This is text</b></foo>
    972974                @endverbatim
    973975
     
    975977                another element. From this XML:
    976978                @verbatim
    977                 <foo>This is <b>text</b></foo> 
     979                <foo>This is <b>text</b></foo>
    978980                @endverbatim
    979981                GetText() will return "This is ".
    980982
    981                 WARNING: GetText() accesses a child node - don't become confused with the 
    982                                  similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are 
     983                WARNING: GetText() accesses a child node - don't become confused with the
     984                                 similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are
    983985                                 safe type casts on the referenced node.
    984986        */
     
    10541056
    10551057
    1056 /** XML text. A text node can have 2 ways to output the next. "normal" output 
     1058/** XML text. A text node can have 2 ways to output the next. "normal" output
    10571059        and CDATA. It will default to the mode it was parsed from the XML file and
    1058         you generally want to leave it alone, but you can change the output mode with 
     1060        you generally want to leave it alone, but you can change the output mode with
    10591061        SetCDATA() and query it with CDATA().
    10601062*/
     
    10631065        friend class TiXmlElement;
    10641066public:
    1065         /** Constructor for text element. By default, it is treated as 
     1067        /** Constructor for text element. By default, it is treated as
    10661068                normal, encoded text. If you want it be output as a CDATA text
    10671069                element, set the parameter _cdata to 'true'
     
    12791281                - The ErrorDesc() method will return the name of the error. (very useful)
    12801282                - The ErrorRow() and ErrorCol() will return the location of the error (if known)
    1281         */     
     1283        */
    12821284        bool Error() const                                              { return error; }
    12831285
     
    12901292        int ErrorId()   const                           { return errorId; }
    12911293
    1292         /** Returns the location (if known) of the error. The first column is column 1, 
     1294        /** Returns the location (if known) of the error. The first column is column 1,
    12931295                and the first row is row 1. A value of 0 means the row and column wasn't applicable
    12941296                (memory errors, for example, have no row/column) or the parser lost the error. (An
     
    13031305                to report the correct values for row and column. It does not change the output
    13041306                or input in any way.
    1305                
     1307
    13061308                By calling this method, with a tab size
    13071309                greater than 0, the row and column of each node and attribute is stored
     
    13311333                state is automatically cleared if you Parse a new XML block.
    13321334        */
    1333         void ClearError()                                               {       error = false; 
    1334                                                                                                 errorId = 0; 
    1335                                                                                                 errorDesc = ""; 
    1336                                                                                                 errorLocation.row = errorLocation.col = 0; 
    1337                                                                                                 //errorLocation.last = 0; 
     1335        void ClearError()                                               {       error = false;
     1336                                                                                                errorId = 0;
     1337                                                                                                errorDesc = "";
     1338                                                                                                errorLocation.row = errorLocation.col = 0;
     1339                                                                                                //errorLocation.last = 0;
    13381340                                                                                        }
    13391341
     
    13811383        @endverbatim
    13821384
    1383         Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very 
     1385        Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very
    13841386        easy to write a *lot* of code that looks like:
    13851387
     
    14011403
    14021404        And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity
    1403         of such code. A TiXmlHandle checks for null     pointers so it is perfectly safe 
     1405        of such code. A TiXmlHandle checks for null     pointers so it is perfectly safe
    14041406        and correct to use:
    14051407
     
    14221424
    14231425        @verbatim
    1424         int i=0; 
     1426        int i=0;
    14251427        while ( true )
    14261428        {
     
    14331435        @endverbatim
    14341436
    1435         It seems reasonable, but it is in fact two embedded while loops. The Child method is 
    1436         a linear walk to find the element, so this code would iterate much more than it needs 
     1437        It seems reasonable, but it is in fact two embedded while loops. The Child method is
     1438        a linear walk to find the element, so this code would iterate much more than it needs
    14371439        to. Instead, prefer:
    14381440
     
    14641466        TiXmlHandle FirstChildElement( const char * value ) const;
    14651467
    1466         /** Return a handle to the "index" child with the given name. 
     1468        /** Return a handle to the "index" child with the given name.
    14671469                The first child is 0, the second 1, etc.
    14681470        */
    14691471        TiXmlHandle Child( const char* value, int index ) const;
    1470         /** Return a handle to the "index" child. 
     1472        /** Return a handle to the "index" child.
    14711473                The first child is 0, the second 1, etc.
    14721474        */
    14731475        TiXmlHandle Child( int index ) const;
    1474         /** Return a handle to the "index" child element with the given name. 
     1476        /** Return a handle to the "index" child element with the given name.
    14751477                The first child element is 0, the second 1, etc. Note that only TiXmlElements
    14761478                are indexed: other types are not counted.
    14771479        */
    14781480        TiXmlHandle ChildElement( const char* value, int index ) const;
    1479         /** Return a handle to the "index" child element. 
     1481        /** Return a handle to the "index" child element.
    14801482                The first child element is 0, the second 1, etc. Note that only TiXmlElements
    14811483                are indexed: other types are not counted.
     
    14921494
    14931495        /// Return the handle as a TiXmlNode. This may return null.
    1494         TiXmlNode* Node() const                 { return node; } 
     1496        TiXmlNode* Node() const                 { return node; }
    14951497        /// Return the handle as a TiXmlElement. This may return null.
    14961498        TiXmlElement* Element() const   { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
  • branches/std/src/lib/particles/spark_particles.cc

    r7193 r7203  
    6868{
    6969  this->setClassID(CL_SPARK_PARTICLES, "SparkParticles");
    70 
    71   this->material = NULL;
    7270}
    7371
  • branches/std/src/lib/sound/ogg_player.cc

    r6987 r7203  
    3131 * @param fileName the file to load
    3232 */
    33 OggPlayer::OggPlayer(const char* fileName)
     33OggPlayer::OggPlayer(const std::string& fileName)
    3434{
    3535  this->setClassID(CL_SOUND_OGG_PLAYER, "OggPlayer");
     
    4040  this->buffers[1] = 0;
    4141
    42   if (fileName != NULL)
     42  if (!fileName.empty())
    4343  {
    4444    if (this->open(fileName))
     
    5656 * @param fileName the file to open
    5757 */
    58 bool OggPlayer::open(const char* fileName)
     58bool OggPlayer::open(const std::string& fileName)
    5959{
    6060  if (this->buffers[0] == 0)
     
    7272  int result;
    7373
    74   if(!(oggFile = fopen(fileName, "rb")))
     74  if(!(oggFile = fopen(fileName.c_str(), "rb")))
    7575  {
    7676    PRINTF(2)("Could not open Ogg file.");
  • branches/std/src/lib/sound/ogg_player.h

    r7054 r7203  
    2727{
    2828public:
    29   OggPlayer(const char* fileName = NULL);
     29  OggPlayer(const std::string& fileName = NULL);
    3030  virtual ~OggPlayer();
    3131
    32   bool open(const char* fileName);
     32  bool open(const std::string& fileName);
    3333  void release();
    3434  void debug();
  • branches/std/src/lib/sound/sound_buffer.cc

    r6836 r7203  
    3232 * @param fileName The name of the File
    3333 */
    34 SoundBuffer::SoundBuffer(const char* fileName)
     34SoundBuffer::SoundBuffer(const std::string& fileName)
    3535{
    3636  this->setClassID(CL_SOUND_BUFFER, "SoundBuffer");
     
    5454 * @returns true on success.
    5555 */
    56 bool SoundBuffer::loadWAV(const char* fileName)
     56bool SoundBuffer::loadWAV(const std::string& fileName)
    5757{
    5858  SDL_AudioSpec wavSpec;
     
    6161
    6262  /* Load the WAV */
    63   if( SDL_LoadWAV(fileName, &wavSpec, &wavBuffer, &wavLength) == NULL)
     63  if( SDL_LoadWAV(fileName.c_str(), &wavSpec, &wavBuffer, &wavLength) == NULL)
    6464  {
    65     PRINTF(2)("Could not open %s: %s\n", fileName, SDL_GetError());
     65    PRINTF(2)("Could not open %s: %s\n", fileName.c_str(), SDL_GetError());
    6666    return false;
    6767  }
  • branches/std/src/lib/sound/sound_buffer.h

    r6981 r7203  
    1717{
    1818  public:
    19     SoundBuffer(const char* fileName);
     19    SoundBuffer(const std::string& fileName);
    2020    virtual ~SoundBuffer();
    2121
    22     bool loadWAV(const char* fileName);
     22    bool loadWAV(const std::string& fileName);
    2323
    2424    /** @returns the ID of the buffer used in this SoundBuffer */
  • branches/std/src/lib/sound/sound_engine.cc

    r7193 r7203  
    9999void SoundEngine::loadSettings(IniParser* iniParser)
    100100{
    101   const char* channels = iniParser->getVar(CONFIG_NAME_AUDIO_CHANNELS, CONFIG_SECTION_AUDIO, "32");
    102   this->maxSourceCount = atoi(channels);
    103 
    104   const char* effectsVolume = iniParser->getVar(CONFIG_NAME_EFFECTS_VOLUME, CONFIG_SECTION_AUDIO, "80");
    105   this->effectsVolume = atof(effectsVolume)/100.0;
    106 
    107   const char* musicVolume = iniParser->getVar(CONFIG_NAME_MUSIC_VOLUME, CONFIG_SECTION_AUDIO, "75");
    108   this->musicVolume = atof(musicVolume)/100.0;
     101  MultiType channels = iniParser->getVar(CONFIG_NAME_AUDIO_CHANNELS, CONFIG_SECTION_AUDIO, "32");
     102  this->maxSourceCount = channels.getInt();
     103
     104  MultiType effectsVolume = iniParser->getVar(CONFIG_NAME_EFFECTS_VOLUME, CONFIG_SECTION_AUDIO, "80");
     105  this->effectsVolume = effectsVolume.getFloat()/100.0;
     106
     107  MultiType musicVolume = iniParser->getVar(CONFIG_NAME_MUSIC_VOLUME, CONFIG_SECTION_AUDIO, "75");
     108  this->musicVolume = musicVolume.getFloat()/100.0;
    109109}
    110110
  • branches/std/src/lib/util/executor/executor.cc

    r7201 r7203  
    105105  value[4] = &value4;
    106106
    107   printf("%s ::: paramCount: %d\n", this->getName(), this->paramCount);
    108107  for (unsigned int i = 0; i < this->paramCount; i++)
    109108  {
    110109    if (*value[i] != MT_NULL)
    111110    {
    112       printf("1:::: %d : %s \n",i, MultiType::MultiTypeToString(this->defaultValue[i].getType()));
    113 
    114       this->defaultValue[i].debug();
    115       //this->defaultValue[i].setValueOf(*value[i]);
    116       //printf("2::::%s\n", MultiType::MultiTypeToString(this->defaultValue[i].getType()));
    117       //this->defaultValue[i].debug();
    118     //this->defaultValue[i].setValueOf(*value[i]);
     111      this->defaultValue[i].setValueOf(*value[i]);
    119112    }
    120113  }
  • branches/std/src/lib/util/executor/executor.h

    r7200 r7203  
    8787#define   l_FLOAT_DEFGRAB(i)        this->defaultValue[i].getFloat()
    8888//! where to chek for default STRING values
     89#define   l_STRING_DEFGRAB(i)       this->defaultValue[i].getString()
     90//! where to chek for default CSTRING values
    8991#define   l_CSTRING_DEFGRAB(i)      this->defaultValue[i].getCString()
    9092
     
    268270    virtual void execute (BaseObject* object, const void* parameters = NULL)
    269271    {
    270       SubString sub((const char*) parameters, " \n\t,", '\\');
    271       printf("%s :: %s\n", this->getName(), (const char*) parameters);
     272      SubString sub(((const std::string*) parameters)->c_str(), " \n\t,", '\\');
     273      printf("%s :: %s\n", this->getName(), ((const std::string*) parameters)->c_str());
    272274//! FUNCTOR_LIST is the List of Executive Functions
    273275#define FUNCTOR_LIST(x) ExecutorExecute ## x
  • branches/std/src/lib/util/executor/functor_list.h

    r7199 r7203  
    7575
    7676#define l_CSTRING_TYPE     const char*          //!< The type of a STRING
    77 #define l_CSTRING_FUNC     isString             //!< The function to parse a STRING
    78 #define l_CSTRING_NAME     "string"             //!< The name of a STRING
     77#define l_CSTRING_FUNC     isCString            //!< The function to parse a STRING
     78#define l_CSTRING_NAME     "cstring"            //!< The name of a STRING
    7979#define l_CSTRING_PARAM    MT_STRING            //!< the type of the parameter STRING
    8080#define l_CSTRING_DEFAULT  ""                   //!< a default Value for an STRING
     
    9898
    9999  FUNCTOR_LIST(0)();
     100  //! makes functions with one cstring
     101  FUNCTOR_LIST(1)(l_CSTRING);
     102  //! makes functions with two cstrings
     103  FUNCTOR_LIST(2)(l_CSTRING, l_CSTRING);
     104  //! makes functions with three cstrings
     105  FUNCTOR_LIST(3)(l_CSTRING, l_CSTRING, l_CSTRING);
     106  //! makes functions with four cstrings
     107  FUNCTOR_LIST(4)(l_CSTRING, l_CSTRING, l_CSTRING, l_CSTRING);
     108
    100109  //! makes functions with one string
    101   FUNCTOR_LIST(1)(l_CSTRING);
     110  FUNCTOR_LIST(1)(l_STRING);
    102111  //! makes functions with two strings
    103   FUNCTOR_LIST(2)(l_CSTRING, l_CSTRING);
     112  FUNCTOR_LIST(2)(l_STRING, l_STRING);
    104113  //! makes functions with three strings
    105   FUNCTOR_LIST(3)(l_CSTRING, l_CSTRING, l_CSTRING);
     114  FUNCTOR_LIST(3)(l_STRING, l_STRING, l_STRING);
    106115  //! makes functions with four strings
    107   FUNCTOR_LIST(4)(l_CSTRING, l_CSTRING, l_CSTRING, l_CSTRING);
     116  FUNCTOR_LIST(4)(l_STRING, l_STRING, l_STRING, l_STRING);
     117
    108118
    109119  //! makes functions with one bool
  • branches/std/src/lib/util/helper_functions.cc

    r5331 r7203  
    2222
    2323/**
    24  * checks if the input was a bool
     24 * @brief checks if the input was a bool
    2525 * @param BOOL a String that holds a bool: must be one of those: 1,0,true,false(case-insensitive)
    2626 * @param defaultValue a default value that is set, if BOOL is corrupt
     
    4242
    4343/**
    44  * checks if the input was a int
     44 * @brief checks if the input was a int
    4545 * @param INT a String that holds an int.
    4646 * @param defaultValue a default value that is set, if INT is corrupt
     
    6363
    6464/**
    65  * checks if the input was a float
     65 * @brief checks if the input was a float
    6666 * @param FLOAT a String that holds an float.
    6767 * @param defaultValue a default value that is set, if FLOAT is corrupt
     
    8383
    8484/**
    85  * checks if the input was a string
     85 * @brief checks if the input was a string
    8686 * @param STING a String(char-array) that holds an string.
    8787 * @param defaultValue a default value that is set, if STRING is corrupt
    8888 * @return returns the contained string (char-array), if STRING was correct otherwise defaultValue
    8989 */
    90 const char* isString(const char* STRING, const char* defaultValue)
     90const char* isCString(const char* STRING, const char* defaultValue)
    9191{
    9292  if (STRING != NULL && strlen(STRING) > 0)
     
    9595    return defaultValue;
    9696}
     97
     98/**
     99 * @brief checks if the input was a string
     100 * @param STING a String(char-array) that holds an string.
     101 * @param defaultValue a default value that is set, if STRING is corrupt
     102 * @return returns the contained string (char-array), if STRING was correct otherwise defaultValue
     103 */
     104std::string isString(const char* STRING, const std::string& defaultValue)
     105{
     106  if (STRING != NULL && strlen(STRING) > 0)
     107    return STRING;
     108  else
     109    return defaultValue;
     110}
     111
     112
     113/**
     114 * @brief compares two strings without ignoring the case
     115 * @param s1 first string
     116 * @param s2 second string
     117 */
     118int nocase_cmp(const std::string& s1, const std::string& s2)
     119{
     120  std::string::const_iterator it1=s1.begin();
     121  std::string::const_iterator it2=s2.begin();
     122
     123  //stop when either string's end has been reached
     124  while ( (it1!=s1.end()) && (it2!=s2.end()) )
     125  {
     126    if(::toupper(*it1) != ::toupper(*it2)) //letters differ?
     127     // return -1 to indicate smaller than, 1 otherwise
     128      return (::toupper(*it1)  < ::toupper(*it2)) ? -1 : 1;
     129    //proceed to the next character in each string
     130    ++it1;
     131    ++it2;
     132  }
     133  size_t size1=s1.size(), size2=s2.size();// cache lengths
     134   //return -1,0 or 1 according to strings' lengths
     135  if (size1==size2)
     136    return 0;
     137  return (size1<size2) ? -1 : 1;
     138}
     139
  • branches/std/src/lib/util/helper_functions.h

    r5141 r7203  
    66#ifndef _HELPER_FUNCTIONS_H
    77#define _HELPER_FUNCTIONS_H
     8
     9#include <string>
    810
    911// FORWARD DECLARATION
     
    1517int           isInt(const char* INT, int defaultValue);
    1618float         isFloat(const char* FLOAT, float defaultValue);
    17 const char*   isString(const char* STRING, const char* defaultValue);
     19const char*   isCString(const char* STRING, const char* defaultValue);
     20std::string   isString(const char* STRING, const std::string& defaultValue);
     21
     22
     23int           nocase_cmp(const std::string& s1, const std::string& s2);
     24
    1825
    1926#endif /* _HELPER_FUNCTIONS_H */
  • branches/std/src/lib/util/loading/game_loader.cc

    r7193 r7203  
    8686 * this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns
    8787 */
    88 ErrorMessage GameLoader::loadCampaign(const char* fileName)
     88ErrorMessage GameLoader::loadCampaign(const std::string& fileName)
    8989{
    9090  ErrorMessage errorCode;
    91   char* campaignName = ResourceManager::getFullName(fileName);
    92   if (campaignName)
     91  std::string campaignName = ResourceManager::getFullName(fileName);
     92  if (!campaignName.empty())
    9393    {
    9494      this->currentCampaign = this->fileToCampaign(campaignName);
    95       delete[] campaignName;
    9695    }
    9796}
     
    105104 * this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns
    106105 */
    107 ErrorMessage GameLoader::loadNetworkCampaign(const char* fileName)
     106ErrorMessage GameLoader::loadNetworkCampaign(const std::string& fileName)
    108107{
    109108  ErrorMessage errorCode;
    110   char* campaignName = ResourceManager::getFullName(fileName);
    111   if (campaignName)
     109  std::string campaignName = ResourceManager::getFullName(fileName);
     110  if (!campaignName.empty())
    112111  {
    113112    this->currentCampaign = this->fileToCampaign(campaignName);
    114     delete[] campaignName;
    115113  }
    116114}
     
    220218 * this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns
    221219 */
    222 Campaign* GameLoader::fileToCampaign(const char* fileName)
     220Campaign* GameLoader::fileToCampaign(const std::string& fileName)
    223221{
    224222  /* do not entirely load the campaign. just the current world
     
    227225  */
    228226
    229   if( fileName == NULL)
     227  if( fileName.empty())
    230228    {
    231229      PRINTF(2)("No filename specified for loading");
     
    233231    }
    234232
    235   TiXmlDocument* XMLDoc = new TiXmlDocument( fileName);
     233  TiXmlDocument XMLDoc(fileName);
    236234  // load the campaign document
    237   if( !XMLDoc->LoadFile())
     235  if( !XMLDoc.LoadFile(fileName))
    238236    {
    239237      // report an error
    240       PRINTF(1)("Could not load XML File %s: %s @ %d:%d\n", fileName, XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
    241       delete XMLDoc;
     238      PRINTF(1)("Could not load XML File %s: %s @ %d:%d\n", fileName.c_str(), XMLDoc.ErrorDesc(), XMLDoc.ErrorRow(), XMLDoc.ErrorCol());
    242239      return NULL;
    243240    }
    244241
    245242  // check basic validity
    246   TiXmlElement* root = XMLDoc->RootElement();
     243  TiXmlElement* root = XMLDoc.RootElement();
    247244  assert( root != NULL);
    248245
     
    251248      // report an error
    252249      PRINTF(2)("Specified XML File is not an orxonox campaign file (Campaign element missing)\n");
    253       delete XMLDoc;
    254250      return NULL;
    255251    }
    256252
    257253  // construct campaign
    258   Campaign* c = new Campaign( root);
    259 
    260   // free the XML data
    261   delete XMLDoc;
    262 
    263   return c;
     254  return new Campaign( root);
    264255}
    265256
  • branches/std/src/lib/util/loading/game_loader.h

    r6981 r7203  
    4444  static GameLoader* getInstance() { if(singletonRef == NULL) singletonRef = new GameLoader(); return singletonRef; }
    4545
    46   ErrorMessage loadCampaign(const char* name);
     46  ErrorMessage loadCampaign(const std::string& name);
    4747  ErrorMessage loadDebugCampaign(Uint32 campaignID);
    48   ErrorMessage loadNetworkCampaign(const char* fileName);
     48  ErrorMessage loadNetworkCampaign(const std::string& fileName);
    4949
    5050  ErrorMessage init();
     
    6262  GameLoader ();
    6363
    64   Campaign* fileToCampaign(const char* name);
     64  Campaign* fileToCampaign(const std::string& name);
    6565
    6666
  • branches/std/src/lib/util/loading/load_param.cc

    r7201 r7203  
    2828 * @param executor the Executor, that executes the loading procedure.
    2929 */
    30 CLoadParam::CLoadParam(const TiXmlElement* root, const char* paramName, BaseObject* object, const Executor& executor, bool inLoadCycle)
    31 {
    32   this->paramName = paramName;
     30CLoadParam::CLoadParam(const TiXmlElement* root, const std::string& paramName, BaseObject* object, const Executor& executor, bool inLoadCycle)
     31  :  paramName(paramName), object(object)
     32{
    3333  this->object = object;
    3434  this->inLoadCycle = inLoadCycle;
     
    3737  if (likely(!inLoadCycle))
    3838    this->loadElem = grabParameterElement(root, paramName);
    39   //this->loadString = grabParameter(root, paramName);
    40   else if (!strcmp(root->Value(), paramName))
     39  else if (paramName == root->Value())
    4140    this->loadElem = (TiXmlElement*)root->FirstChild();
    4241  else
     
    4645  this->executor = executor.clone();
    4746
    48   if (this->executor)
    49     this->executor->setName(paramName);
     47  //if (this->executor)
     48  //  this->executor->setName(paramName);
    5049}
    5150
     
    6059  if (likely(this->executor != NULL))
    6160  {
     61    std::string loadString;
    6262    if (this->loadElem != NULL &&  this->loadElem->ToText())
    63       this->loadString = this->loadElem->Value();
    64     else
    65       this->loadString = NULL;
     63      loadString = this->loadElem->Value();
    6664    if (likely(this->object != NULL) &&
    67         ( this->loadString != NULL ||
     65        ( !loadString.empty() ||
    6866          ((this->executor->getType() & Executor_NoLoadString) == Executor_NoLoadString)))
    6967    {
    70       PRINTF(4)("Loading '%s' with Parameters '%s' onto: '%s'(%s)\n", this->paramName, this->loadString, this->object->getName(), this->object->getClassName());
    71       this->executor->execute(this->object, this->loadString);
     68      PRINTF(4)("Loading '%s' with Parameters '%s' onto: '%s'(%s)\n", this->paramName, loadString, this->object->getName(), this->object->getClassName());
     69      this->executor->execute(this->object, &loadString);
    7270    }
    7371    delete this->executor;
     
    9997 * @returns a pointer to itself.
    10098*/
    101 CLoadParam& CLoadParam::describe(const char* descriptionText)
    102 {
    103   if (LoadClassDescription::parametersDescription && this->paramDesc && !this->paramDesc->getDescription())
     99CLoadParam& CLoadParam::describe(const std::string& descriptionText)
     100{
     101  if (LoadClassDescription::parametersDescription && this->paramDesc && this->paramDesc->getDescription().empty())
    104102  {
    105103    this->paramDesc->setDescription(descriptionText);
     
    230228 * @returns the Value of the parameter if found, NULL otherwise
    231229*/
    232 const char* grabParameter(const TiXmlElement* root, const char* parameterName)
     230std::string grabParameter(const TiXmlElement* root, const std::string& parameterName)
    233231{
    234232  const TiXmlElement* element;
    235233  const TiXmlNode* node;
    236234
    237   if (root == NULL || parameterName == NULL)
     235  if (root == NULL)
    238236    return NULL;
    239   assert( parameterName != NULL);
    240237
    241238  element = root->FirstChildElement( parameterName);
     
    256253 * @returns the Element of the parameter if found, NULL otherwise
    257254 */
    258 const TiXmlElement* grabParameterElement(const TiXmlElement* root, const char* parameterName)
     255const TiXmlElement* grabParameterElement(const TiXmlElement* root, const std::string& parameterName)
    259256{
    260257  const TiXmlElement* element;
    261258  const TiXmlNode* node;
    262259
    263   if (root == NULL || parameterName == NULL)
     260  if (root == NULL)
    264261    return NULL;
    265   assert( parameterName != NULL);
    266262
    267263  element = root->FirstChildElement( parameterName);
  • branches/std/src/lib/util/loading/load_param.h

    r7198 r7203  
    8787{
    8888  public:
    89     CLoadParam(const TiXmlElement* root, const char* paramName, BaseObject* object, const Executor& executor, bool inLoadCycle = false);
     89    CLoadParam(const TiXmlElement* root, const std::string& paramName, BaseObject* object, const Executor& executor, bool inLoadCycle = false);
    9090    virtual ~CLoadParam();
    9191
    92     CLoadParam& describe(const char* descriptionText);
     92    CLoadParam& describe(const std::string& descriptionText);
    9393    CLoadParam& defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,
    9494                              const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,
    9595                              const MultiType& value4 = MT_NULL);
    96     CLoadParam& attribute(const char* attributeName, const Executor& executor);
     96    CLoadParam& attribute(const std::string& attributeName, const Executor& executor);
    9797
    9898
     
    101101    Executor*                executor;
    102102    BaseObject*              object;
    103     const char*              paramName;
     103    const std::string        paramName;
    104104
    105105    LoadClassDescription*    classDesc;            //!< The LoadClassDescription of this CLoadParameter
    106106    LoadParamDescription*    paramDesc;            //!< The LoadParameterDescription of this LoadParameter
    107107    const TiXmlElement*      loadElem;             //!< The Element to load.
    108     const char*              loadString;           //!< The string loaded by this LoadParam
    109108    const void*              pointerToParam;       //!< A Pointer to a Parameter.
    110109
     
    114113// helper function
    115114
    116 const char* grabParameter(const TiXmlElement* root, const char* parameterName);
    117 const TiXmlElement* grabParameterElement(const TiXmlElement* root, const char* parameterName);
     115std::string grabParameter(const TiXmlElement* root, const std::string& parameterName);
     116const TiXmlElement* grabParameterElement(const TiXmlElement* root, const std::string& parameterName);
    118117
    119118#endif /* _LOAD_PARAM_H */
  • branches/std/src/lib/util/loading/load_param_description.cc

    r7130 r7203  
    2222 * @param paramName the name of the parameter to load
    2323 */
    24 LoadParamDescription::LoadParamDescription(const char* paramName)
     24LoadParamDescription::LoadParamDescription(const std::string& paramName)
    2525{
    2626  this->types = NULL;
    27   this->description = NULL;
    2827  this->defaultValues = NULL;
    29   this->paramName = new char[strlen(paramName)+1];
    30   strcpy(this->paramName, paramName);
     28  this->paramName = paramName;
    3129}
    3230
     
    4644  delete[] this->types;
    4745  delete[] this->defaultValues;
    48   delete[] this->paramName;
    49   delete[] this->description;
    5046}
    5147
     
    5349 * @param descriptionText The text to set as a description for this Parameter
    5450 */
    55 void LoadParamDescription::setDescription(const char* descriptionText)
    56 {
    57   this->description = new char[strlen(descriptionText)+1];
    58   strcpy(this->description, descriptionText);
     51void LoadParamDescription::setDescription(const std::string& descriptionText)
     52{
     53  this->description = descriptionText;
    5954}
    6055
     
    6459void LoadParamDescription::print() const
    6560{
    66   PRINT(3)(" <%s>", this->paramName);
     61  PRINT(3)(" <%s>", this->paramName.c_str());
    6762  for (int i = 0; i < this->paramCount; i++)
    6863  {
     
    10196//     }
    10297  }
    103   PRINT(3)("</%s>", this->paramName);
    104   if (this->description)
    105     PRINT(3)(" -- %s", this->description);
     98  PRINT(3)("</%s>", this->paramName.c_str());
     99  if (!this->description.empty())
     100    PRINT(3)(" -- %s", this->description.c_str());
    106101  // default values
    107102  if (this->paramCount > 0)
     
    213208  while (it != this->paramList.end())
    214209  {
    215     if (!strcmp((*it)->paramName, paramName))
     210    if ((*it)->paramName == paramName)
    216211    {
    217212      return NULL;
  • branches/std/src/lib/util/loading/load_param_description.h

    r7130 r7203  
    3636  friend class LoadParam;
    3737  friend class LoadClassDescription;
    38  public:
    39   LoadParamDescription(const char* paramName);
     38public:
     39  LoadParamDescription(const std::string& paramName);
    4040  ~LoadParamDescription();
    4141
    42   void setDescription(const char* descriptionText);
     42  void setDescription(const std::string& descriptionText);
    4343  /** @returns the descriptionString */
    44   const char* getDescription() { return this->description; };
     44  const std::string& getDescription() { return this->description; };
    4545
    4646  void print() const;
    4747
    48  private:
    49   char*         paramName;             //!< The name of the parameter.
     48private:
     49  std::string   paramName;             //!< The name of the parameter.
    5050  int           paramCount;            //!< The count of parameters.
    5151  int*          types;                 //!< What kind of parameters does this function take ??
    52   char*         description;           //!< A longer description about this function.
     52  std::string   description;           //!< A longer description about this function.
    5353  char**        defaultValues;         //!< The 'Default Values'. @TODO MAKE THIS A MULTITYPE
    5454};
     
    5858{
    5959  friend class CLoadParam;
    60  public:
     60public:
    6161  LoadClassDescription(const char* className);
    6262  ~LoadClassDescription();
     
    6969  static void printAll(const char* fileName = NULL);
    7070  static std::list<const char*> searchClassWithShort(const char* classNameBegin);
    71 //  static const LoadParamDescription* getClass(const char* className);
     71  //  static const LoadParamDescription* getClass(const char* className);
    7272
    73  private:
     73private:
    7474  static bool                              parametersDescription;  //!< if parameter-description should be enabled.
    7575  static std::list<LoadClassDescription*>* classList;              //!< a list, that stores all the loadable classes. (after one instance has been loaded)
  • branches/std/src/lib/util/loading/resource_manager.cc

    r7199 r7203  
    6060
    6161  this->dataDir = new char[3];
    62   strcpy(this->dataDir, "./");
     62  this->dataDir = "./";
    6363  this->tryDataDir("./data");
    64 
    65   this->_cwd = NULL;
    6664}
    6765
     
    8078    PRINTF(1)("Not removed all Resources, since there are still %d resources registered\n", this->resourceList.size());
    8179
    82   // deleting the Directorie Lists
    83   while (!this->imageDirs.empty())
    84   {
    85     delete[] this->imageDirs.back();
    86     this->imageDirs.pop_back();
    87   }
    88 
    89   delete[] this->dataDir;
    90   if (this->_cwd)
    91     delete[] this->_cwd;
    9280  ResourceManager::singletonRef = NULL;
    9381}
     
    9785 * @param dataDir the DataDirectory.
    9886 */
    99 bool ResourceManager::setDataDir(const char* dataDir)
    100 {
    101   char* realDir = ResourceManager::homeDirCheck(dataDir);
     87bool ResourceManager::setDataDir(const std::string& dataDir)
     88{
     89  std::string realDir = ResourceManager::homeDirCheck(dataDir);
    10290  if (isDir(realDir))
    10391  {
    104     delete[] this->dataDir;
    105     if (dataDir[strlen(dataDir)-1] == '/' || dataDir[strlen(dataDir)-1] == '\\')
     92    if (dataDir[dataDir.size()-1] == '/' || dataDir[dataDir.size()-1] == '\\')
    10693    {
    107       this->dataDir = new char[strlen(realDir)+1];
    108       strcpy(this->dataDir, realDir);
     94      this->dataDir = realDir;
    10995    }
    11096    else
    11197    {
    112       this->dataDir = new char[strlen(realDir)+2];
    113       strcpy(this->dataDir, realDir);
    114       this->dataDir[strlen(realDir)] = '/';
    115       this->dataDir[strlen(realDir)+1] = '\0';
     98      this->dataDir = realDir;
     99      this->dataDir += '/';
    116100    }
    117     delete[] realDir;
    118101    return true;
    119102  }
    120103  else
    121104  {
    122     PRINTF(1)("%s is not a Directory, and can not be the Data Directory, leaving as %s \n", realDir, this->dataDir);
    123     delete[] realDir;
     105    PRINTF(1)("%s is not a Directory, and can not be the Data Directory, leaving as %s \n", realDir.c_str(), this->dataDir.c_str());
    124106    return false;
    125107  }
     
    132114 * this is essentially the same as setDataDir, but it ommits the error-message
    133115 */
    134 bool ResourceManager::tryDataDir(const char* dataDir)
    135 {
    136   char* realDir = ResourceManager::homeDirCheck(dataDir);
     116bool ResourceManager::tryDataDir(const std::string& dataDir)
     117{
     118  std::string realDir = ResourceManager::homeDirCheck(dataDir);
    137119  if (isDir(realDir))
    138120  {
    139     delete[] this->dataDir;
    140     if (dataDir[strlen(dataDir)-1] == '/' || dataDir[strlen(dataDir)-1] == '\\')
     121    if (dataDir[dataDir.size()-1] == '/' || dataDir[dataDir.size()-1] == '\\')
    141122    {
    142       this->dataDir = new char[strlen(realDir)+1];
    143       strcpy(this->dataDir, realDir);
     123      this->dataDir = realDir;
    144124    }
    145125    else
    146126    {
    147       this->dataDir = new char[strlen(realDir)+2];
    148       strcpy(this->dataDir, realDir);
    149       this->dataDir[strlen(realDir)] = '/';
    150       this->dataDir[strlen(realDir)+1] = '\0';
     127      this->dataDir = realDir;
     128      this->dataDir += '/';
    151129    }
    152     delete[] realDir;
    153130    return true;
    154131  }
    155   delete[] realDir;
    156132  return false;
    157133}
     
    162138 * @param fileInside is iniside of the given directory.
    163139*/
    164 bool ResourceManager::verifyDataDir(const char* fileInside)
     140bool ResourceManager::verifyDataDir(const std::string& fileInside)
    165141{
    166142  bool retVal;
    167143  if (!isDir(this->dataDir))
    168144  {
    169     PRINTF(1)("%s is not a directory\n", this->dataDir);
    170     return false;
    171   }
    172 
    173   char* testFile = new char[strlen(this->dataDir)+strlen(fileInside)+1];
    174   sprintf(testFile, "%s%s", this->dataDir, fileInside);
     145    PRINTF(1)("%s is not a directory\n", this->dataDir.c_str());
     146    return false;
     147  }
     148
     149  std::string testFile = this->dataDir + fileInside;
    175150  retVal = isFile(testFile);
    176   delete[] testFile;
    177151  return retVal;
    178152}
     
    185159   false otherwise
    186160*/
    187 bool ResourceManager::addImageDir(const char* imageDir)
    188 {
    189   if (imageDir == NULL)
    190     return false;
    191 
    192   char* newDir;
    193   if (imageDir[strlen(imageDir)-1] == '/' || imageDir[strlen(imageDir)-1] == '\\')
    194   {
    195     newDir = new char[strlen(imageDir)+1];
    196     strcpy(newDir, imageDir);
    197   }
    198   else
    199   {
    200     newDir = new char[strlen(imageDir)+2];
    201     strcpy(newDir, imageDir);
    202     newDir[strlen(imageDir)] = '/';
    203     newDir[strlen(imageDir)+1] = '\0';
     161bool ResourceManager::addImageDir(const std::string& imageDir)
     162{
     163  std::string newDir;
     164  if (imageDir[imageDir.size()-1] == '/' || imageDir[imageDir.size()-1] == '\\')
     165  {
     166    newDir = imageDir;
     167  }
     168  else
     169  {
     170    newDir = imageDir;
     171    newDir += '/';
    204172  }
    205173  // check if the param is a Directory
     
    207175  {
    208176    // check if the Directory has been added before
    209     std::vector<char*>::const_iterator imageDir;
     177    std::vector<std::string>::const_iterator imageDir;
    210178    for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++)
    211179    {
    212       if (!strcmp(*imageDir, newDir))
     180      if (*imageDir == newDir)
    213181      {
    214         PRINTF(3)("Path %s already loaded\n", newDir);
    215         delete[] newDir;
     182        PRINTF(3)("Path %s already loaded\n", newDir.c_str());
    216183        return true;
    217184      }
     
    223190  else
    224191  {
    225     PRINTF(1)("%s is not a Directory, and can not be added to the Paths of Images\n", newDir);
    226     delete[] newDir;
     192    PRINTF(1)("%s is not a Directory, and can not be added to the Paths of Images\n", newDir.c_str());
    227193    return false;
    228194  }
     
    239205 * @returns a pointer to a desired Resource.
    240206*/
    241 BaseObject* ResourceManager::load(const char* fileName, ResourcePriority prio,
     207BaseObject* ResourceManager::load(const std::string& fileName, ResourcePriority prio,
    242208                                  const MultiType& param0, const MultiType& param1, const MultiType& param2)
    243209{
    244   if (fileName == NULL)
    245     return NULL;
    246210  ResourceType tmpType;
    247211#ifndef NO_MODEL
    248212#define __IF_OK
    249   if (!strncasecmp(fileName+(strlen(fileName)-4), ".obj", 4))
     213  if (!strncasecmp(fileName.c_str()+(fileName.size()-4), ".obj", 4))
    250214    tmpType = OBJ;
    251   else if (!strncmp(fileName+(strlen(fileName)-4), ".md2", 4))
     215  else if (!strncmp(fileName.c_str()+(fileName.size()-4), ".md2", 4))
    252216    tmpType = MD2;
    253   else if (!strcasecmp(fileName, "cube") ||
    254            !strcasecmp(fileName, "sphere") ||
    255            !strcasecmp(fileName, "plane") ||
    256            !strcasecmp(fileName, "cylinder") ||
    257            !strcasecmp(fileName, "cone"))
     217  else if (!strcasecmp(fileName.c_str(), "cube") ||
     218            !strcasecmp(fileName.c_str(), "sphere") ||
     219            !strcasecmp(fileName.c_str(), "plane") ||
     220            !strcasecmp(fileName.c_str(), "cylinder") ||
     221            !strcasecmp(fileName.c_str(), "cone"))
    258222    tmpType = PRIM;
    259223#endif /* NO_MODEL */
     
    263227#endif
    264228#define __IF_OK
    265     if (!strncasecmp(fileName+(strlen(fileName)-4), ".wav", 4))
     229    if (!strncasecmp(fileName.c_str()+(fileName.size()-4), ".wav", 4))
    266230      tmpType = WAV;
    267     else if (!strncasecmp(fileName+(strlen(fileName)-4), ".mp3", 4))
     231    else if (!strncasecmp(fileName.c_str()+(fileName.size()-4), ".mp3", 4))
    268232      tmpType = MP3;
    269     else if (!strncasecmp(fileName+(strlen(fileName)-4), ".ogg", 4))
     233    else if (!strncasecmp(fileName.c_str()+(fileName.size()-4), ".ogg", 4))
    270234      tmpType = OGG;
    271235#endif /* NO_AUDIO */
     
    275239#endif
    276240#define __IF_OK
    277       if (!strncasecmp(fileName+(strlen(fileName)-4), ".ttf", 4))
     241      if (!strncasecmp(fileName.c_str()+(fileName.size()-4), ".ttf", 4))
    278242        tmpType = TTF;
    279243#endif /* NO_TEXT */
     
    283247#endif
    284248#define __IF_OK
    285         if (!strncasecmp(fileName+(strlen(fileName)-5), ".vert", 5))
     249        if (!strncasecmp(fileName.c_str()+(fileName.size()-5), ".vert", 5))
    286250          tmpType = SHADER;
    287251#endif /* NO_SHADERS */
     
    308272 * during the initialisation instead of at Runtime.
    309273 */
    310 bool ResourceManager::cache(const char* fileName, ResourceType type, ResourcePriority prio,
     274bool ResourceManager::cache(const std::string& fileName, ResourceType type, ResourcePriority prio,
    311275                            const MultiType& param0, const MultiType& param1, const MultiType& param2)
    312276{
    313   assert(fileName != NULL);
    314 
    315277  // searching if the resource was loaded before.
    316278  Resource* tmpResource;
     
    359321 * @returns a pointer to a desired Resource.
    360322*/
    361 BaseObject* ResourceManager::load(const char* fileName, ResourceType type, ResourcePriority prio,
     323BaseObject* ResourceManager::load(const std::string& fileName, ResourceType type, ResourcePriority prio,
    362324                                  const MultiType& param0, const MultiType& param1, const MultiType& param2)
    363325{
    364   assert(fileName != NULL);
    365 
    366326  // searching if the resource was loaded before.
    367327  Resource* tmpResource;
     
    397357 * @returns a pointer to a desired Resource.
    398358 */
    399 Resource* ResourceManager::loadResource(const char* fileName, ResourceType type, ResourcePriority prio,
     359Resource* ResourceManager::loadResource(const std::string& fileName, ResourceType type, ResourcePriority prio,
    400360                                        const MultiType& param0, const MultiType& param1, const MultiType& param2)
    401361{
     
    406366  tmpResource->prio = prio;
    407367  tmpResource->pointer = NULL;
    408   tmpResource->name = new char[strlen(fileName)+1];
    409   strcpy(tmpResource->name, fileName);
     368  tmpResource->name = fileName;
    410369
    411370  // creating the full name. (directoryName + FileName)
    412   char* fullName = ResourceManager::getFullName(fileName);
     371  std::string fullName = ResourceManager::getFullName(fileName);
    413372  // Checking for the type of resource \see ResourceType
    414373  switch(type)
     
    425384      else
    426385      {
    427         PRINTF(2)("File %s in %s does not exist. Loading a cube-Model instead\n", fileName, dataDir);
     386        PRINTF(2)("File %s in %s does not exist. Loading a cube-Model instead\n", fileName.c_str(), dataDir.c_str());
    428387        tmpResource->pointer = ResourceManager::load("cube", PRIM, prio, tmpResource->param[0].getFloat());
    429388      }
     
    435394        tmpResource->param[0] = 1.0f;
    436395
    437       if (!strcmp(tmpResource->name, "cube"))
     396      if (tmpResource->name == "cube")
    438397        tmpResource->pointer = new PrimitiveModel(PRIM_CUBE, tmpResource->param[0].getFloat());
    439       else if (!strcmp(tmpResource->name, "sphere"))
     398      else if (tmpResource->name == "sphere")
    440399        tmpResource->pointer = new PrimitiveModel(PRIM_SPHERE, tmpResource->param[0].getFloat());
    441       else if (!strcmp(tmpResource->name, "plane"))
     400      else if (tmpResource->name == "plane")
    442401        tmpResource->pointer = new PrimitiveModel(PRIM_PLANE, tmpResource->param[0].getFloat());
    443       else if (!strcmp(tmpResource->name, "cylinder"))
     402      else if (tmpResource->name == "cylinder")
    444403        tmpResource->pointer = new PrimitiveModel(PRIM_CYLINDER, tmpResource->param[0].getFloat());
    445       else if (!strcmp(tmpResource->name, "cone"))
     404      else if (tmpResource->name == "cone")
    446405        tmpResource->pointer = new PrimitiveModel(PRIM_CONE, tmpResource->param[0].getFloat());
    447406      break;
     
    468427        tmpResource->pointer = new Font(fullName, (unsigned int) tmpResource->param[0].getInt());
    469428      else
    470         PRINTF(2)("%s does not exist in %s. Not loading Font\n", fileName, this->dataDir);
     429        PRINTF(2)("%s does not exist in %s. Not loading Font\n", fileName.c_str(), this->dataDir.c_str());
    471430      break;
    472431#endif /* NO_TEXT */
     
    494453      else
    495454      {
    496         std::vector<char*>::iterator imageDir;
     455        std::vector<std::string>::iterator imageDir;
    497456        for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++)
    498457        {
    499           char* imgName = new char[strlen(*imageDir)+strlen(fileName)+1];
    500           sprintf(imgName, "%s%s", *imageDir, fileName);
     458          std::string imgName = *imageDir + fileName;
    501459          if(isFile(imgName))
    502460          {
    503461            PRINTF(4)("Image %s resides to %s\n", fileName, imgName);
    504462            tmpResource->pointer = new Texture(imgName, tmpResource->param[0].getInt());
    505             delete[] imgName;
    506463            break;
    507464          }
    508           delete[] imgName;
    509465        }
    510466      }
    511467      if(!tmpResource)
    512         PRINTF(2)("!!Image %s not Found!!\n", fileName);
     468        PRINTF(2)("!!Image %s not Found!!\n", fileName.c_str());
    513469      break;
    514470#endif /* NO_TEXTURES */
     
    520476        {
    521477          MultiType param = param0; /// HACK
    522           char* secFullName = ResourceManager::getFullName(param.getCString());
     478          std::string secFullName = ResourceManager::getFullName(param.getCString());
    523479          if (ResourceManager::isFile(secFullName))
    524480          {
     
    526482            tmpResource->pointer = new Shader(fullName, secFullName);
    527483          }
    528           delete[] secFullName;
    529484        }
    530485        else
     
    538493    default:
    539494      tmpResource->pointer = NULL;
    540       PRINTF(1)("No type found for %s.\n   !!This should not happen unless the Type is not supported yet. JUST DO IT!!\n", tmpResource->name);
     495      PRINTF(1)("No type found for %s.\n   !!This should not happen unless the Type is not supported yet. JUST DO IT!!\n", tmpResource->name.c_str());
    541496      break;
    542497  }
    543498  if (tmpResource->pointer != NULL)
    544499    this->resourceList.push_back(tmpResource);
    545   delete[] fullName;
    546 
    547500
    548501  if (tmpResource->pointer != NULL)
     
    550503  else
    551504  {
    552     PRINTF(2)("Resource %s could not be loaded\n", fileName);
    553     delete[] tmpResource->name;
     505    PRINTF(2)("Resource %s could not be loaded\n", fileName.c_str());
    554506    delete tmpResource;
    555507    return NULL;
     
    597549      delete resource->pointer;
    598550      // deleting the List Entry:
    599       PRINTF(4)("Resource %s safely removed.\n", resource->name);
    600       delete[] resource->name;
     551      PRINTF(4)("Resource %s safely removed.\n", resource->name.c_str());
    601552      std::vector<Resource*>::iterator resourceIT = std::find(this->resourceList.begin(), this->resourceList.end(), resource);
    602553      this->resourceList.erase(resourceIT);
     
    604555    }
    605556    else
    606       PRINTF(4)("Resource %s not removed, because there are still %d References to it.\n", resource->name, resource->count);
    607   }
    608   else
    609     PRINTF(4)("not deleting resource %s because DeleteLevel to high\n", resource->name);
     557      PRINTF(4)("Resource %s not removed, because there are still %d References to it.\n", resource->name.c_str(), resource->count);
     558  }
     559  else
     560    PRINTF(4)("not deleting resource %s because DeleteLevel to high\n", resource->name.c_str());
    610561  return true;
    611562}
     
    633584          if (round == 3)
    634585            PRINTF(2)("unable to unload %s because there are still %d references to it\n",
    635                       this->resourceList[index]->name, this->resourceList[index]->count);
     586                      this->resourceList[index]->name.c_str(), this->resourceList[index]->count);
    636587          removeCount++;
    637588        }
     
    653604 * @returns a Pointer to the Resource if found, NULL otherwise.
    654605*/
    655 Resource* ResourceManager::locateResourceByInfo(const char* fileName, ResourceType type,
     606Resource* ResourceManager::locateResourceByInfo(const std::string& fileName, ResourceType type,
    656607    const MultiType& param0, const MultiType& param1, const MultiType& param2) const
    657608{
     
    659610  for (resource = this->resourceList.begin(); resource != this->resourceList.end(); resource++)
    660611  {
    661     if ((*resource)->type == type && !strcmp(fileName, (*resource)->name))
     612    if ((*resource)->type == type && fileName == (*resource)->name)
    662613    {
    663614      bool match = false;
     
    743694}
    744695
    745 char* ResourceManager::toResourcableString(unsigned int i)
    746 {
    747   int len = strlen(ResourceManager::ResourceTypeToChar(this->resourceList[i]->type));
    748   len += strlen(this->resourceList[i]->name);
     696std::string ResourceManager::toResourcableString(unsigned int i)
     697{
     698/*  int len = strlen(ResourceManager::ResourceTypeToChar(this->resourceList[i]->type));
     699  len += this->resourceList[i]->name.size();
    749700  if (this->resourceList[i]->param[0].getCString()) len += strlen(this->resourceList[i]->param[0].getCString()) +1;
    750701  if (this->resourceList[i]->param[1].getCString()) len += strlen(this->resourceList[i]->param[1].getCString()) +1;
    751702  if (this->resourceList[i]->param[2].getCString()) len += strlen(this->resourceList[i]->param[2].getCString()) +1;
    752703  len += 10;
    753   char* tmp = new char[len];
     704  std::string tmp = new char[len];
    754705  tmp[0] = '\0';
    755   strcat( tmp, ResourceManager::ResourceTypeToChar(this->resourceList[i]->type));
     706  strcat(tmp, ResourceManager::ResourceTypeToChar(this->resourceList[i]->type));
    756707  strcat(tmp,",");
    757708  strcat (tmp, this->resourceList[i]->name);
     
    771722    strcat( tmp, this->resourceList[i]->param[2].getCString());
    772723  }
    773   return tmp;
     724  return tmp;*/
    774725}
    775726
     
    778729 * @param resourceableString the String to cache the resource from.
    779730 */
    780 bool ResourceManager::fromResourceableString(const char* resourceableString)
    781 {
    782   SubString splits(resourceableString, ',');
     731bool ResourceManager::fromResourceableString(const std::string& resourceableString)
     732{
     733/*  SubString splits(resourceableString, ',');
    783734  splits.debug();
    784735  if (splits.getCount() == 2)
     
    793744  else if (splits.getCount() == 5)
    794745    return this->cache(splits[1], ResourceManager::stringToResourceType(splits[0]),
    795                 RP_LEVEL, splits[2], splits[3], splits[4]);
     746                RP_LEVEL, splits[2], splits[3], splits[4]);*/
    796747}
    797748
     
    802753 * @returns true if it is a directory/symlink false otherwise
    803754*/
    804 bool ResourceManager::isDir(const char* directoryName)
    805 {
    806   if (directoryName == NULL)
    807     return false;
    808 
    809   char* tmpDirName = NULL;
     755bool ResourceManager::isDir(const std::string& directoryName)
     756{
     757  std::string tmpDirName = directoryName;
    810758  struct stat status;
    811759
    812760  // checking for the termination of the string given. If there is a "/" at the end cut it away
    813   if (directoryName[strlen(directoryName)-1] == '/' ||
    814       directoryName[strlen(directoryName)-1] == '\\')
    815   {
    816     tmpDirName = new char[strlen(directoryName)];
    817     strncpy(tmpDirName, directoryName, strlen(directoryName)-1);
    818     tmpDirName[strlen(directoryName)-1] = '\0';
    819   }
    820   else
    821   {
    822     tmpDirName = new char[strlen(directoryName)+1];
    823     strcpy(tmpDirName, directoryName);
    824   }
    825 
    826   if(!stat(tmpDirName, &status))
     761  if (directoryName[directoryName.size()-1] == '/' ||
     762      directoryName[directoryName.size()-1] == '\\')
     763  {
     764    tmpDirName.erase(tmpDirName.size()-1);
     765  }
     766
     767  if(!stat(tmpDirName.c_str(), &status))
    827768  {
    828769    if (status.st_mode & (S_IFDIR
     
    832773                         ))
    833774    {
    834       delete[] tmpDirName;
    835775      return true;
    836776    }
    837777    else
    838     {
    839       delete[] tmpDirName;
    840778      return false;
    841     }
    842   }
    843   else
    844   {
    845     delete[] tmpDirName;
    846     return false;
    847   }
     779  }
     780  else
     781    return false;
    848782}
    849783
     
    853787 * @returns true if it is a regular file/symlink, false otherwise
    854788*/
    855 bool ResourceManager::isFile(const char* fileName)
    856 {
    857   if (fileName == NULL)
    858     return false;
    859   char* tmpFileName = ResourceManager::homeDirCheck(fileName);
     789bool ResourceManager::isFile(const std::string& fileName)
     790{
     791  std::string tmpFileName = ResourceManager::homeDirCheck(fileName);
    860792  // actually checks the File
    861793  struct stat status;
    862   if (!stat(tmpFileName, &status))
     794  if (!stat(tmpFileName.c_str(), &status))
    863795  {
    864796    if (status.st_mode & (S_IFREG
     
    868800                         ))
    869801    {
    870       delete[] tmpFileName;
    871802      return true;
    872803    }
    873804    else
    874     {
    875       delete[] tmpFileName;
    876805      return false;
    877     }
    878   }
    879   else
    880   {
    881     delete[] tmpFileName;
    882     return false;
    883   }
     806  }
     807  else
     808    return false;
    884809}
    885810
     
    888813 * @param fileName The file to touch
    889814*/
    890 bool ResourceManager::touchFile(const char* fileName)
    891 {
    892   char* tmpName = ResourceManager::homeDirCheck(fileName);
    893   if (tmpName == NULL)
     815bool ResourceManager::touchFile(const std::string& fileName)
     816{
     817  std::string tmpName = ResourceManager::homeDirCheck(fileName);
     818  if (tmpName.empty())
    894819    return false;
    895820  FILE* stream;
    896   if( (stream = fopen (tmpName, "w")) == NULL)
    897   {
    898     PRINTF(1)("could not open %s fro writing\n", fileName);
    899     delete[] tmpName;
     821  if( (stream = fopen (tmpName.c_str(), "w")) == NULL)
     822  {
     823    PRINTF(1)("could not open %s fro writing\n", fileName.c_str());
    900824    return false;
    901825  }
    902826  fclose(stream);
    903 
    904   delete[] tmpName;
    905827}
    906828
     
    909831 * @param fileName the File to delete
    910832*/
    911 bool ResourceManager::deleteFile(const char* fileName)
    912 {
    913   if (fileName == NULL)
    914     return false;
    915   char* tmpName = ResourceManager::homeDirCheck(fileName);
    916   unlink(tmpName);
    917   delete[] tmpName;
     833bool ResourceManager::deleteFile(const std::string& fileName)
     834{
     835  std::string tmpName = ResourceManager::homeDirCheck(fileName);
     836  unlink(tmpName.c_str());
    918837}
    919838
     
    923842 * IMPORTANT: this has to be deleted from the outside
    924843 */
    925 char* ResourceManager::homeDirCheck(const char* name)
    926 {
    927   if (name == NULL)
    928     return NULL;
    929   char* retName;
    930   if (!strncmp(name, "~/", 2))
     844std::string ResourceManager::homeDirCheck(const std::string& name)
     845{
     846  std::string retName;
     847  if (!strncmp(name.c_str(), "~/", 2))
    931848  {
    932849    char tmpFileName[500];
     
    936853    strcpy(tmpFileName, getenv("HOME"));
    937854#endif
    938     retName = new char[strlen(tmpFileName)+strlen(name)];
    939     sprintf(retName, "%s%s", tmpFileName, name+1);
    940   }
    941   else
    942   {
    943     retName = new char[strlen(name)+1];
    944     strcpy(retName, name);
     855    retName = tmpFileName + name;
     856  }
     857  else
     858  {
     859    retName = name;
    945860  }
    946861  return retName;
     
    949864/**
    950865 * @param name the relative name of the File/Directory.
    951  * @returns a new char* with the name in abs-dir-format
    952  */
    953 char* ResourceManager::getAbsDir(const char* name)
    954 {
    955   if (name == NULL)
    956     return NULL;
    957   char* retName;
    958   if (strncmp(name, "/", 1))
    959   {
    960     if (*name == '.' && *(name+1) != '.')
    961       name++;
    962     const char* absDir = ResourceManager::cwd();
    963     retName = new char[strlen(absDir)+strlen(name)+1];
    964     sprintf(retName, "%s%s", absDir, name);
    965   }
    966   else
    967   {
    968     retName = new char[strlen(name)+1];
    969     strcpy(retName, name);
     866 * @returns a new std::string with the name in abs-dir-format
     867 */
     868std::string ResourceManager::getAbsDir(const std::string& name)
     869{
     870  if (name.empty())
     871    return "";
     872  std::string retName = name;
     873  if (strncmp(name.c_str(), "/", 1))
     874  {
     875    if (name[0] == '.' && name[1] != '.')
     876      retName.erase(0);
     877    const std::string& absDir = ResourceManager::cwd();
     878    retName = absDir + retName;
    970879  }
    971880  return retName;
     
    978887 * !!IMPORTANT: this has to be deleted from the outside!!
    979888*/
    980 char* ResourceManager::getFullName(const char* fileName)
    981 {
    982   if (fileName == NULL || ResourceManager::getInstance()->getDataDir() == NULL)
     889std::string ResourceManager::getFullName(const std::string& fileName)
     890{
     891  if (fileName.empty() || ResourceManager::getInstance()->getDataDir().empty())
    983892    return NULL;
    984893
    985   char* retName = new char[strlen(ResourceManager::getInstance()->getDataDir())
    986                            + strlen(fileName) + 1];
    987   sprintf(retName, "%s%s", ResourceManager::getInstance()->getDataDir(), fileName);
     894  std::string retName = ResourceManager::getInstance()->getDataDir() +fileName;
    988895  if (ResourceManager::isFile(retName) || ResourceManager::isDir(retName))
    989896    return retName;
    990897  else
    991   {
    992     delete[] retName;
    993898    return NULL;
    994   }
    995899}
    996900
     
    1005909 * @returns the Current Woring Directory
    1006910 */
    1007 const char* ResourceManager::cwd()
    1008 {
    1009   if (ResourceManager::getInstance()->_cwd == NULL)
     911const std::string& ResourceManager::cwd()
     912{
     913  if (ResourceManager::getInstance()->_cwd.empty())
    1010914  {
    1011915    char cwd[1024];
    1012916    char* errorCode = getcwd(cwd, 1024);
    1013917    if (errorCode == 0)
    1014       return NULL;
    1015 
    1016     ResourceManager::getInstance()->_cwd = new char[strlen(cwd)+1];
    1017     strcpy(ResourceManager::getInstance()->_cwd, cwd);
     918      return ResourceManager::getInstance()->_cwd;
     919
     920    ResourceManager::getInstance()->_cwd = cwd;
    1018921  }
    1019922  return ResourceManager::getInstance()->_cwd;
     
    1026929 * @returns true if the file exists, false otherwise
    1027930 */
    1028 bool ResourceManager::isInDataDir(const char* fileName)
    1029 {
    1030   if (fileName == NULL || ResourceManager::getInstance()->getDataDir() == NULL)
     931bool ResourceManager::isInDataDir(const std::string& fileName)
     932{
     933  if (fileName.empty() || ResourceManager::getInstance()->getDataDir().empty())
    1031934    return false;
    1032935
    1033936  bool retVal = false;
    1034   char* checkFile = new char[strlen(ResourceManager::getInstance()->getDataDir())
    1035                              + strlen(fileName) + 1];
    1036   sprintf(checkFile, "%s%s", ResourceManager::getInstance()->getDataDir(), fileName);
     937  std::string checkFile = ResourceManager::getInstance()->getDataDir() + fileName;
    1037938
    1038939  if (ResourceManager::isFile(checkFile) || ResourceManager::isDir(checkFile))
     
    1040941  else
    1041942    retVal = false;
    1042   delete[] checkFile;
    1043943  return retVal;
    1044944}
     
    1055955  // if it is not initialized
    1056956  PRINT(0)(" Reference is: %p\n", ResourceManager::singletonRef);
    1057   PRINT(0)(" Data-Directory is: %s\n", this->dataDir);
     957  PRINT(0)(" Data-Directory is: %s\n", this->dataDir.c_str());
    1058958  PRINT(0)(" List of Image-Directories: ");
    1059   std::vector<char*>::const_iterator imageDir;
     959  std::vector<std::string>::const_iterator imageDir;
    1060960  for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++)
    1061     PRINT(0)("%s ", (*imageDir));
     961    PRINT(0)("%s ", (*imageDir).c_str());
    1062962  PRINT(0)("\n");
    1063963
     
    1068968  {
    1069969    PRINT(0)("-----------------------------------------\n");
    1070     PRINT(0)("Name: %s; References: %d; Type: %s ", (*resource)->name, (*resource)->count, ResourceManager::ResourceTypeToChar((*resource)->type));
     970    PRINT(0)("Name: %s; References: %d; Type: %s ", (*resource)->name.c_str(), (*resource)->count, ResourceManager::ResourceTypeToChar((*resource)->type));
    1071971
    1072972    PRINT(0)("gets deleted at ");
  • branches/std/src/lib/util/loading/resource_manager.h

    r7196 r7203  
    7171  unsigned int      count;             //!< How many times this Resource has been loaded.
    7272
    73   char*             name;              //!< Name of the Resource.
     73  std::string       name;              //!< Name of the Resource.
    7474  ResourceType      type;              //!< ResourceType of this Resource.
    7575  ResourcePriority  prio;              //!< The Priority of this resource. (This will only be increased)
     
    9696  inline static ResourceManager* getInstance() { if (!singletonRef) singletonRef = new ResourceManager();  return singletonRef; };
    9797
    98   bool setDataDir(const char* dataDir);
     98  bool setDataDir(const std::string& dataDir);
    9999  /** @returns the Name of the data directory */
    100   inline const char* getDataDir() const { return this->dataDir; };
     100  inline const std::string& getDataDir() const { return this->dataDir; };
    101101
    102102
    103   bool tryDataDir(const char* dataDir);
    104   bool verifyDataDir(const char* fileInside);
    105   bool addImageDir(const char* imageDir);
     103  bool tryDataDir(const std::string& dataDir);
     104  bool verifyDataDir(const std::string& fileInside);
     105  bool addImageDir(const std::string& imageDir);
    106106
    107   bool cache(const char* fileName, ResourceType type, ResourcePriority prio = RP_NO,
     107  bool cache(const std::string& fileName, ResourceType type, ResourcePriority prio = RP_NO,
    108108             const MultiType& param0 = MultiType(), const MultiType& param1 = MultiType(), const MultiType& param2 = MultiType());
    109109  BaseObject* copy(BaseObject* resourcePointer);
    110110
    111   BaseObject* load(const char* fileName, ResourcePriority prio = RP_NO,
     111  BaseObject* load(const std::string& fileName, ResourcePriority prio = RP_NO,
    112112                   const MultiType& param0 = MultiType(), const MultiType& param1 = MultiType(), const MultiType& param2 = MultiType());
    113   BaseObject* load(const char* fileName, ResourceType type, ResourcePriority prio = RP_NO,
     113  BaseObject* load(const std::string& fileName, ResourceType type, ResourcePriority prio = RP_NO,
    114114                   const MultiType& param0 = MultiType(), const MultiType& param1 = MultiType(), const MultiType& param2 = MultiType());
    115115  bool unload(BaseObject* pointer, ResourcePriority prio = RP_NO);
     
    117117  bool unloadAllByPriority(ResourcePriority prio);
    118118
    119   Resource* locateResourceByInfo(const char* fileName, ResourceType type,
     119  Resource* locateResourceByInfo(const std::string& fileName, ResourceType type,
    120120                                 const MultiType& param0 = MultiType(), const MultiType& param1 = MultiType(), const MultiType& param2 = MultiType()) const;
    121121  Resource* locateResourceByPointer(const void* pointer) const;
    122122
    123   char* toResourcableString(unsigned int i);
    124   bool fromResourceableString(const char* resourceableString);
     123  std::string toResourcableString(unsigned int i);
     124  bool fromResourceableString(const std::string& resourceableString);
    125125  /** @returns the Count of Resources the ResourceManager handles */
    126126  unsigned int resourceCount() const { return this->resourceList.size(); }
     
    130130
    131131  // utility functions for handling files in and around the data-directory
    132   static bool isDir(const char* directory);
    133   static bool isFile(const char* fileName);
    134   static bool touchFile(const char* fileName);
    135   static bool deleteFile(const char* fileName);
    136   static char* homeDirCheck(const char* fileName);
    137   static char* getFullName(const char* fileName);
    138   static bool isInDataDir(const char* fileName);
    139   static char* getAbsDir(const char* fileName);
    140   static const char* cwd();
     132  static bool isDir(const std::string& directory);
     133  static bool isFile(const std::string& fileName);
     134  static bool touchFile(const std::string& fileName);
     135  static bool deleteFile(const std::string& fileName);
     136  static std::string homeDirCheck(const std::string& fileName);
     137  static std::string getFullName(const std::string& fileName);
     138  static bool isInDataDir(const std::string& fileName);
     139  static std::string getAbsDir(const std::string& fileName);
     140  static const std::string& cwd();
    141141
    142142  static const char* ResourceTypeToChar(ResourceType type);
     
    145145 private:
    146146  ResourceManager();
    147   Resource* loadResource(const char* fileName, ResourceType type, ResourcePriority prio,
     147  Resource* loadResource(const std::string& fileName, ResourceType type, ResourcePriority prio,
    148148                         const MultiType& param0, const MultiType& param1, const MultiType& param2);
    149149
    150150 private:
    151   static ResourceManager*  singletonRef;       //!< singleton Reference
     151  static ResourceManager*    singletonRef;       //!< singleton Reference
    152152
    153   char*                    _cwd;               //!< The currend Working directory.
    154   char*                    dataDir;            //!< The Data Directory, where all relevant Data is stored.
    155   std::vector<char*>       imageDirs;          //!< A list of directories in which images are stored.
     153  std::string                _cwd;               //!< The currend Working directory.
     154  std::string                dataDir;            //!< The Data Directory, where all relevant Data is stored.
     155  std::vector<std::string>   imageDirs;          //!< A list of directories in which images are stored.
    156156
    157   std::vector<Resource*>   resourceList;       //!< The List of Resources, that has already been loaded.
     157  std::vector<Resource*>     resourceList;       //!< The List of Resources, that has already been loaded.
    158158
    159   static const char*       resourceNames[RESOURCE_TYPE_SIZE];
     159  static const char*         resourceNames[RESOURCE_TYPE_SIZE];
    160160};
    161161
  • branches/std/src/orxonox.cc

    r7193 r7203  
    8686  this->port = -1;
    8787
    88   this->configFileName = NULL;
     88  this->configFileName = "";
    8989}
    9090
     
    117117  // orxonox class-stuff
    118118  delete this->iniParser;
    119   delete[] this->configFileName;
    120119
    121120  SDL_QuitSubSystem(SDL_INIT_TIMER);
     
    162161
    163162/**
    164  * this finds the config file
     163 * @brief this finds the config file
    165164 * @returns the new config-fileName
    166165 * Since the config file varies from user to user and since one may want to specify different config files
     
    168167 * it's path and name into configfilename
    169168*/
    170 const char* Orxonox::getConfigFile ()
     169const std::string& Orxonox::getConfigFile ()
    171170{
    172171  if (ResourceManager::isFile("orxonox.conf"))
    173172  {
    174     this->configFileName = new char[strlen("orxonox.conf")+1];
    175     strcpy(this->configFileName, "orxonox.conf");
     173    this->configFileName =  "orxonox.conf";
    176174  }
    177175  else
     
    231229  GraphicsEngine::getInstance()->initFromIniFile(this->iniParser);
    232230
    233   char* iconName = ResourceManager::getFullName("pictures/fighter-top-32x32.bmp");
    234   if (iconName != NULL)
     231  std::string iconName = ResourceManager::getFullName("pictures/fighter-top-32x32.bmp");
     232  if (!iconName.empty())
    235233  {
    236234    GraphicsEngine::getInstance()->setWindowName(PACKAGE_NAME " " PACKAGE_VERSION, iconName);
    237     delete[] iconName;
    238235  }
    239236  return 0;
     
    301298
    302299  // init the resource manager
    303   const char* dataPath;
    304   if ((dataPath = this->iniParser->getVar(CONFIG_NAME_DATADIR, CONFIG_SECTION_DATA))!= NULL)
     300  std::string dataPath;
     301  if ((dataPath = this->iniParser->getVar(CONFIG_NAME_DATADIR, CONFIG_SECTION_DATA))!= "")
    305302  {
    306303    if (!ResourceManager::getInstance()->setDataDir(dataPath) &&
    307304        !ResourceManager::getInstance()->verifyDataDir(DEFAULT_DATA_DIR_CHECKFILE))
    308305    {
    309       PRINTF(1)("Data Could not be located in %s\n", dataPath);
     306      PRINTF(1)("Data Could not be located in %s\n", dataPath.c_str());
    310307    }
    311308  }
     
    315312    PRINTF(1)("The DataDirectory %s could not be verified\n\nh" \
    316313              "!!!  Please Change in File %s Section %s Entry %s to a suitable value !!!\n",
    317               ResourceManager::getInstance()->getDataDir(),
    318               this->configFileName,
     314    ResourceManager::getInstance()->getDataDir().c_str(),
     315    this->configFileName.c_str(),
    319316              CONFIG_SECTION_DATA,
    320317              CONFIG_NAME_DATADIR );
     
    325322  }
    326323  //! @todo this is a hack and should be loadable
    327   char* imageDir = ResourceManager::getInstance()->getFullName("maps");
     324  std::string imageDir = ResourceManager::getInstance()->getFullName("maps");
    328325  ResourceManager::getInstance()->addImageDir(imageDir);
    329   delete[] imageDir;
    330326  imageDir = ResourceManager::getInstance()->getFullName("pictures");
    331327  ResourceManager::getInstance()->addImageDir(imageDir);
    332   delete[] imageDir;
    333328
    334329  DynamicLoader::loadDyLib("libtest.so");
  • branches/std/src/orxonox.h

    r5996 r7203  
    4141  int initMisc ();
    4242
    43   const char* getConfigFile ();
     43  const std::string& getConfigFile ();
    4444
    4545 private:
     
    4747
    4848  IniParser*        iniParser;               //!< Reference to the ini-parser used in orxonox
    49   char*             configFileName;          //!< Filename of the configuration-file.
     49  std::string       configFileName;          //!< Filename of the configuration-file.
    5050  GameLoader*       gameLoader;              //!< The gameLoader
    5151
  • branches/std/src/story_entities/game_world.cc

    r7193 r7203  
    145145  GameLoader* loader = GameLoader::getInstance();
    146146
    147   if( getLoadFile() == NULL)
     147  if( getLoadFile().empty())
    148148  {
    149149    PRINTF(1)("GameWorld has no path specified for loading\n");
     
    155155  if( !XMLDoc->LoadFile())
    156156  {
    157     PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getLoadFile(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
     157    PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getLoadFile().c_str(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
    158158    delete XMLDoc;
    159159    return (ErrorMessage){213,"XML File parsing error","GameWorld::load()"};
  • branches/std/src/story_entities/game_world_data.cc

    r7193 r7203  
    129129  // load the parameters
    130130  // name
    131   const char* string = grabParameter( root, "name");
    132   if( string == NULL)
     131  std::string string = grabParameter( root, "name");
     132  if( string.empty() )
    133133  {
    134134    PRINTF(2)("GameWorld is missing a proper 'name'\n");
     
    136136  }
    137137  else
    138     this->setName(string);
     138    this->setName(string.c_str());
    139139
    140140  this->loadGUI(root);
     
    363363  {
    364364    PRINTF(3)("Setting Sound Track to %s\n", name);
    365     char* oggFile = ResourceManager::getFullName(name); /// FIXME
     365    std::string oggFile = ResourceManager::getFullName(name);
    366366    this->music = new OggPlayer(oggFile);
    367     delete[] oggFile;
    368367
    369368    //(OggPlayer*)ResourceManager::getInstance()->load(name, OGG, RP_LEVEL);
  • branches/std/src/story_entities/story_entity.cc

    r7193 r7203  
    4040  this->isRunning = false;
    4141
    42   this->loadFile = NULL;
     42  this->loadFile = "";
    4343  this->storyID = -1;
    4444  this->description = NULL;
     
    100100 * @param name the name of the path
    101101 */
    102 void StoryEntity::setLoadFile(const char* fileName)
    103 {
    104   if (this->loadFile)
    105     delete this->loadFile;
     102void StoryEntity::setLoadFile(const std::string& fileName)
     103{
    106104  if (ResourceManager::isFile(fileName))
    107105  {
    108     this->loadFile = new char[strlen(fileName)+1];
    109     strcpy(this->loadFile, fileName);
     106    this->loadFile =  fileName;
    110107  }
    111108  else
     
    149146{
    150147  PRINTF(3)("Grabbing the Worlds Settings\n", this->getLoadFile());
    151   if( getLoadFile() == NULL)
    152     return;
     148  if( getLoadFile().empty())
     149        return;
    153150  TiXmlDocument XMLDoc(this->getLoadFile());
    154151  // load the xml world file for further loading
    155152  if( !XMLDoc.LoadFile())
    156153  {
    157     PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc.ErrorDesc(), this->getLoadFile(), XMLDoc.ErrorRow(), XMLDoc.ErrorCol());
     154    PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc.ErrorDesc(), this->getLoadFile().c_str(), XMLDoc.ErrorRow(), XMLDoc.ErrorCol());
    158155    return;
    159156  }
  • branches/std/src/story_entities/story_entity.h

    r6993 r7203  
    6161  inline int getStoryID() { return this->storyID; }
    6262
    63   void setLoadFile( const char* fileName);
     63  void setLoadFile(const std::string& fileName);
    6464  /** @returns the Filename this StoryEntity was loaded with */
    65   const char* getLoadFile() const { return this->loadFile; }
     65  const std::string& getLoadFile() const { return this->loadFile; }
    6666
    6767  void setNextStoryID(int nextStoryID);
     
    8686
    8787  protected:
    88     bool isInit;            //!< if the entity is initialized, this has to be true.
    89     bool isRunning;         //!< is true if the entity is running
    90     bool isPaused;          //!< is true if the entity is paused
     88    bool          isInit;            //!< if the entity is initialized, this has to be true.
     89    bool          isRunning;         //!< is true if the entity is running
     90    bool          isPaused;          //!< is true if the entity is paused
    9191
    9292
    9393 private:
    94     int     storyID;          //!< this is the number of this entity, identifying it in a list/tree...
    95     int     nextStoryID;      //!< if this entity has finished, this entity shall be called
    96     char*   loadFile;         //!< The file from which this world is loaded
     94    int           storyID;          //!< this is the number of this entity, identifying it in a list/tree...
     95    int           nextStoryID;      //!< if this entity has finished, this entity shall be called
     96    std::string   loadFile;         //!< The file from which this world is loaded
    9797
    98     char*   description;      //!< the description of the StoryEntity
    99     char*   menuItemImage;    //!< the item image of the StoryEntity
    100     char*   menuScreenshoot;  //!< the screenshoot of the StoryEntity
    101     bool    bMenuEntry;       //!< If true, this GameWorld apears in the SimpleMenu: SimpleMenu specific
     98    char*         description;      //!< the description of the StoryEntity
     99    char*         menuItemImage;    //!< the item image of the StoryEntity
     100    char*         menuScreenshoot;  //!< the screenshoot of the StoryEntity
     101    bool          bMenuEntry;       //!< If true, this GameWorld apears in the SimpleMenu: SimpleMenu specific
    102102};
    103103
  • branches/std/src/world_entities/terrain.cc

    r7193 r7203  
    146146  this->heightMap = NULL;
    147147
    148   char* hmName = ResourceManager::getFullName(heightMapFile);
    149   char* hmColorName = ResourceManager::getFullName(colorMap);
     148  std::string hmName = ResourceManager::getFullName(heightMapFile);
     149  std::string hmColorName = ResourceManager::getFullName(colorMap);
    150150
    151151
     
    155155  heightMap->setAbsCoor(this->getAbsCoor());
    156156  heightMap->load();
    157   delete[] hmName;
    158   delete[] hmColorName;
    159 
    160157}
    161158
  • branches/std/src/world_entities/world_entity.cc

    r7198 r7203  
    575575    char* name = (char*)(getModel( 0 )->getName());
    576576
    577     if ( strstr(name, ResourceManager::getInstance()->getDataDir()) )
    578     {
    579       name += strlen(ResourceManager::getInstance()->getDataDir());
     577    if (  ResourceManager::getInstance()->getDataDir() == name ) /// FIXME (do not know what to do here.)
     578    {
     579      name += ResourceManager::getInstance()->getDataDir().size();
    580580    }
    581581
Note: See TracChangeset for help on using the changeset viewer.