FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpptcl/examples/cpptcl_example_functions.cc at master · flightaware/cpptcl · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
flightaware
/
cpptcl
Public
Notifications
You must be signed in to change notification settings
Fork
12
Star
58
Code
Issues
1
Pull requests
1
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
cpptcl
/
examples
/
cpptcl_example_functions.cc
Copy path
More file actions
More file actions
Latest commit
History
History
History
53 lines (39 loc) · 1.51 KB
Breadcrumbs
cpptcl
/
examples
/
cpptcl_example_functions.cc
Copy path
File metadata and controls
53 lines (39 loc) · 1.51 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#
include
<
iostream
>
#
include
"
cpptcl/cpptcl.h
"
using
namespace
std
;
using
namespace
Tcl
;
void
hello
();
void
helloArray
(object
const
&name);
void
helloArray2
(object
const
&name, object
const
&address);
void
hello
() { cout <<
"
Hello C++/Tcl!
"
<< endl; }
void
helloProc
() {
Bind<
int
,
int
>
expr
(
"
expr
"
);
Bind<
double
,
double
,
double
>
pow
(
"
pow
"
);
int
v =
pow
(
2
,
5
);
cout <<
"
pow(2,5) ==
"
<< v <<
"
pow(5,2) =
"
<<
pow
(
5
,
2
) <<
"
expr {1} =
"
<<
expr
(
1
) << endl;
}
void
helloArray
(object
const
&name) { cout <<
"
Hello C++/Tcl! from array
"
<<
name
(
"
first
"
).
get
() <<
"
"
<<
name
(
"
last
"
).
get
() << endl; }
void
helloArray2
(object
const
&name, object
const
&address) {
cout <<
"
Hello C++/Tcl! from array
"
<<
name
(
"
first
"
).
get
() <<
"
"
<<
name
(
"
last
"
).
get
() << endl;
cout <<
"
city exists
"
<< address.
exists
(
"
city
"
) << endl;
cout <<
"
city
"
<<
address
(
"
city
"
).
get
() << endl;
std::string
state
(
"
state
"
);
//
Check for exists with if
if
(
address
(state)) {
//
C++ does not allow $ to be an operator, so use *
cout <<
"
state
"
<<
address
(state).
asString
() << endl;
}
//
TODO
//
address(state).set("TX");
cout <<
"
exists zip?
"
<< address.
exists
(
"
zip
"
) << endl;
cout <<
"
exception stack expected
"
<< endl;
std::string zip =
address
(
"
zip
"
).
asString
();
cout << zip << endl;
}
CPPTCL_MODULE
(Cpptcl_example_functions, i) {
i.
pkg_provide
(
"
cpptcl_example_functions
"
,
CPPTCL_EXAMPLE_FUNCTIONS_VERSION
);
i.
def
(
"
hello
"
, hello);
i.
def
(
"
helloProc
"
, helloProc);
i.
def
(
"
helloArray
"
, helloArray);
i.
def
(
"
helloArray2
"
, helloArray2);
}
Back
|
FazBrowse Home
|
New Git URL