Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_StringInputStream.cpp
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
11 
12 using namespace Teuchos;
13 
14 
15 unsigned int StringInputStream::readBytes(unsigned char* const toFill,
16  const unsigned int maxToRead)
17 {
18  if (pos_ == text_.length()) return 0;
19 
20  int toRead = static_cast<int>(text_.length() - pos_);
21  if ((int) maxToRead < toRead) toRead = maxToRead;
22 
23  std::strncpy((char*) toFill, text_.c_str()+pos_, toRead);
24 
25  pos_ += toRead;
26 
27  return (size_t) toRead;
28 }
29 
virtual unsigned int readBytes(unsigned char *const toFill, const unsigned int maxToRead)
Read up to maxToRead bytes.
Definition of XMLInputStream derived class for reading XML from a std::string.