Repository navigation
Expand file tree
/
Copy pathStringUtils.cpp
More file actions
84 lines (68 loc) · 2.11 KB
/
Copy pathStringUtils.cpp
File metadata and controls
84 lines (68 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// 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.
#pragma once
#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<String^>^ StringUtils::ToClr(const std::vector<CefString>& cefStr)
{
auto result = gcnew List<String^>();
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<const wchar_t> pStr = PtrToStringChars(str);
CefString cefStr(pStr);
return cefStr;
}
[DebuggerStepThrough]
std::vector<CefString> StringUtils::ToNative(List<String^>^ str)
{
if (str == nullptr)
{
return std::vector<CefString>();
}
std::vector<CefString> result = std::vector<CefString>();
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<const wchar_t> pStr = PtrToStringChars(str);
cef_string_copy(pStr, str->Length, &cefStr);
}
}
}
}