Upstream version 8.37.180.0
[platform/framework/web/crosswalk.git] / src / third_party / pdfium / core / src / fxcrt / fx_xml_composer.cpp
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 "../../include/fxcrt/fx_xml.h"
8 #include "xml_int.h"
9 void FX_XML_SplitQualifiedName(FX_BSTR bsFullName, CFX_ByteStringC &bsSpace, CFX_ByteStringC &bsName)
10 {
11     if (bsFullName.IsEmpty()) {
12         return;
13     }
14     FX_INT32 iStart = 0;
15     for (; iStart < bsFullName.GetLength(); iStart ++) {
16         if (bsFullName.GetAt(iStart) == ':') {
17             break;
18         }
19     }
20     if (iStart >= bsFullName.GetLength()) {
21         bsName = bsFullName;
22     } else {
23         bsSpace = CFX_ByteStringC(bsFullName.GetCStr(), iStart);
24         iStart ++;
25         bsName = CFX_ByteStringC(bsFullName.GetCStr() + iStart, bsFullName.GetLength() - iStart);
26     }
27 }
28 void CXML_Element::SetTag(FX_BSTR qSpace, FX_BSTR tagname)
29 {
30     IFX_Allocator* pAllocator = m_Children.m_pAllocator;
31     m_QSpaceName.Set(qSpace, pAllocator);
32     m_TagName.Set(tagname, pAllocator);
33 }
34 void CXML_Element::SetTag(FX_BSTR qTagName)
35 {
36     ASSERT(!qTagName.IsEmpty());
37     IFX_Allocator* pAllocator = m_Children.m_pAllocator;
38     CFX_ByteStringC bsSpace, bsName;
39     FX_XML_SplitQualifiedName(qTagName, bsSpace, bsName);
40     m_QSpaceName.Set(bsSpace, pAllocator);
41     m_TagName.Set(bsName, pAllocator);
42 }