Index: cloud_print/gcp20/prototype/dns_txt_builder.cc |
diff --git a/cloud_print/gcp20/prototype/dns_txt_builder.cc b/cloud_print/gcp20/prototype/dns_txt_builder.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5c6d92332b4912d808cd6baac2e84db6d040c8d8 |
--- /dev/null |
+++ b/cloud_print/gcp20/prototype/dns_txt_builder.cc |
@@ -0,0 +1,34 @@ |
+// Copyright 2013 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 "cloud_print/gcp20/prototype/dns_txt_builder.h" |
+ |
+#include <string.h> |
+ |
+#include "base/logging.h" |
+#include "base/strings/string_piece.h" |
+ |
+DnsTxtBuilder::DnsTxtBuilder() { |
+} |
+ |
+DnsTxtBuilder::~DnsTxtBuilder() { |
+} |
+ |
+void DnsTxtBuilder::AddRecord(const char* str) { |
+ size_t length_ptr = record.size(); // Remember position of length byte. |
+ record += '\0'; // Allocate space for length byte. |
+ record += str; |
+ int len = strlen(str); |
+ DCHECK_LT(len, 256); |
+ record[length_ptr] = static_cast<char>(len); // Set length byte. |
+} |
+ |
+void DnsTxtBuilder::Build(std::string* out) const { |
+ *out = record; |
+} |
+ |
+const std::string& DnsTxtBuilder::Build() const { |
+ return record; |
+} |
+ |