diff options
| author | William S Fulton <wsf@fultondesigns.co.uk> | 2010-06-02 20:53:17 +0000 |
|---|---|---|
| committer | William S Fulton <wsf@fultondesigns.co.uk> | 2010-06-02 20:53:17 +0000 |
| commit | 2824b0cbb66e715490e1ef13250bd675d87b32d9 (patch) | |
| tree | c3bc8d54c6d73f2b7ce08cac34172dbc9f5e5b95 /trunk/Examples/ruby/mark_function/example.cxx | |
| parent | 289cfef4b4766ff266f3b1bdda8ca3a952e5a047 (diff) | |
| download | swig-2.0.0.tar.gz | |
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/tags/rel-2.0.0@12089 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'trunk/Examples/ruby/mark_function/example.cxx')
| -rw-r--r-- | trunk/Examples/ruby/mark_function/example.cxx | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/trunk/Examples/ruby/mark_function/example.cxx b/trunk/Examples/ruby/mark_function/example.cxx new file mode 100644 index 000000000..504e8fcbe --- /dev/null +++ b/trunk/Examples/ruby/mark_function/example.cxx @@ -0,0 +1,61 @@ +#include "example.h" + +Animal::Animal(const char* name) : name_(name) +{ +} + +Animal::~Animal() +{ + name_ = "Destroyed"; +} + +/* Return the animal's name */ +const char* Animal::get_name() const +{ + return name_.c_str(); +} + +Zoo::Zoo() +{ +} + +Zoo::~Zoo() +{ + return; +} + +/* Create a new animal. */ +Animal* Zoo::create_animal(const char* name) +{ + return new Animal(name); +} + +/* Add a new animal to the zoo. */ +void Zoo::add_animal(Animal* animal) +{ + animals.push_back(animal); +} + +Animal* Zoo::remove_animal(size_t i) +{ + /* Note a production implementation should check + for out of range errors. */ + Animal* result = this->animals[i]; + IterType iter = this->animals.begin(); + std::advance(iter, i); + this->animals.erase(iter); + + return result; +} + +/* Return the number of animals in the zoo. */ +size_t Zoo::get_num_animals() const +{ + return animals.size(); +} + +/* Return a pointer to the ith animal */ +Animal* Zoo::get_animal(size_t i) const +{ + return animals[i]; +} |
