Synopsis - Cross-Reference

File: /tests/Cxx-API/Python/src/Object.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  Object object;
11  Object character('q');
12  std::cout << Object::narrow<char>(character) << std::endl;
13  std::cout << Object::narrow<std::string>(character.str()) << std::endl;
14  Object string("hello world");
15  std::cout << Object::narrow<std::string>(string) << std::endl;
16  std::cout << Object::narrow<std::string>(string.str()) << std::endl;
17  Object integer(42);
18  std::cout << Object::narrow<long>(integer) << std::endl;
19  std::cout << Object::narrow<std::string>(integer.str()) << std::endl;
20  try { std::cout << Object::narrow<long>(string) << std::endl;}
21  catch (Object::TypeError &e) { std::cout << e.what() << std::endl;}
22}
23
24int main(int, char **)
25{  
26  try
27  {
28    test1();
29  }
30  catch (const std::exception &e)
31  {
32    std::cout << "Error : " << e.what() << std::endl;
33  }
34}