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

Unified Diff: third_party/libjingle/overrides/talk/xmllite/qname.cc

Issue 2255007: New libjingle integrated to chrome. (Closed)
Patch Set: - Created 10 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/libjingle/overrides/talk/xmllite/qname.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/libjingle/overrides/talk/xmllite/qname.cc
diff --git a/third_party/libjingle/overrides/talk/xmllite/qname.cc b/third_party/libjingle/overrides/talk/xmllite/qname.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5c9e62dbca5541ca95db01d86d024f387f26711d
--- /dev/null
+++ b/third_party/libjingle/overrides/talk/xmllite/qname.cc
@@ -0,0 +1,65 @@
+// Copyright (c) 2010 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 "talk/xmllite/qname.h"
+
+#include "talk/base/common.h"
+#include "talk/xmllite/xmlelement.h"
+#include "talk/xmllite/xmlconstants.h"
+
+namespace buzz {
+
+QName::QName() : namespace_(QN_EMPTY.namespace_),
+ local_part_(QN_EMPTY.local_part_) {}
+
+QName::QName(const std::string & ns, const std::string & local) :
+ namespace_(ns), local_part_(local) {}
+
+QName::QName(bool add, const std::string & ns, const std::string & local) :
+ namespace_(ns), local_part_(local) {}
+
+static std::string
+QName_LocalPart(const std::string & name) {
+ size_t i = name.rfind(':');
+ if (i == std::string::npos)
+ return name;
+ return name.substr(i + 1);
+}
+
+static std::string
+QName_Namespace(const std::string & name) {
+ size_t i = name.rfind(':');
+ if (i == std::string::npos)
+ return STR_EMPTY;
+ return name.substr(0, i);
+}
+
+QName::QName(const std::string & mergedOrLocal) :
+ namespace_(QName_Namespace(mergedOrLocal)),
+ local_part_(QName_LocalPart(mergedOrLocal)) {}
+
+std::string
+QName::Merged() const {
+ if (namespace_ == STR_EMPTY)
+ return local_part_;
+ return namespace_ + ':' + local_part_;
+}
+
+bool
+QName::operator==(const QName & other) const {
+ return
+ local_part_ == other.local_part_ &&
+ namespace_ == other.namespace_;
+}
+
+int
+QName::Compare(const QName & other) const {
+ int result = local_part_.compare(other.local_part_);
+ if (result)
+ return result;
+
+ return namespace_.compare(other.namespace_);
+}
+
+} // namespace buzz
« no previous file with comments | « third_party/libjingle/overrides/talk/xmllite/qname.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698