1 #ifndef NPSTAT_VECTORASTEXT_HH_
2 #define NPSTAT_VECTORASTEXT_HH_
34 std::ostream& asciiStream,
35 const unsigned long firstElementToDump=0,
36 const unsigned long nElementsToDump=ULONG_MAX)
40 const unsigned long sz = v.size();
41 if (firstElementToDump < sz)
43 unsigned long ndumped = 0;
44 for (
unsigned long i=firstElementToDump;
45 i<sz && ndumped<nElementsToDump; ++i, ++ndumped)
46 asciiStream << v[i] <<
'\n';
47 if (asciiStream.fail())
66 const unsigned long maxElementsToFill=ULONG_MAX)
69 if (maxElementsToFill && asciiStream)
73 std::istringstream is;
74 unsigned long nfilled = 0;
77 while (asciiStream && status && nfilled<maxElementsToFill)
79 std::getline(asciiStream, linebuf);
80 const unsigned long len = linebuf.size();
87 bool isComment =
false;
89 char* line = &linebuf[0];
91 for (
unsigned long i=0; i<len && allSpace; ++i)
99 if (isComment || allSpace)
108 v->push_back(buffer);
110 if ((asciiStream.fail() && !asciiStream.eof()) ||
Definition: AbsArrayProjector.hh:14
bool fillVectorFromText(std::istream &asciiStream, std::vector< T > *v, const unsigned long maxElementsToFill=ULONG_MAX)
Definition: vectorAsText.hh:64
bool dumpVectorAsText(const std::vector< T > &v, std::ostream &asciiStream, const unsigned long firstElementToDump=0, const unsigned long nElementsToDump=ULONG_MAX)
Definition: vectorAsText.hh:33