Index: components/rappor/bytevector.cc |
diff --git a/components/rappor/bytevector.cc b/components/rappor/bytevector.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..47386a723b4a2aca1b7965a164a8812dc042267b |
--- /dev/null |
+++ b/components/rappor/bytevector.cc |
@@ -0,0 +1,44 @@ |
+// Copyright (c) 2012 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 "base/logging.h" |
+#include "components/rappor/bytevector.h" |
+ |
+namespace rappor { |
+ |
+ByteVector::ByteVector(size_t bytes_size) : std::vector<uint8_t>(bytes_size) {} |
+ |
+ByteVector::ByteVector(const std::vector<uint8_t>& v) |
+ : std::vector<uint8_t>(v) {} |
+ |
+ByteVector::ByteVector(const char* bytes, int size) |
+ : std::vector<uint8_t>(bytes, bytes + size) {} |
+ |
+ByteVector ByteVector::And(ByteVector rhs) const { |
+ DCHECK_EQ(size(), rhs.size()); |
+ ByteVector output(*this); |
+ for (size_t i = 0, len = rhs.size(); i < len; i++) { |
+ output[i] = output[i] & rhs[i]; |
+ } |
+ return output; |
+} |
+ |
+ByteVector ByteVector::Or(ByteVector rhs) const { |
+ DCHECK_EQ(size(), rhs.size()); |
+ ByteVector output(*this); |
+ for (size_t i = 0, len = rhs.size(); i < len; i++) { |
+ output[i] = output[i] | rhs[i]; |
+ } |
+ return output; |
+} |
+ |
+ByteVector ByteVector::Not() const { |
+ ByteVector output(size()); |
+ for (size_t i = 0, len = size(); i < len; i++) { |
+ output[i] = ~at(i); |
+ } |
+ return output; |
+} |
+ |
+} // namespace rappor |