diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-05-12 13:59:36 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-05-12 13:59:36 +0000 |
commit | 8032f26ca0bd2233de066ce5786ff976bbd641ae (patch) | |
tree | 954b2ecdce037dcf47b0376616ac05dbad8542ab /src/libutil/util.hh | |
parent | 4750065ada362bd46e85879975a3148e18df5b0c (diff) | |
parent | bd25ac2260267abd2181324e1650820da70e5e60 (diff) |
* Merged the `fast-eval' branch.
Diffstat (limited to 'src/libutil/util.hh')
-rw-r--r-- | src/libutil/util.hh | 42 |
1 files changed, 13 insertions, 29 deletions
diff --git a/src/libutil/util.hh b/src/libutil/util.hh index f609e8944..ff710077c 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -15,7 +15,7 @@ namespace nix { #define foreach(it_type, it, collection) \ - for (it_type it = collection.begin(); it != collection.end(); ++it) + for (it_type it = (collection).begin(); it != (collection).end(); ++it) /* Return an environment variable. */ @@ -276,11 +276,6 @@ void inline checkInterrupt() MakeError(Interrupted, BaseError) -/* String packing / unpacking. */ -string packStrings(const Strings & strings); -Strings unpackStrings(const string & s); - - /* String tokenizer. */ Strings tokenizeString(const string & s, const string & separators = " \t\n\r"); @@ -307,32 +302,21 @@ string int2String(int n); bool hasSuffix(const string & s, const string & suffix); -/* Exception handling in destructors: print an error message, then - ignore the exception. */ -void ignoreException(); +/* Read string `s' from stream `str'. */ +void expect(std::istream & str, const string & s); -/* STL functions such as sort() pass a binary function object around - by value, so it gets cloned a lot. This is bad if the function - object has state or is simply large. This adapter wraps the - function object to simulate passing by reference. */ -template<class F> -struct binary_function_ref_adapter -{ - F * p; +/* Read a C-style string from stream `str'. */ +string parseString(std::istream & str); - binary_function_ref_adapter(F * _p) - { - p = _p; - } - - typename F::result_type operator () ( - const typename F::first_argument_type & x, - const typename F::second_argument_type & y) - { - return (*p)(x, y); - } -}; + +/* Utility function used to parse legacy ATerms. */ +bool endOfList(std::istream & str); + + +/* Exception handling in destructors: print an error message, then + ignore the exception. */ +void ignoreException(); } |