1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
24 #include <com/sun/star/uno/RuntimeException.hpp>
25 #include <rtl/string.h>
26 #include <rtl/ustring.hxx>
27 #include <sal/types.h>
28 #include <xmlreader/span.hxx>
29 #include <xmlreader/xmlreader.hxx>
32 #include "parsemanager.hxx"
34 #include "xmldata.hxx"
36 namespace configmgr::xmldata
{
39 xmlreader::XmlReader
const & reader
, xmlreader::Span
const & text
)
42 sal_Int32 i
= rtl_str_indexOfChar_WithLength(text
.begin
, text
.length
, ':');
44 xmlreader::Span
token(text
.begin
+ i
+ 1, text
.length
- (i
+ 1));
45 switch (reader
.getNamespaceId(xmlreader::Span(text
.begin
, i
))) {
46 case ParseManager::NAMESPACE_OOR
:
50 } else if (token
== "boolean-list")
52 return TYPE_BOOLEAN_LIST
;
53 } else if (token
== "short-list")
55 return TYPE_SHORT_LIST
;
56 } else if (token
== "int-list")
59 } else if (token
== "long-list")
61 return TYPE_LONG_LIST
;
62 } else if (token
== "double-list")
64 return TYPE_DOUBLE_LIST
;
65 } else if (token
== "string-list")
67 return TYPE_STRING_LIST
;
68 } else if (token
== "hexBinary-list")
70 return TYPE_HEXBINARY_LIST
;
73 case ParseManager::NAMESPACE_XS
:
74 if (token
== "boolean")
77 } else if (token
=="short")
80 } else if (token
=="int")
83 } else if (token
=="long")
86 } else if (token
=="double")
89 } else if (token
=="string")
92 } else if (token
=="hexBinary")
94 return TYPE_HEXBINARY
;
101 throw css::uno::RuntimeException(
102 "invalid type " + text
.convertFromUtf8());
105 bool parseBoolean(xmlreader::Span
const & text
) {
107 if (text
== "true") {
110 if (text
== "false") {
113 throw css::uno::RuntimeException(
114 "invalid boolean " + text
.convertFromUtf8());
117 OUString
parseTemplateReference(
118 std::u16string_view component
, bool hasNodeType
,
119 std::u16string_view nodeType
, OUString
const * defaultTemplateName
)
122 if (defaultTemplateName
!= nullptr) {
123 return *defaultTemplateName
;
125 throw css::uno::RuntimeException(
126 "missing node-type attribute");
128 return Data::fullTemplateName(component
, nodeType
);
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */