| Index: components/rappor/bytevector.cc
|
| diff --git a/components/rappor/bytevector.cc b/components/rappor/bytevector.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..0edec03f09e86f66796183dfcae49b9572e229d0
|
| --- /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::operator&(ByteVector rhs) const {
|
| + DCHECK(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::operator|(ByteVector rhs) const {
|
| + DCHECK(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::operator~() const {
|
| + ByteVector output(size());
|
| + for (size_t i = 0, len = size(); i < len; i++) {
|
| + output[i] = ~at(i);
|
| + }
|
| + return output;
|
| +}
|
| +
|
| +} // namespace rappor
|
|
|