! this method changes the name of a specific object */
| 293 | this method changes the name of a specific object |
| 294 | */ |
| 295 | ErrorCode EditName(const std::string & old_name, const std::string & new_name) |
| 296 | { |
| 297 | if( !IsNameCorrect(old_name) || !IsNameCorrect(new_name) ) |
| 298 | return err_incorrect_name; |
| 299 | |
| 300 | Iterator old_i = table.find(old_name); |
| 301 | if( old_i == table.end() ) |
| 302 | return err_unknown_object; |
| 303 | |
| 304 | if( old_name == new_name ) |
| 305 | // the new name is the same as the old one |
| 306 | // we treat it as a normal situation |
| 307 | return err_ok; |
| 308 | |
| 309 | ErrorCode err = Add(new_name, old_i->second.value, old_i->second.param); |
| 310 | |
| 311 | if( err == err_ok ) |
| 312 | { |
| 313 | old_i = table.find(old_name); |
| 314 | TTMATH_ASSERT( old_i != table.end() ) |
| 315 | |
| 316 | table.erase(old_i); |
| 317 | } |
| 318 | |
| 319 | return err; |
| 320 | } |
| 321 | |
| 322 | |
| 323 |