Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <precomp.h>
21 : #include <ary/qualiname.hxx>
22 :
23 :
24 : // NOT FULLY DECLARED SERVICES
25 :
26 :
27 : namespace ary
28 : {
29 :
30 :
31 57 : QualifiedName::QualifiedName( uintt i_nSize )
32 : : aNamespace(),
33 : sLocalName(),
34 : bIsAbsolute(false),
35 57 : bIsFunction()
36 : {
37 57 : if (i_nSize > 0)
38 0 : aNamespace.reserve(i_nSize);
39 57 : }
40 :
41 1 : QualifiedName::QualifiedName( const char * i_sText,
42 : const char * i_sSeparator )
43 : : aNamespace(),
44 : sLocalName(),
45 : bIsAbsolute(false),
46 1 : bIsFunction()
47 : {
48 1 : AssignText(i_sText,i_sSeparator);
49 1 : }
50 :
51 58 : QualifiedName::~QualifiedName()
52 : {
53 58 : }
54 :
55 : void
56 1 : QualifiedName::AssignText( const char * i_sText,
57 : const char * i_sSeparator )
58 : {
59 : csv_assert(NOT csv::no_str(i_sText) AND NOT csv::no_str(i_sSeparator));
60 1 : bIsAbsolute = false;
61 1 : bIsFunction = false;
62 1 : csv::erase_container( aNamespace );
63 :
64 1 : uintt nSepLen = strlen(i_sSeparator);
65 1 : const char * sNext = i_sText;
66 :
67 1 : const char * ps = strstr( i_sText, i_sSeparator );
68 1 : if (ps == i_sText)
69 : {
70 1 : bIsAbsolute = true;
71 1 : sNext = ps + nSepLen;
72 : }
73 :
74 5 : for ( ps = strstr(sNext, i_sSeparator);
75 : ps != 0;
76 : ps = strstr(sNext, i_sSeparator) )
77 : {
78 4 : String sPart(sNext, ps - sNext);
79 4 : aNamespace.push_back(sPart);
80 4 : sNext = ps + nSepLen;
81 4 : }
82 :
83 1 : uintt sNameLen = strlen(sNext);
84 1 : if ( sNameLen > 2 )
85 : {
86 1 : ps = sNext + sNameLen - 2;
87 1 : if (*ps == '(' AND *(ps+1) == ')')
88 : {
89 0 : sNameLen -= 2;
90 0 : bIsFunction = true;
91 : }
92 : }
93 1 : sLocalName = String(sNext,sNameLen);
94 1 : }
95 :
96 :
97 3 : } // namespace ary
98 :
99 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|