summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2012-05-23 18:02:48 -0400
committerChris Dyer <cdyer@cs.cmu.edu>2012-05-23 18:02:48 -0400
commit570ba076cbe3b12c56b281da7c1892972e8598f1 (patch)
tree2678e7501e678a792f1a191774da0ca0b03ebb32 /utils
parentcf465121251cc3478b3f8a8ff1332ff2406b86ca (diff)
more bjam stuff, more cleanup
Diffstat (limited to 'utils')
-rw-r--r--utils/Jamfile4
-rw-r--r--utils/null_traits.h8
-rw-r--r--utils/stringlib.h14
3 files changed, 12 insertions, 14 deletions
diff --git a/utils/Jamfile b/utils/Jamfile
index 53a51277..4444b25f 100644
--- a/utils/Jamfile
+++ b/utils/Jamfile
@@ -24,11 +24,9 @@ lib utils :
..//z
: <include>.. <include>. : : <include>.. <include>. ;
-exe ts : ts.cc utils ;
exe atools : atools.cc utils ..//boost_program_options ;
-exe phmt : phmt.cc utils ;
exe reconstruct_weights : reconstruct_weights.cc utils ..//boost_program_options ;
alias programs : reconstruct_weights atools ;
-all_tests : utils ;
+all_tests [ glob *_test.cc phmt.cc ts.cc ] : utils : <testing.arg>$(TOP)/utils/test_data ;
diff --git a/utils/null_traits.h b/utils/null_traits.h
index fac857d9..7b2d32d0 100644
--- a/utils/null_traits.h
+++ b/utils/null_traits.h
@@ -3,23 +3,23 @@
template <class V>
struct null_traits {
- static V null; //TODO: maybe take out default null and make ppl explicitly define? they may be surprised that they need to when they include a header lib that uses null_traits
+ static V xnull; //TODO: maybe take out default null and make ppl explicitly define? they may be surprised that they need to when they include a header lib that uses null_traits
};
// global bool is_null(V const& v)
// definitely override this, and possibly set_null and is_null. that's the point.
template <class V>
-V null_traits<V>::null;
+V null_traits<V>::xnull;
//TODO: are we getting single init of the static null object?
template <class V>
void set_null(V &v) {
- v=null_traits<V>::null;
+ v=null_traits<V>::xnull;
}
template <class V>
void is_null(V const& v) {
- return v==null_traits<V>::null;
+ return v==null_traits<V>::xnull;
}
diff --git a/utils/stringlib.h b/utils/stringlib.h
index f457e1e4..13d14dbf 100644
--- a/utils/stringlib.h
+++ b/utils/stringlib.h
@@ -97,9 +97,9 @@ inline std::string Trim(const std::string& str, const std::string& dropChars = "
inline void Tokenize(const std::string& str, char delimiter, std::vector<std::string>* res) {
std::string s = str;
- int last = 0;
+ unsigned last = 0;
res->clear();
- for (int i=0; i < s.size(); ++i)
+ for (unsigned i=0; i < s.size(); ++i)
if (s[i] == delimiter) {
s[i]=0;
if (last != i) {
@@ -120,14 +120,14 @@ inline unsigned NTokens(const std::string& str, char delimiter)
inline std::string LowercaseString(const std::string& in) {
std::string res(in.size(),' ');
- for (int i = 0; i < in.size(); ++i)
+ for (unsigned i = 0; i < in.size(); ++i)
res[i] = tolower(in[i]);
return res;
}
inline std::string UppercaseString(const std::string& in) {
std::string res(in.size(),' ');
- for (int i = 0; i < in.size(); ++i)
+ for (unsigned i = 0; i < in.size(); ++i)
res[i] = toupper(in[i]);
return res;
}
@@ -146,8 +146,8 @@ inline int CountSubstrings(const std::string& str, const std::string& sub) {
inline int SplitOnWhitespace(const std::string& in, std::vector<std::string>* out) {
out->clear();
- int i = 0;
- int start = 0;
+ unsigned i = 0;
+ unsigned start = 0;
std::string cur;
while(i < in.size()) {
if (in[i] == ' ' || in[i] == '\t') {
@@ -249,7 +249,7 @@ inline void SplitCommandAndParam(const std::string& in, std::string* cmd, std::s
SplitOnWhitespace(in, &x);
if (x.size() == 0) return;
*cmd = x[0];
- for (int i = 1; i < x.size(); ++i) {
+ for (unsigned i = 1; i < x.size(); ++i) {
if (i > 1) { *param += " "; }
*param += x[i];
}