xref: /aosp_15_r20/external/webrtc/rtc_base/crypt_string.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright 2015 The WebRTC Project Authors. All rights reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #include "rtc_base/crypt_string.h"
12 
13 namespace rtc {
14 
GetLength() const15 size_t EmptyCryptStringImpl::GetLength() const {
16   return 0;
17 }
18 
CopyTo(char * dest,bool nullterminate) const19 void EmptyCryptStringImpl::CopyTo(char* dest, bool nullterminate) const {
20   if (nullterminate) {
21     *dest = '\0';
22   }
23 }
24 
UrlEncode() const25 std::string EmptyCryptStringImpl::UrlEncode() const {
26   return "";
27 }
28 
Copy() const29 CryptStringImpl* EmptyCryptStringImpl::Copy() const {
30   return new EmptyCryptStringImpl();
31 }
32 
CopyRawTo(std::vector<unsigned char> * dest) const33 void EmptyCryptStringImpl::CopyRawTo(std::vector<unsigned char>* dest) const {
34   dest->clear();
35 }
36 
CryptString()37 CryptString::CryptString() : impl_(new EmptyCryptStringImpl()) {}
38 
CryptString(const CryptString & other)39 CryptString::CryptString(const CryptString& other)
40     : impl_(other.impl_->Copy()) {}
41 
CryptString(const CryptStringImpl & impl)42 CryptString::CryptString(const CryptStringImpl& impl) : impl_(impl.Copy()) {}
43 
44 CryptString::~CryptString() = default;
45 
46 }  // namespace rtc
47