bump product version to 6.3.0.0.beta1
[LibreOffice.git] / configmgr / source / xmldata.cxx
blob4e01e50675d556e1f07140fdb98252a59c9c9af5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <cassert>
23 #include <climits>
24 #include <stack>
26 #include <com/sun/star/uno/RuntimeException.hpp>
27 #include <com/sun/star/uno/XInterface.hpp>
28 #include <osl/file.hxx>
29 #include <rtl/ref.hxx>
30 #include <rtl/string.h>
31 #include <rtl/ustring.hxx>
32 #include <sal/types.h>
33 #include <xmlreader/span.hxx>
34 #include <xmlreader/xmlreader.hxx>
36 #include "data.hxx"
37 #include "groupnode.hxx"
38 #include "localizedpropertynode.hxx"
39 #include "localizedvaluenode.hxx"
40 #include "node.hxx"
41 #include "nodemap.hxx"
42 #include "parsemanager.hxx"
43 #include "parser.hxx"
44 #include "propertynode.hxx"
45 #include "setnode.hxx"
46 #include "type.hxx"
47 #include "xmldata.hxx"
49 namespace configmgr {
51 namespace xmldata {
53 Type parseType(
54 xmlreader::XmlReader const & reader, xmlreader::Span const & text)
56 assert(text.is());
57 sal_Int32 i = rtl_str_indexOfChar_WithLength(text.begin, text.length, ':');
58 if (i >= 0) {
59 switch (reader.getNamespaceId(xmlreader::Span(text.begin, i))) {
60 case ParseManager::NAMESPACE_OOR:
61 if (xmlreader::Span(text.begin + i + 1, text.length - (i + 1)).
62 equals("any"))
64 return TYPE_ANY;
65 } else if (xmlreader::Span(
66 text.begin + i + 1, text.length - (i + 1)).
67 equals("boolean-list"))
69 return TYPE_BOOLEAN_LIST;
70 } else if (xmlreader::Span(
71 text.begin + i + 1, text.length - (i + 1)).
72 equals("short-list"))
74 return TYPE_SHORT_LIST;
75 } else if (xmlreader::Span(
76 text.begin + i + 1, text.length - (i + 1)).
77 equals("int-list"))
79 return TYPE_INT_LIST;
80 } else if (xmlreader::Span(
81 text.begin + i + 1, text.length - (i + 1)).
82 equals("long-list"))
84 return TYPE_LONG_LIST;
85 } else if (xmlreader::Span(
86 text.begin + i + 1, text.length - (i + 1)).
87 equals("double-list"))
89 return TYPE_DOUBLE_LIST;
90 } else if (xmlreader::Span(
91 text.begin + i + 1, text.length - (i + 1)).
92 equals("string-list"))
94 return TYPE_STRING_LIST;
95 } else if (xmlreader::Span(
96 text.begin + i + 1, text.length - (i + 1)).
97 equals("hexBinary-list"))
99 return TYPE_HEXBINARY_LIST;
101 break;
102 case ParseManager::NAMESPACE_XS:
103 if (xmlreader::Span(text.begin + i + 1, text.length - (i + 1)).
104 equals("boolean"))
106 return TYPE_BOOLEAN;
107 } else if (xmlreader::Span(
108 text.begin + i + 1, text.length - (i + 1)).
109 equals("short"))
111 return TYPE_SHORT;
112 } else if (xmlreader::Span(
113 text.begin + i + 1, text.length - (i + 1)).
114 equals("int"))
116 return TYPE_INT;
117 } else if (xmlreader::Span(
118 text.begin + i + 1, text.length - (i + 1)).
119 equals("long"))
121 return TYPE_LONG;
122 } else if (xmlreader::Span(
123 text.begin + i + 1, text.length - (i + 1)).
124 equals("double"))
126 return TYPE_DOUBLE;
127 } else if (xmlreader::Span(
128 text.begin + i + 1, text.length - (i + 1)).
129 equals("string"))
131 return TYPE_STRING;
132 } else if (xmlreader::Span(
133 text.begin + i + 1, text.length - (i + 1)).
134 equals("hexBinary"))
136 return TYPE_HEXBINARY;
138 break;
139 default:
140 break;
143 throw css::uno::RuntimeException(
144 "invalid type " + text.convertFromUtf8());
147 bool parseBoolean(xmlreader::Span const & text) {
148 assert(text.is());
149 if (text.equals("true")) {
150 return true;
152 if (text.equals("false")) {
153 return false;
155 throw css::uno::RuntimeException(
156 "invalid boolean " + text.convertFromUtf8());
159 OUString parseTemplateReference(
160 OUString const & component, bool hasNodeType,
161 OUString const & nodeType, OUString const * defaultTemplateName)
163 if (!hasNodeType) {
164 if (defaultTemplateName != nullptr) {
165 return *defaultTemplateName;
167 throw css::uno::RuntimeException(
168 "missing node-type attribute");
170 return Data::fullTemplateName(component, nodeType);
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */