PageRenderTime 41ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/ocaml/strings_test/example.h

#
C++ Header | 41 lines | 25 code | 9 blank | 7 comment | 2 complexity | 9df92ca56b296ecd4e75b84ef50eca4d MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* -*- mode: c++ -*- */
  2. /* File : example.h -- Tests all string typemaps */
  3. #include <sys/time.h>
  4. #include <time.h>
  5. void takes_std_string( std::string in ) {
  6. cout << "takes_std_string( \"" << in << "\" );" << endl;
  7. }
  8. std::string gives_std_string() {
  9. struct timeval tv;
  10. gettimeofday(&tv, NULL);
  11. return std::string( asctime( localtime( &tv.tv_sec ) ) );
  12. }
  13. void takes_char_ptr( char *p ) {
  14. cout << "takes_char_ptr( \"" << p << "\" );" << endl;
  15. }
  16. char *gives_char_ptr() {
  17. return "foo";
  18. }
  19. void takes_and_gives_std_string( std::string &inout ) {
  20. inout.insert( inout.begin(), '[' );
  21. inout.insert( inout.end(), ']' );
  22. }
  23. void takes_and_gives_char_ptr( char *&inout ) {
  24. char *pout = strchr( inout, '.' );
  25. if( pout ) inout = pout + 1;
  26. else inout = "foo";
  27. }
  28. /*
  29. * Local-Variables:
  30. * c-indentation-style: "stroustrup"
  31. * End:
  32. */