SheafSystem  0.0.0.0
primitives_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 primitives_schema_member_index facet of namespace sheaf.
19 
20 
21 #include "SheafSystem/primitives_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 PRIMITIVES_SCHEMA_MEMBER_INDEX_CT =
31  sheaf::PRIMITIVES_SCHEMA_MEMBER_INDEX_END - sheaf::PRIMITIVES_SCHEMA_MEMBER_INDEX_BEGIN;
32 }
33 
36 sheaf::
38 {
39  return x =
40  (x == PRIMITIVES_SCHEMA_MEMBER_INDEX_END) ?
41  PRIMITIVES_SCHEMA_MEMBER_INDEX_BEGIN :
43 };
44 
46 const std::string&
47 sheaf::
49 {
50  // Preconditions:
51 
52  // Body:
53 
54  static const string names[PRIMITIVES_SCHEMA_MEMBER_INDEX_CT+1] =
55  {
56  "SIZE_INDEX",
57  "ALIGNMENT_INDEX",
58  "INDEX_INDEX",
59  "NOT_A_PRIMITIVES_SCHEMA_MEMBER_INDEX" // Must be one more than last std id.
60  };
61 
62  const string* lresult_ptr = &names[PRIMITIVES_SCHEMA_MEMBER_INDEX_CT];
63 
64  pod_index_type lpt = xpt;
66  {
67  lresult_ptr = &names[lpt - PRIMITIVES_SCHEMA_MEMBER_INDEX_BEGIN];
68  }
69 
70  const string& result = *lresult_ptr;
71 
72  // Postconditions:
73 
74  ensure(!result.empty());
75 
76  // Exit:
77 
78  return result;
79 }
80 
83 sheaf::
85 {
86  primitives_schema_member_index result = NOT_A_PRIMITIVES_SCHEMA_MEMBER_INDEX;
87  for(primitives_schema_member_index i=PRIMITIVES_SCHEMA_MEMBER_INDEX_BEGIN;
88  i< PRIMITIVES_SCHEMA_MEMBER_INDEX_END;
89  ++i)
90  {
92  {
93  result = i;
94  break;
95  }
96  }
97 
98  return result;
99 }
100 
103 sheaf::
105 {
106  // Preconditions:
107 
108  // Body:
109 
110  static const primitives_schema_member_index prims[PRIMITIVES_SCHEMA_MEMBER_INDEX_CT+1] =
111  {
112  SIZE_INDEX,
113  ALIGNMENT_INDEX,
114  INDEX_INDEX,
115  NOT_A_PRIMITIVES_SCHEMA_MEMBER_INDEX
116  };
117 
118  primitives_schema_member_index result = prims[PRIMITIVES_SCHEMA_MEMBER_INDEX_CT];
120  {
121  result = prims[xindex - PRIMITIVES_SCHEMA_MEMBER_INDEX_BEGIN];
122  }
123 
124  // Postconditions:
125 
126  // Exit:
127 
128  return result;
129 }
130 
132 bool
133 sheaf::
135 {
136  bool result;
137 
138  // Preconditions:
139 
140  // Body:
141 
142  result =
143  (PRIMITIVES_SCHEMA_MEMBER_INDEX_BEGIN <= xindex) && (xindex < PRIMITIVES_SCHEMA_MEMBER_INDEX_END);
144 
145  // Postconditions:
146 
147  // Exit
148 
149  return result;
150 }
151 
primitives_schema_member_index
Ids for standard poset members.
SHEAF_DLL_SPEC primitives_schema_member_index primitives_schema_member_index_from_name(const std::string &xname)
The enumerator with name xname.
STL namespace.
SHEAF_DLL_SPEC bool is_primitives_schema_member_index(pod_index_type xindex)
True if xindex is a valid primitive index.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
SHEAF_DLL_SPEC namespace_member_index & operator++(namespace_member_index &x)
Prefix increment operator for namespace_member_index.
SHEAF_DLL_SPEC const std::string & primitives_schema_member_index_to_name(primitives_schema_member_index xpt)
The name of the enumerator xpt.
SHEAF_DLL_SPEC primitives_schema_member_index primitives_schema_member_index_from_index(pod_index_type xindex)
The enumerator corresponding to primitive index xindex.