SheafSystem  0.0.0.0
namespace_schema_member_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 // Definitions for namespace_schema_member_index facet of namespace sheaf.
19 
20 
21 #include "SheafSystem/namespace_schema_member_index.h"
22 
23 #include "SheafSystem/assert_contract.h"
24 #include "SheafSystem/std_string.h"
25 
26 using namespace std;
27 
28 namespace
29 {
30 const int NAMESPACE_SCHEMA_MEMBER_INDEX_CT =
31  sheaf::NAMESPACE_SCHEMA_MEMBER_INDEX_END - sheaf::NAMESPACE_SCHEMA_MEMBER_INDEX_BEGIN;
32 }
33 
36 sheaf::
38 {
39  return x =
40  (x == NAMESPACE_SCHEMA_MEMBER_INDEX_END) ?
41  NAMESPACE_SCHEMA_MEMBER_INDEX_BEGIN :
43 };
44 
46 const std::string&
47 sheaf::
49 {
50  // Preconditions:
51 
52  // Body:
53 
54  static const string names[NAMESPACE_SCHEMA_MEMBER_INDEX_CT+1] =
55  {
56  "POINTER_INDEX",
57  "TYPE_ID_INDEX",
58  "CLASS_INDEX",
59  "PREREQ_ID_0_INDEX",
60  "PREREQ_ID_1_INDEX",
61  "PREREQ_ID_2_INDEX",
62  "PREREQ_ID_3_INDEX",
63  "PREREQ_ID_4_INDEX",
64  "IO_INDEX",
65  "NOT_A_NAMESPACE_SCHEMA_MEMBER_INDEX"
66  };
67 
68  const string* lresult_ptr = &names[NAMESPACE_SCHEMA_MEMBER_INDEX_CT];
69 
70  pod_index_type lpt = xpt;
72  {
73  lresult_ptr = &names[lpt - NAMESPACE_SCHEMA_MEMBER_INDEX_BEGIN];
74  }
75 
76  const string& result = *lresult_ptr;
77 
78  // Postconditions:
79 
80  ensure(!result.empty());
81 
82  // Exit:
83 
84  return result;
85 }
86 
89 sheaf::
90 namespace_schema_member_index_from_name(const std::string& xname)
91 {
92  namespace_schema_member_index result = NOT_A_NAMESPACE_SCHEMA_MEMBER_INDEX;
93  for(namespace_schema_member_index i=NAMESPACE_SCHEMA_MEMBER_INDEX_BEGIN;
94  i< NAMESPACE_SCHEMA_MEMBER_INDEX_END;
95  ++i)
96  {
98  {
99  result = i;
100  break;
101  }
102  }
103 
104  return result;
105 }
106 
109 sheaf::
111 {
112  // Preconditions:
113 
114  // Body:
115 
116  static const namespace_schema_member_index prims[NAMESPACE_SCHEMA_MEMBER_INDEX_CT+1] =
117  {
118  POINTER_INDEX,
119  TYPE_ID_INDEX,
120  CLASS_INDEX,
121  PREREQ_ID_0_INDEX,
122  PREREQ_ID_1_INDEX,
123  PREREQ_ID_2_INDEX,
124  PREREQ_ID_3_INDEX,
125  PREREQ_ID_4_INDEX,
126  IO_INDEX,
127  NOT_A_NAMESPACE_SCHEMA_MEMBER_INDEX
128  };
129 
130  namespace_schema_member_index result = prims[NAMESPACE_SCHEMA_MEMBER_INDEX_CT];
132  {
133  result = prims[xindex - NAMESPACE_SCHEMA_MEMBER_INDEX_BEGIN];
134  }
135 
136  // Postconditions:
137 
138  // Exit:
139 
140  return result;
141 }
142 
144 bool
145 sheaf::
147 {
148  bool result;
149 
150  // Preconditions:
151 
152  // Body:
153 
154  result =
155  (NAMESPACE_SCHEMA_MEMBER_INDEX_BEGIN <= xindex) && (xindex < NAMESPACE_SCHEMA_MEMBER_INDEX_END);
156 
157  // Postconditions:
158 
159  // Exit
160 
161  return result;
162 }
163 
SHEAF_DLL_SPEC bool is_namespace_schema_member_index(pod_index_type xindex)
True if xindex is a valid primitive index.
STL namespace.
namespace_schema_member_index
Ids for namespace poset schema members.
SHEAF_DLL_SPEC const std::string & namespace_schema_member_index_to_name(namespace_schema_member_index xpt)
The name of the enumerator xpt.
SHEAF_DLL_SPEC namespace_schema_member_index namespace_schema_member_index_from_index(pod_index_type xindex)
The enumerator corresponding to primitive index xindex.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
SHEAF_DLL_SPEC namespace_schema_member_index namespace_schema_member_index_from_name(const std::string &xname)
The enumerator with name xname.
SHEAF_DLL_SPEC namespace_member_index & operator++(namespace_member_index &x)
Prefix increment operator for namespace_member_index.