10#include "Teuchos_MatrixMarket_split.hpp" 
   21      trim (
const std::string& in)
 
   23        size_t start = in.find_first_not_of(
" \t");
 
   24        size_t end = in.find_last_not_of(
" \t");
 
   25        if (start == std::string::npos)
 
   26          return std::string(
"");
 
   28          return in.substr (start, end-start+1);
 
   32      lowercase (
const std::string& in)
 
   35        std::transform (in.begin(), in.end(), out.begin(), tolower);
 
   40      trim_and_lowercase (
const std::string& in)
 
   42        std::string out = trim (in);
 
   43        std::string out2 (out);
 
   44        std::transform (out.begin(), out.end(), out2.begin(), tolower);
 
   50      endToken (
const std::pair<size_t, size_t>& range)
 
   52        return range.first == std::string::npos && range.second == std::string::npos;
 
   60      static std::pair<size_t, size_t>
 
   61      nextToken (
const std::string& str,
 
   62                 const std::string& delimiters,
 
   70          return make_pair (string::npos, string::npos);
 
   73        const size_t first = str.find_first_not_of (delimiters, start);
 
   74        if (first == string::npos)
 
   76          return make_pair (string::npos, string::npos);
 
   77        else if (first == size-1)
 
   79          return make_pair (first, 1);
 
   85            const size_t next = str.find_first_of (delimiters, first);
 
   86            return make_pair (first, next - first);
 
   90      std::vector<std::string>
 
   91      split (
const std::string& str, 
const std::string& delimiters, 
const size_t start)
 
   93        size_t curStart = start;
 
   94        size_t size = str.size();
 
   95        std::vector<std::string> tokens;
 
   97          std::pair<size_t, size_t> token = nextToken (str, delimiters, curStart, size);
 
   98          if (endToken (token)) {
 
  101          tokens.push_back (str.substr (token.first, token.second));
 
  102          curStart = token.first + token.second;
 
Matrix Market file utilities.
 
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
 
Teuchos implementation details.