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

Unified Diff: third_party/libjingle_xmpp/xmllite/qname.h

Issue 2443903004: Add xmllite and xmpp sources to third_party/ (Closed)
Patch Set: Fix GN and sort includes Created 4 years 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
Index: third_party/libjingle_xmpp/xmllite/qname.h
diff --git a/third_party/libjingle_xmpp/xmllite/qname.h b/third_party/libjingle_xmpp/xmllite/qname.h
new file mode 100644
index 0000000000000000000000000000000000000000..5d050fa695d5fbb06eaba30cf93b2dd5b4e81e78
--- /dev/null
+++ b/third_party/libjingle_xmpp/xmllite/qname.h
@@ -0,0 +1,77 @@
+// Copyright 2004 The Chromium Authors. All rights reserved.
Sergey Ulanov 2016/12/22 22:57:59 I think the right thing to do here is to keep the
kjellander_chromium 2016/12/27 12:49:21 You're probably right, I changed to Chromium heade
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBRTC_LIBJINGLE_XMLLITE_QNAME_H_
+#define WEBRTC_LIBJINGLE_XMLLITE_QNAME_H_
+
+#include <string>
+
+namespace buzz {
+
+class QName;
+
+// StaticQName is used to represend constant quailified names. They
+// can be initialized statically and don't need intializers code, e.g.
+// const StaticQName QN_FOO = { "foo_namespace", "foo" };
+//
+// Beside this use case, QName should be used everywhere
+// else. StaticQName instances are implicitly converted to QName
+// objects.
+struct StaticQName {
+ const char* const ns;
+ const char* const local;
+
+ bool operator==(const QName& other) const;
+ bool operator!=(const QName& other) const;
+};
+
+class QName {
+ public:
+ QName();
+ QName(const QName& qname);
+ QName(const StaticQName& const_value);
+ QName(const std::string& ns, const std::string& local);
+ explicit QName(const std::string& merged_or_local);
+ ~QName();
+
+ const std::string& Namespace() const { return namespace_; }
+ const std::string& LocalPart() const { return local_part_; }
+ std::string Merged() const;
+ bool IsEmpty() const;
+
+ int Compare(const StaticQName& other) const;
+ int Compare(const QName& other) const;
+
+ bool operator==(const StaticQName& other) const {
+ return Compare(other) == 0;
+ }
+ bool operator==(const QName& other) const {
+ return Compare(other) == 0;
+ }
+ bool operator!=(const StaticQName& other) const {
+ return Compare(other) != 0;
+ }
+ bool operator!=(const QName& other) const {
+ return Compare(other) != 0;
+ }
+ bool operator<(const QName& other) const {
+ return Compare(other) < 0;
+ }
+
+ private:
+ std::string namespace_;
+ std::string local_part_;
+};
+
+inline bool StaticQName::operator==(const QName& other) const {
+ return other.Compare(*this) == 0;
+}
+
+inline bool StaticQName::operator!=(const QName& other) const {
+ return other.Compare(*this) != 0;
+}
+
+} // namespace buzz
+
+#endif // WEBRTC_LIBJINGLE_XMLLITE_QNAME_H_

Powered by Google App Engine
This is Rietveld 408576698