Synopsis - Cross-Reference

File: /tests/Cxx-API/Python/src/List.cc
 1#include <Synopsis/Python/Object.hh>
 2#include "Guard.hh"
 3#include <string>
 4#include <iostream>
 5
 6using namespace Synopsis::Python;
 7
 8void test1()
 9{
10  List list;
11  list.append('a');
12  list.append(1);
13  list.append("hello");
14  list.append("world");
15  std::cout << Object::narrow<std::string>(list.str()) << std::endl;
16  list.sort();
17  std::cout << Object::narrow<std::string>(list.str()) << std::endl;
18  list.reverse();
19  std::cout << Object::narrow<std::string>(list.str()) << std::endl;
20  Object o = list.get(0);
21  std::cout << Object::narrow<std::string>(o.str()) << std::endl;
22
23  for (List::iterator i = list.begin(); i != list.end(); ++i)
24    std::cout << Object::narrow<std::string>(i->str()) << std::endl;
25  for (List::reverse_iterator i = list.rbegin(); i != list.rend(); ++i)
26    std::cout << Object::narrow<std::string>(i->str()) << std::endl;
27  std::cout << *(list.begin() + 1) << ' ' << *(list.end() - 1) << std::endl;
28  std::cout << *(list.rbegin() + 1) << ' ' << *(list.rend() - 1) << std::endl;
29}
30
31int main(int, char **)
32{  
33  try
34  {
35    test1();
36  }
37  catch (const std::exception &e)
38  {
39    std::cout << "Error : " << e.what() << std::endl;
40  }
41}