Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: third_party/xmllite/qname.cc

Issue 2443903004: Add xmllite and xmpp sources to third_party/ (Closed)
Patch Set: Restored includes in jingle/ as well Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2004 The Chromium 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 #include "third_party/xmllite/qname.h"
6
7 namespace buzz {
8
9 QName::QName() {
10 }
11
12 QName::QName(const QName& qname)
13 : namespace_(qname.namespace_),
14 local_part_(qname.local_part_) {
15 }
16
17 QName::QName(const StaticQName& const_value)
18 : namespace_(const_value.ns),
19 local_part_(const_value.local) {
20 }
21
22 QName::QName(const std::string& ns, const std::string& local)
23 : namespace_(ns),
24 local_part_(local) {
25 }
26
27 QName::QName(const std::string& merged_or_local) {
28 size_t i = merged_or_local.rfind(':');
29 if (i == std::string::npos) {
30 local_part_ = merged_or_local;
31 } else {
32 namespace_ = merged_or_local.substr(0, i);
33 local_part_ = merged_or_local.substr(i + 1);
34 }
35 }
36
37 QName::~QName() {
38 }
39
40 std::string QName::Merged() const {
41 if (namespace_[0] == '\0')
42 return local_part_;
43
44 std::string result;
45 result.reserve(namespace_.length() + 1 + local_part_.length());
46 result += namespace_;
47 result += ':';
48 result += local_part_;
49 return result;
50 }
51
52 bool QName::IsEmpty() const {
53 return namespace_.empty() && local_part_.empty();
54 }
55
56 int QName::Compare(const StaticQName& other) const {
57 int result = local_part_.compare(other.local);
58 if (result != 0)
59 return result;
60
61 return namespace_.compare(other.ns);
62 }
63
64 int QName::Compare(const QName& other) const {
65 int result = local_part_.compare(other.local_part_);
66 if (result != 0)
67 return result;
68
69 return namespace_.compare(other.namespace_);
70 }
71
72 } // namespace buzz
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698