1 /*
2 * Copyright 2006-2011 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 #include "stdafx.h"
17
18 #include "store/api/iterator.h"
19
20 #include "common.h"
21
22 using namespace std;
23
24 namespace zorba {
25
26 ///////////////////////////////////////////////////////////////////////////////
27
get_attribute_value(store::Item_t const & element,char const * att_name,zstring * att_value)28 bool get_attribute_value( store::Item_t const &element, char const *att_name,
29 zstring *att_value ) {
30 store::Iterator_t i( element->getAttributes() );
31 bool found = false;
32 i->open();
33 store::Item_t att_item;
34 while ( i->next( att_item ) ) {
35 if ( att_item->getNodeName()->getStringValue() == att_name ) {
36 att_item->getStringValue2( *att_value );
37 found = true;
38 break;
39 }
40 }
41 i->close();
42 return found;
43 }
44
45 ///////////////////////////////////////////////////////////////////////////////
46
47 #if ZORBA_DEBUG_JSON
48
operator <<(ostream & o,parse_state s)49 ostream& operator<<( ostream &o, parse_state s ) {
50 static char const *const string_of[] = {
51 "in_array",
52 "in_object"
53 };
54 return o << string_of[ s ];
55 }
56
57 #endif /* ZORBA_DEBUG_JSON */
58
59 ///////////////////////////////////////////////////////////////////////////////
60
61 } // namespace zorba
62 /* vim:set et sw=2 ts=2: */
63