1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #include "xml_int.h"
8 
9 #include "core/include/fxcrt/fx_xml.h"
10 
FX_XML_SplitQualifiedName(const CFX_ByteStringC & bsFullName,CFX_ByteStringC & bsSpace,CFX_ByteStringC & bsName)11 void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName,
12                                CFX_ByteStringC& bsSpace,
13                                CFX_ByteStringC& bsName) {
14   if (bsFullName.IsEmpty()) {
15     return;
16   }
17   int32_t iStart = 0;
18   for (; iStart < bsFullName.GetLength(); iStart++) {
19     if (bsFullName.GetAt(iStart) == ':') {
20       break;
21     }
22   }
23   if (iStart >= bsFullName.GetLength()) {
24     bsName = bsFullName;
25   } else {
26     bsSpace = CFX_ByteStringC(bsFullName.GetCStr(), iStart);
27     iStart++;
28     bsName = CFX_ByteStringC(bsFullName.GetCStr() + iStart,
29                              bsFullName.GetLength() - iStart);
30   }
31 }
SetTag(const CFX_ByteStringC & qSpace,const CFX_ByteStringC & tagname)32 void CXML_Element::SetTag(const CFX_ByteStringC& qSpace,
33                           const CFX_ByteStringC& tagname) {
34   m_QSpaceName = qSpace;
35   m_TagName = tagname;
36 }
SetTag(const CFX_ByteStringC & qTagName)37 void CXML_Element::SetTag(const CFX_ByteStringC& qTagName) {
38   ASSERT(!qTagName.IsEmpty());
39   CFX_ByteStringC bsSpace, bsName;
40   FX_XML_SplitQualifiedName(qTagName, bsSpace, bsName);
41   m_QSpaceName = bsSpace;
42   m_TagName = bsName;
43 }
44