// Copyright © 2010-2014 The CefSharp 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 "Stdafx.h" using namespace System::Diagnostics; using namespace System::Collections::Generic; namespace CefSharp { namespace Internals { [DebuggerStepThrough] String^ StringUtils::ToClr(const cef_string_t& cefStr) { return gcnew String(cefStr.str); } [DebuggerStepThrough] String^ StringUtils::ToClr(const CefString& cefStr) { return gcnew String(cefStr.c_str()); } [DebuggerStepThrough] List^ StringUtils::ToClr(const std::vector& cefStr) { auto result = gcnew List(); for each(CefString s in cefStr) { result->Add(StringUtils::ToClr(s)); } return result; } [DebuggerStepThrough] CefString StringUtils::ToNative(String^ str) { if (str == nullptr) { return CefString(); } pin_ptr pStr = PtrToStringChars(str); CefString cefStr(pStr); return cefStr; } [DebuggerStepThrough] std::vector StringUtils::ToNative(List^ str) { if (str == nullptr) { return std::vector(); } std::vector result = std::vector(); for each (String^ s in str) { result.push_back(StringUtils::ToNative(s)); } return result; } [DebuggerStepThrough] void StringUtils::AssignNativeFromClr(cef_string_t& cefStr, String^ str) { cef_string_clear(&cefStr); if (str != nullptr) { pin_ptr pStr = PtrToStringChars(str); cef_string_copy(pStr, str->Length, &cefStr); } } } }