blob: 930baa535b74bfed357308a26365e9868cf14091 [file] [log] [blame]
// 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 <stdint.h>
#include <string>
#import "ios/web/navigation/nscoder_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
namespace web {
namespace nscoder_util {
void EncodeString(NSCoder* coder, NSString* key, const std::string& string) {
[coder encodeBytes:reinterpret_cast<const uint8_t*>(
std::string DecodeString(NSCoder* decoder, NSString* key) {
NSUInteger length = 0;
const uint8_t* bytes = [decoder decodeBytesForKey:key returnedLength:&length];
return std::string(reinterpret_cast<const char*>(bytes), length);
} // namespace nscoder_util
} // namespace web