PageRenderTime 14ms CodeModel.GetById 1ms app.highlight 8ms RepoModel.GetById 2ms 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
 1/* -*- mode: c++ -*- */
 2/* File : example.h -- Tests all string typemaps */
 3
 4#include <sys/time.h>
 5#include <time.h>
 6
 7void takes_std_string( std::string in ) {
 8    cout << "takes_std_string( \"" << in << "\" );" << endl;
 9}
10
11std::string gives_std_string() {
12    struct timeval tv;
13
14    gettimeofday(&tv, NULL);
15    return std::string( asctime( localtime( &tv.tv_sec ) ) );
16}
17
18void takes_char_ptr( char *p ) {
19    cout << "takes_char_ptr( \"" << p << "\" );" << endl;
20}
21
22char *gives_char_ptr() {
23    return "foo";
24}
25
26void takes_and_gives_std_string( std::string &inout ) {
27    inout.insert( inout.begin(), '[' );
28    inout.insert( inout.end(), ']' );
29}
30
31void takes_and_gives_char_ptr( char *&inout ) {
32    char *pout = strchr( inout, '.' );
33    if( pout ) inout = pout + 1;
34    else inout = "foo";
35}
36
37/*
38 * Local-Variables:
39 * c-indentation-style: "stroustrup"
40 * End:
41 */