Coverage Report

Created: 2017-03-27 23:01

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/polly/lib/External/JSON/json_valueiterator.inl
Line
Count
Source (jump to first uncovered line)
1
// included by json_value.cpp
2
// everything is within Json namespace
3
4
5
// //////////////////////////////////////////////////////////////////
6
// //////////////////////////////////////////////////////////////////
7
// //////////////////////////////////////////////////////////////////
8
// class ValueIteratorBase
9
// //////////////////////////////////////////////////////////////////
10
// //////////////////////////////////////////////////////////////////
11
// //////////////////////////////////////////////////////////////////
12
13
ValueIteratorBase::ValueIteratorBase()
14
#ifndef JSON_VALUE_USE_INTERNAL_MAP
15
   : current_()
16
   , isNull_( true )
17
0
{
18
0
}
19
#else
20
   : isArray_( true )
21
   , isNull_( true )
22
{
23
   iterator_.array_ = ValueInternalArray::IteratorState();
24
}
25
#endif
26
27
28
#ifndef JSON_VALUE_USE_INTERNAL_MAP
29
ValueIteratorBase::ValueIteratorBase( const Value::ObjectValues::iterator &current )
30
   : current_( current )
31
   , isNull_( false )
32
0
{
33
0
}
34
#else
35
ValueIteratorBase::ValueIteratorBase( const ValueInternalArray::IteratorState &state )
36
   : isArray_( true )
37
{
38
   iterator_.array_ = state;
39
}
40
41
42
ValueIteratorBase::ValueIteratorBase( const ValueInternalMap::IteratorState &state )
43
   : isArray_( false )
44
{
45
   iterator_.map_ = state;
46
}
47
#endif
48
49
Value &
50
ValueIteratorBase::deref() const
51
0
{
52
0
#ifndef JSON_VALUE_USE_INTERNAL_MAP
53
0
   return current_->second;
54
0
#else
55
   if ( isArray_ )
56
      return ValueInternalArray::dereference( iterator_.array_ );
57
   return ValueInternalMap::value( iterator_.map_ );
58
#endif
59
0
}
60
61
62
void 
63
ValueIteratorBase::increment()
64
0
{
65
0
#ifndef JSON_VALUE_USE_INTERNAL_MAP
66
0
   ++current_;
67
0
#else
68
   if ( isArray_ )
69
      ValueInternalArray::increment( iterator_.array_ );
70
   ValueInternalMap::increment( iterator_.map_ );
71
#endif
72
0
}
73
74
75
void 
76
ValueIteratorBase::decrement()
77
0
{
78
0
#ifndef JSON_VALUE_USE_INTERNAL_MAP
79
0
   --current_;
80
0
#else
81
   if ( isArray_ )
82
      ValueInternalArray::decrement( iterator_.array_ );
83
   ValueInternalMap::decrement( iterator_.map_ );
84
#endif
85
0
}
86
87
88
ValueIteratorBase::difference_type 
89
ValueIteratorBase::computeDistance( const SelfType &other ) const
90
0
{
91
0
#ifndef JSON_VALUE_USE_INTERNAL_MAP
92
0
# ifdef JSON_USE_CPPTL_SMALLMAP
93
   return current_ - other.current_;
94
# else
95
0
   // Iterator for null value are initialized using the default
96
0
   // constructor, which initialize current_ to the default
97
0
   // std::map::iterator. As begin() and end() are two instance 
98
0
   // of the default std::map::iterator, they can not be compared.
99
0
   // To allow this, we handle this comparison specifically.
100
0
   if ( 
isNull_ && 0
other.isNull_0
)
101
0
   {
102
0
      return 0;
103
0
   }
104
0
105
0
106
0
   // Usage of std::distance is not portable (does not compile with Sun Studio 12 RogueWave STL,
107
0
   // which is the one used by default).
108
0
   // Using a portable hand-made version for non random iterator instead:
109
0
   //   return difference_type( std::distance( current_, other.current_ ) );
110
0
   difference_type myDistance = 0;
111
0
   for ( Value::ObjectValues::iterator it = current_; 
it != other.current_0
;
++it0
)
112
0
   {
113
0
      ++myDistance;
114
0
   }
115
0
   return myDistance;
116
0
# endif
117
0
#else
118
   if ( isArray_ )
119
      return ValueInternalArray::distance( iterator_.array_, other.iterator_.array_ );
120
   return ValueInternalMap::distance( iterator_.map_, other.iterator_.map_ );
121
#endif
122
0
}
123
124
125
bool 
126
ValueIteratorBase::isEqual( const SelfType &other ) const
127
0
{
128
0
#ifndef JSON_VALUE_USE_INTERNAL_MAP
129
0
   if ( isNull_ )
130
0
   {
131
0
      return other.isNull_;
132
0
   }
133
0
   return current_ == other.current_;
134
0
#else
135
   if ( isArray_ )
136
      return ValueInternalArray::equals( iterator_.array_, other.iterator_.array_ );
137
   return ValueInternalMap::equals( iterator_.map_, other.iterator_.map_ );
138
#endif
139
0
}
140
141
142
void 
143
ValueIteratorBase::copy( const SelfType &other )
144
0
{
145
0
#ifndef JSON_VALUE_USE_INTERNAL_MAP
146
0
   current_ = other.current_;
147
0
#else
148
   if ( isArray_ )
149
      iterator_.array_ = other.iterator_.array_;
150
   iterator_.map_ = other.iterator_.map_;
151
#endif
152
0
}
153
154
155
Value 
156
ValueIteratorBase::key() const
157
0
{
158
0
#ifndef JSON_VALUE_USE_INTERNAL_MAP
159
0
   const Value::CZString czstring = (*current_).first;
160
0
   if ( czstring.c_str() )
161
0
   {
162
0
      if ( czstring.isStaticString() )
163
0
         return Value( StaticString( czstring.c_str() ) );
164
0
      return Value( czstring.c_str() );
165
0
   }
166
0
   return Value( czstring.index() );
167
0
#else
168
   if ( isArray_ )
169
      return Value( ValueInternalArray::indexOf( iterator_.array_ ) );
170
   bool isStatic;
171
   const char *memberName = ValueInternalMap::key( iterator_.map_, isStatic );
172
   if ( isStatic )
173
      return Value( StaticString( memberName ) );
174
   return Value( memberName );
175
#endif
176
0
}
177
178
179
UInt 
180
ValueIteratorBase::index() const
181
0
{
182
0
#ifndef JSON_VALUE_USE_INTERNAL_MAP
183
0
   const Value::CZString czstring = (*current_).first;
184
0
   if ( !czstring.c_str() )
185
0
      return czstring.index();
186
0
   return Value::UInt( -1 );
187
0
#else
188
   if ( isArray_ )
189
      return Value::UInt( ValueInternalArray::indexOf( iterator_.array_ ) );
190
   return Value::UInt( -1 );
191
#endif
192
0
}
193
194
195
const char *
196
ValueIteratorBase::memberName() const
197
0
{
198
0
#ifndef JSON_VALUE_USE_INTERNAL_MAP
199
0
   const char *name = (*current_).first.c_str();
200
0
   return name ? 
name0
:
""0
;
201
0
#else
202
   if ( !isArray_ )
203
      return ValueInternalMap::key( iterator_.map_ );
204
   return "";
205
#endif
206
0
}
207
208
209
// //////////////////////////////////////////////////////////////////
210
// //////////////////////////////////////////////////////////////////
211
// //////////////////////////////////////////////////////////////////
212
// class ValueConstIterator
213
// //////////////////////////////////////////////////////////////////
214
// //////////////////////////////////////////////////////////////////
215
// //////////////////////////////////////////////////////////////////
216
217
ValueConstIterator::ValueConstIterator()
218
0
{
219
0
}
220
221
222
#ifndef JSON_VALUE_USE_INTERNAL_MAP
223
ValueConstIterator::ValueConstIterator( const Value::ObjectValues::iterator &current )
224
   : ValueIteratorBase( current )
225
0
{
226
0
}
227
#else
228
ValueConstIterator::ValueConstIterator( const ValueInternalArray::IteratorState &state )
229
   : ValueIteratorBase( state )
230
{
231
}
232
233
ValueConstIterator::ValueConstIterator( const ValueInternalMap::IteratorState &state )
234
   : ValueIteratorBase( state )
235
{
236
}
237
#endif
238
239
ValueConstIterator &
240
ValueConstIterator::operator =( const ValueIteratorBase &other )
241
0
{
242
0
   copy( other );
243
0
   return *this;
244
0
}
245
246
247
// //////////////////////////////////////////////////////////////////
248
// //////////////////////////////////////////////////////////////////
249
// //////////////////////////////////////////////////////////////////
250
// class ValueIterator
251
// //////////////////////////////////////////////////////////////////
252
// //////////////////////////////////////////////////////////////////
253
// //////////////////////////////////////////////////////////////////
254
255
ValueIterator::ValueIterator()
256
0
{
257
0
}
258
259
260
#ifndef JSON_VALUE_USE_INTERNAL_MAP
261
ValueIterator::ValueIterator( const Value::ObjectValues::iterator &current )
262
   : ValueIteratorBase( current )
263
0
{
264
0
}
265
#else
266
ValueIterator::ValueIterator( const ValueInternalArray::IteratorState &state )
267
   : ValueIteratorBase( state )
268
{
269
}
270
271
ValueIterator::ValueIterator( const ValueInternalMap::IteratorState &state )
272
   : ValueIteratorBase( state )
273
{
274
}
275
#endif
276
277
ValueIterator::ValueIterator( const ValueConstIterator &other )
278
   : ValueIteratorBase( other )
279
0
{
280
0
}
281
282
ValueIterator::ValueIterator( const ValueIterator &other )
283
   : ValueIteratorBase( other )
284
0
{
285
0
}
286
287
ValueIterator &
288
ValueIterator::operator =( const SelfType &other )
289
0
{
290
0
   copy( other );
291
0
   return *this;
292
0
}