Commit a64b0c8268122e57c9761b8570a8a034553493bb

Authored by Jordi Inglada
1 parent 44f7e1e1
Exists in master

DOC: prettify

Showing 1 changed file with 16 additions and 15 deletions   Show diff stats
include/cbutils.h
... ... @@ -4,7 +4,7 @@
4 4  
5 5 Copyright (c) CESBIO. All rights reserved.
6 6  
7   - See otb-bv-copyright.txt for details.
  7 + See cbutils-copyright.txt for details.
8 8  
9 9 This software is distributed WITHOUT ANY WARRANTY; without even
10 10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
... ... @@ -13,29 +13,30 @@
13 13 =========================================================================*/
14 14 #ifndef __CBUTILS_H
15 15 #define __CBUTILS_H
16   -
  16 +#include <algorithm>
17 17 #include <boost/algorithm/string.hpp>
18   -#include <vector>
19   -#include <string>
20 18 #include <fstream>
21   -#include <algorithm>
22   -
23   -
  19 +#include <string>
  20 +#include <vector>
24 21 namespace cbutils
25 22 {
26   -
  23 +// ----------------- String manipulation ---------------------------------------
27 24 namespace string
28 25 {
  26 +// Splits a string using any of a list of separators
29 27 std::vector<std::string> split(const std::string& str,
30 28 const char* separators = "\t ")
31   -{ std::vector< std::string > tokens;
32   - boost::split(tokens, str, boost::is_any_of(separators), boost::token_compress_on);
  29 +{
  30 + std::vector< std::string > tokens;
  31 + boost::split(tokens, str, boost::is_any_of(separators),
  32 + boost::token_compress_on);
33 33 return tokens;
34 34 }
35 35 } //end ns string
36   -
  36 +// ----------------- File IO ---------------------------------------------------
37 37 namespace file
38 38 {
  39 +//Reads a text file and returns a vector of lines
39 40 std::vector<std::string> readlines(const std::string& fname)
40 41 {
41 42 std::ifstream ifs(fname);
... ... @@ -49,10 +50,12 @@ std::vector&lt;std::string&gt; readlines(const std::string&amp; fname)
49 50 return lines;
50 51 }
51 52 }//end ns file
52   -
  53 +// ----------------- Sequence manipulation -------------------------------------
53 54 namespace seq
54 55 {
55   -template <typename Seq> Seq tail(const Seq& s)
  56 +//Chops off the head of a sequence and returns its tail
  57 +template <typename Seq>
  58 +Seq tail(const Seq& s)
56 59 {
57 60 Seq result{};
58 61 auto head = std::begin(s);
... ... @@ -61,7 +64,5 @@ template &lt;typename Seq&gt; Seq tail(const Seq&amp; s)
61 64 return result;
62 65 }
63 66 }// end ns seq
64   -
65 67 }//end ns cbutils
66   -
67 68 #endif
... ...