SheafSystem  0.0.0.0
namespace_relative_subposet_index.cc
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
18 // Implementation for class NAMESPACE_RELATIVE_SUBPOSET_INDEX
19 
20 // Implementation is mostly inline in namespace_relative_subposet_index.h
21 
22 #include "SheafSystem/namespace_relative_subposet_index.h"
23 
24 using namespace std;
25 
27 std::ostream&
28 sheaf::operator<<(std::ostream& xos, const namespace_relative_subposet_index& xindex)
29 {
30  // Preconditions:
31 
32  // Body:
33 
34  xos << xindex.poset_id << " " << xindex.subposet_id;
35 
36  // Postconditions:
37 
38  // Exit:
39 
40  return xos;
41 }
42 
44 std::istream&
46 {
47  // Preconditions:
48 
49  // Body:
50 
51  scoped_index lposet_id, lsubposet_id;
52 
53  // Extract "poset_id subposet_id", checking each step so
54  // when we return the stream state properly represents any failure.
55  // In particular, the stream state should properly distinguish
56  // a syntax or conversion failure from an end-of-file.
57  //
58  // Note that skipws may or may not be set, so we explicitly
59  // skip white space to make sure it is dealt with properly.
60  //
61  // Also note that this operator does not modify xindex unless
62  // the extraction succeeeds.
63 
64  if((xis >> ws >> lposet_id) && (xis >> ws >> lsubposet_id))
65  {
66  // Converted poset and subposet id successfully; set result.
67 
68  xindex.poset_id = lposet_id;
69  xindex.subposet_id = lsubposet_id;
70  }
71  else
72  {
73  // Couldn't read poset and/or subposet id, set fail bit..
74 
75  xis.setstate(ios_base::failbit);
76  }
77 
78  // Postconditions:
79 
80  // Exit:
81 
82  return xis;
83 }
84 
scoped_index poset_id
The index of the poset relative to the namespace.
STL namespace.
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
scoped_index subposet_id
The index of the subposet relative to the poset.
Index for identifying a subposet relative to a given name space.
SHEAF_DLL_SPEC std::istream & operator>>(std::istream &is, dof_tuple_type &xdt)
Extract dof_tuple_type xdt from istream& is.
SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &os, const dof_descriptor_array &p)
Insert dof_descriptor_array& p into ostream& os.