Jpp
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JLang
JString.cc
Go to the documentation of this file.
1
2
#include <string>
3
#include <iostream>
4
#include <fstream>
5
#include <locale>
6
#include <iomanip>
7
8
#include "
JLang/JString.hh
"
9
10
#include "
Jeep/JParser.hh
"
11
#include "
Jeep/JMessage.hh
"
12
13
14
/**
15
* \file
16
*
17
* Example program to test JLANG::JString class.
18
* \author mdejong
19
*/
20
int
main
(
int
argc,
char
**argv)
21
{
22
using namespace
std;
23
using namespace
JPP;
24
25
int
debug
;
26
27
try
{
28
29
JParser<>
zap(
"Example program to test string operations."
);
30
31
zap[
'd'
] =
make_field
(
debug
) = 0;
32
33
zap(argc, argv);
34
}
35
catch
(
const
exception &error) {
36
FATAL
(error.what() << endl);
37
}
38
39
40
{
41
const
JString buffer(
"% = %;"
,
"key"
, 123);
42
43
DEBUG
(buffer << endl);
44
45
ASSERT
(buffer ==
"key = 123;"
,
"Test formatting"
);
46
}
47
48
{
49
JString buffer(
"Hello world."
);
50
51
DEBUG
(buffer << endl);
52
53
buffer.toUpper();
54
55
DEBUG
(buffer << endl);
56
57
ASSERT
(buffer ==
"HELLO WORLD."
,
"Test JString::toUpper()"
);
58
59
buffer.toLower();
60
61
DEBUG
(buffer << endl);
62
63
ASSERT
(buffer ==
"hello world."
,
"Test JString::toLower()"
);
64
}
65
66
{
67
JString buffer(
"a = %1; b = %2; c = %3;"
);
68
69
buffer.replace(
"%1"
, 3.1415).replace(
"%2"
,
"hello"
).replace(
"%3"
, 123);
70
71
DEBUG
(buffer << endl);
72
73
ASSERT
(buffer ==
"a = 3.1415; b = hello; c = 123;"
,
"Test JString::replace()"
);
74
}
75
76
77
{
78
int
i = JString::toValue<int>(
"1234"
);
79
80
DEBUG
(i << endl);
81
82
ASSERT
(i == 1234,
"Test JString::toValue<int>()"
);
83
}
84
85
{
86
JString buffer(
"1 3.1415 hello"
);
87
88
int
i;
89
double
d
;
90
string
w
;
91
92
buffer.assign(i).assign(d).assign(w);
93
94
DEBUG
(i <<
' '
<< d <<
' '
<< w << endl);
95
96
ASSERT
(i == 1 && d == 3.1415 && w ==
"hello"
,
"Test JString::assign()"
);
97
}
98
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1493
JTOOLS::w
data_type w[N+1][M+1]
Definition:
JPolint.hh:708
JString.hh
ASSERT
#define ASSERT(A,...)
Assert macro.
Definition:
JMessage.hh:90
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1954
d
then print_variable DETECTOR INPUT_FILE INTERMEDIATE_FILE check_input_file $DETECTOR $INPUT_FILE check_output_file $INTERMEDIATE_FILE $OUTPUT_FILE JMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
Definition:
JPath.sh:52
debug
int debug
debug level
Definition:
JSirene.cc:61
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JParser.hh
Utility class to parse command line options.
DEBUG
#define DEBUG(A)
Message macros.
Definition:
JMessage.hh:62
main
int main(int argc, char *argv[])
Definition:
Main.cpp:15
Generated by
1.8.5