summaryrefslogtreecommitdiff
path: root/util.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-04-20 02:14:53 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:38:28 -0400
commitb84f676946941df6f7e8476d77d1db0cbe7736c5 (patch)
tree9ee7c7a2d3b7496b38ad127519210adfeced2241 /util.h
parent539370ff1b37772e9f11439f652ffd3583beeedb (diff)
downloadledger-b84f676946941df6f7e8476d77d1db0cbe7736c5.tar.gz
ledger-b84f676946941df6f7e8476d77d1db0cbe7736c5.tar.bz2
ledger-b84f676946941df6f7e8476d77d1db0cbe7736c5.zip
Did some optimization and memory cleanup
Diffstat (limited to 'util.h')
-rw-r--r--util.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/util.h b/util.h
index dc14547a..ec591ce2 100644
--- a/util.h
+++ b/util.h
@@ -3,6 +3,8 @@
#include <iostream>
+#include "trace.h"
+
#if defined __FreeBSD__ && __FreeBSD__ <=4
// FreeBSD has a broken isspace macro, so dont use it
#undef isspace(c)
@@ -26,6 +28,8 @@ typedef std::istream::pos_type istream_pos_type;
typedef std::ostream::pos_type ostream_pos_type;
#endif
+namespace ledger {
+
inline char * skip_ws(char * ptr) {
while (*ptr == ' ' || *ptr == '\t' || *ptr == '\n')
ptr++;
@@ -79,7 +83,7 @@ inline char peek_next_nonws(std::istream& in) {
*_p = '\0'; \
}
-std::string resolve_path(const std::string& path);
+ledger::string resolve_path(const ledger::string& path);
#ifdef HAVE_REALPATH
extern "C" char *realpath(const char *, char resolved_path[]);
@@ -92,12 +96,13 @@ enum elision_style_t {
ABBREVIATE
};
-std::string abbreviate(const std::string& str, unsigned int width,
- elision_style_t elision_style = TRUNCATE_TRAILING,
- const bool is_account = false, int abbrev_length = 2);
+ledger::string abbreviate(const ledger::string& str, unsigned int width,
+ elision_style_t elision_style = TRUNCATE_TRAILING,
+ const bool is_account = false, int abbrev_length = 2);
static inline const
-std::string& either_or(const std::string& first, const std::string& second)
+ledger::string& either_or(const ledger::string& first,
+ const ledger::string& second)
{
if (first.empty())
return second;
@@ -105,4 +110,6 @@ std::string& either_or(const std::string& first, const std::string& second)
return first;
}
+} // namespace ledger
+
#endif // _UTIL_H