QMCPACK
LibxmlNumericIO.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Jordan E. Vincent, University of Illinois at Urbana-Champaign
8 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
9 // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
10 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
11 //
12 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
13 //////////////////////////////////////////////////////////////////////////////////////
14 
15 
16 #ifndef OHMMS_LIBXML_NUMERICATTRIBIO_H
17 #define OHMMS_LIBXML_NUMERICATTRIBIO_H
18 #include "OhmmsData/libxmldefs.h"
19 #include "OhmmsPETE/OhmmsVector.h"
20 #include "OhmmsPETE/OhmmsMatrix.h"
21 /** assign std::vector<T> from a node. Create a temporary vector and make assignment.
22  *\param a reference std::vector<T>
23  *\param cur current node to which a content is copied
24  *\return true if successful
25  */
26 template<class T>
27 inline bool putContent(qmcplusplus::Vector<T>& a, xmlNodePtr cur)
28 {
29  std::istringstream stream(XMLNodeString{cur});
30  int i = 0;
31  int n(a.size());
32  while (!stream.eof() && i < n)
33  {
34  stream >> a[i++];
35  }
36  return true;
37 }
38 
39 template<typename T>
40 inline bool putContent(qmcplusplus::Matrix<T>& a, xmlNodePtr cur)
41 {
42  std::istringstream stream(XMLNodeString{cur});
43  int i = 0, ntot = a.size();
44  while (!stream.eof() && i < ntot)
45  {
46  stream >> a(i++);
47  }
48  return true;
49 }
50 
51 #endif
A collection of put/get functions to read from or write to a xmlNode defined in libxml2.
size_type size() const
Definition: OhmmsMatrix.h:76
size_type size() const
return the current size
Definition: OhmmsVector.h:162
convert xmlNode contents into a std::string
Declaraton of Vector<T,Alloc> Manage memory through Alloc directly and allow referencing an existing ...
bool putContent(qmcplusplus::Vector< T > &a, xmlNodePtr cur)
assign std::vector<T> from a node.