RepastHPC  2.3.1
Utilities.h
1 /*
2  * Repast for High Performance Computing (Repast HPC)
3  *
4  * Copyright (c) 2010 Argonne National Laboratory
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with
8  * or without modification, are permitted provided that the following
9  * conditions are met:
10  *
11  * Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the following disclaimer.
13  *
14  * Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * Neither the name of the Argonne National Laboratory nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE TRUSTEES OR
26  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
32  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  *
35  * Utilities.h
36  *
37  * Created on: Oct 27, 2009
38  * Author: nick
39  */
40 
41 #ifndef UTILITIES_H_
42 #define UTILITIES_H_
43 
44 #include <string>
45 #include <vector>
46 #include <time.h>
47 
48 #include <boost/cstdint.hpp>
49 
50 namespace repast {
51 
56 class Timer {
57 
58 private:
59  clock_t startTime;
60 
61 public:
62  Timer();
63 
67  void start();
68 
76  long double stop();
77 };
78 
87 void tokenize(const std::string& str, std::vector<std::string>& tokens, const std::string& delimiters = " ");
88 
96 std::string trim(const std::string& str);
97 
105 boost::uint32_t strToUInt(const std::string& val);
106 
107 
115 int strToInt(const std::string& val);
116 
124 double strToDouble(const std::string& val);
125 
126 }
127 
128 #endif /* UTILITIES_H_ */
repast::Timer
Simple timing class.
Definition: Utilities.h:56
repast::Timer::start
void start()
Starts the timer.
Definition: Utilities.cpp:53
repast::Timer::stop
long double stop()
Stops the timer and returns the number of milliseconds elapsed since calling start().
Definition: Utilities.cpp:57