Index: third_party/xmllite/qname.cc |
diff --git a/third_party/xmllite/qname.cc b/third_party/xmllite/qname.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ba4cfba96226f5a33e1c8997bca1923738b9d4a9 |
--- /dev/null |
+++ b/third_party/xmllite/qname.cc |
@@ -0,0 +1,72 @@ |
+// Copyright 2004 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "third_party/xmllite/qname.h" |
+ |
+namespace buzz { |
+ |
+QName::QName() { |
+} |
+ |
+QName::QName(const QName& qname) |
+ : namespace_(qname.namespace_), |
+ local_part_(qname.local_part_) { |
+} |
+ |
+QName::QName(const StaticQName& const_value) |
+ : namespace_(const_value.ns), |
+ local_part_(const_value.local) { |
+} |
+ |
+QName::QName(const std::string& ns, const std::string& local) |
+ : namespace_(ns), |
+ local_part_(local) { |
+} |
+ |
+QName::QName(const std::string& merged_or_local) { |
+ size_t i = merged_or_local.rfind(':'); |
+ if (i == std::string::npos) { |
+ local_part_ = merged_or_local; |
+ } else { |
+ namespace_ = merged_or_local.substr(0, i); |
+ local_part_ = merged_or_local.substr(i + 1); |
+ } |
+} |
+ |
+QName::~QName() { |
+} |
+ |
+std::string QName::Merged() const { |
+ if (namespace_[0] == '\0') |
+ return local_part_; |
+ |
+ std::string result; |
+ result.reserve(namespace_.length() + 1 + local_part_.length()); |
+ result += namespace_; |
+ result += ':'; |
+ result += local_part_; |
+ return result; |
+} |
+ |
+bool QName::IsEmpty() const { |
+ return namespace_.empty() && local_part_.empty(); |
+} |
+ |
+int QName::Compare(const StaticQName& other) const { |
+ int result = local_part_.compare(other.local); |
+ if (result != 0) |
+ return result; |
+ |
+ return namespace_.compare(other.ns); |
+} |
+ |
+int QName::Compare(const QName& other) const { |
+ int result = local_part_.compare(other.local_part_); |
+ if (result != 0) |
+ return result; |
+ |
+ return namespace_.compare(other.namespace_); |
+} |
+ |
+} // namespace buzz |