mirror of https://github.com/axmolengine/axmol.git
string_view for apple
This commit is contained in:
parent
f785632497
commit
8584b40f16
|
@ -171,9 +171,9 @@ bool FileUtilsApple::removeDirectory(std::string_view path) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FileUtilsApple::getPathForDirectory(const std::string& dir,
|
std::string FileUtilsApple::getPathForDirectory(std::string_view dir,
|
||||||
const std::string& resolutionDiretory,
|
std::string_view resolutionDiretory,
|
||||||
const std::string& searchPath) const
|
std::string_view searchPath) const
|
||||||
{
|
{
|
||||||
auto path = searchPath + resolutionDiretory + dir;
|
auto path = searchPath + resolutionDiretory + dir;
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ std::string Application::getVersion()
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::openURL(const std::string& url)
|
bool Application::openURL(std::string_view url)
|
||||||
{
|
{
|
||||||
NSString* msg = [NSString stringWithCString:url.c_str() encoding:NSUTF8StringEncoding];
|
NSString* msg = [NSString stringWithCString:url.c_str() encoding:NSUTF8StringEncoding];
|
||||||
NSURL* nsUrl = [NSURL URLWithString:msg];
|
NSURL* nsUrl = [NSURL URLWithString:msg];
|
||||||
|
|
|
@ -166,7 +166,7 @@ LanguageType Application::getCurrentLanguage()
|
||||||
return utils::getLanguageTypeByISO2([languageCode UTF8String]);
|
return utils::getLanguageTypeByISO2([languageCode UTF8String]);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::openURL(const std::string& url)
|
bool Application::openURL(std::string_view url)
|
||||||
{
|
{
|
||||||
NSString* msg = [NSString stringWithCString:url.c_str() encoding:NSUTF8StringEncoding];
|
NSString* msg = [NSString stringWithCString:url.c_str() encoding:NSUTF8StringEncoding];
|
||||||
NSURL* nsUrl = [NSURL URLWithString:msg];
|
NSURL* nsUrl = [NSURL URLWithString:msg];
|
||||||
|
|
|
@ -481,7 +481,7 @@ bool GLViewImpl::initWithFullScreen(std::string_view viewName)
|
||||||
return initWithRect(viewName, Rect(0, 0, (float)videoMode->width, (float)videoMode->height), 1.0f, false);
|
return initWithRect(viewName, Rect(0, 0, (float)videoMode->width, (float)videoMode->height), 1.0f, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GLViewImpl::initWithFullscreen(const std::string& viewname, const GLFWvidmode& videoMode, GLFWmonitor* monitor)
|
bool GLViewImpl::initWithFullscreen(std::string_view viewname, const GLFWvidmode& videoMode, GLFWmonitor* monitor)
|
||||||
{
|
{
|
||||||
// Create fullscreen on specified monitor at the specified video mode.
|
// Create fullscreen on specified monitor at the specified video mode.
|
||||||
_monitor = monitor;
|
_monitor = monitor;
|
||||||
|
|
|
@ -57,24 +57,24 @@
|
||||||
|
|
||||||
- (void)setFrameWithX:(float)x y:(float)y width:(float)width height:(float)height;
|
- (void)setFrameWithX:(float)x y:(float)y width:(float)width height:(float)height;
|
||||||
|
|
||||||
- (void)setJavascriptInterfaceScheme:(const std::string&)scheme;
|
- (void)setJavascriptInterfaceScheme:(std::string_view)scheme;
|
||||||
|
|
||||||
- (void)loadData:(const std::string&)data
|
- (void)loadData:(std::string_view)data
|
||||||
MIMEType:(const std::string&)MIMEType
|
MIMEType:(std::string_view)MIMEType
|
||||||
textEncodingName:(const std::string&)encodingName
|
textEncodingName:(std::string_view)encodingName
|
||||||
baseURL:(const std::string&)baseURL;
|
baseURL:(std::string_view)baseURL;
|
||||||
|
|
||||||
- (void)loadHTMLString:(const std::string&)string baseURL:(const std::string&)baseURL;
|
- (void)loadHTMLString:(std::string_view)string baseURL:(std::string_view)baseURL;
|
||||||
|
|
||||||
- (void)loadUrl:(const std::string&)urlString cleanCachedData:(BOOL)needCleanCachedData;
|
- (void)loadUrl:(std::string_view)urlString cleanCachedData:(BOOL)needCleanCachedData;
|
||||||
|
|
||||||
- (void)loadFile:(const std::string&)filePath;
|
- (void)loadFile:(std::string_view)filePath;
|
||||||
|
|
||||||
- (void)stopLoading;
|
- (void)stopLoading;
|
||||||
|
|
||||||
- (void)reload;
|
- (void)reload;
|
||||||
|
|
||||||
- (void)evaluateJS:(const std::string&)js;
|
- (void)evaluateJS:(std::string_view)js;
|
||||||
|
|
||||||
- (void)goBack;
|
- (void)goBack;
|
||||||
|
|
||||||
|
@ -189,15 +189,15 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setJavascriptInterfaceScheme:(const std::string&)scheme
|
- (void)setJavascriptInterfaceScheme:(std::string_view)scheme
|
||||||
{
|
{
|
||||||
self.jsScheme = @(scheme.c_str());
|
self.jsScheme = @(scheme.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)loadData:(const std::string&)data
|
- (void)loadData:(std::string_view)data
|
||||||
MIMEType:(const std::string&)MIMEType
|
MIMEType:(std::string_view)MIMEType
|
||||||
textEncodingName:(const std::string&)encodingName
|
textEncodingName:(std::string_view)encodingName
|
||||||
baseURL:(const std::string&)baseURL
|
baseURL:(std::string_view)baseURL
|
||||||
{
|
{
|
||||||
auto path = [[NSBundle mainBundle] resourcePath];
|
auto path = [[NSBundle mainBundle] resourcePath];
|
||||||
path = [path stringByAppendingPathComponent:@(baseURL.c_str())];
|
path = [path stringByAppendingPathComponent:@(baseURL.c_str())];
|
||||||
|
@ -209,7 +209,7 @@
|
||||||
baseURL:url];
|
baseURL:url];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)loadHTMLString:(const std::string&)string baseURL:(const std::string&)baseURL
|
- (void)loadHTMLString:(std::string_view)string baseURL:(std::string_view)baseURL
|
||||||
{
|
{
|
||||||
if (!self.wkWebView)
|
if (!self.wkWebView)
|
||||||
{
|
{
|
||||||
|
@ -221,7 +221,7 @@
|
||||||
[self.wkWebView loadHTMLString:@(string.c_str()) baseURL:url];
|
[self.wkWebView loadHTMLString:@(string.c_str()) baseURL:url];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)loadUrl:(const std::string&)urlString cleanCachedData:(BOOL)needCleanCachedData
|
- (void)loadUrl:(std::string_view)urlString cleanCachedData:(BOOL)needCleanCachedData
|
||||||
{
|
{
|
||||||
if (!self.wkWebView)
|
if (!self.wkWebView)
|
||||||
{
|
{
|
||||||
|
@ -240,7 +240,7 @@
|
||||||
[self.wkWebView loadRequest:request];
|
[self.wkWebView loadRequest:request];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)loadFile:(const std::string&)filePath
|
- (void)loadFile:(std::string_view)filePath
|
||||||
{
|
{
|
||||||
if (!self.wkWebView)
|
if (!self.wkWebView)
|
||||||
{
|
{
|
||||||
|
@ -281,7 +281,7 @@
|
||||||
[self.wkWebView goForward];
|
[self.wkWebView goForward];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)evaluateJS:(const std::string&)js
|
- (void)evaluateJS:(std::string_view)js
|
||||||
{
|
{
|
||||||
if (!self.wkWebView)
|
if (!self.wkWebView)
|
||||||
{
|
{
|
||||||
|
@ -411,37 +411,37 @@ WebViewImpl::~WebViewImpl()
|
||||||
_uiWebViewWrapper = nullptr;
|
_uiWebViewWrapper = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebViewImpl::setJavascriptInterfaceScheme(const std::string& scheme)
|
void WebViewImpl::setJavascriptInterfaceScheme(std::string_view scheme)
|
||||||
{
|
{
|
||||||
[_uiWebViewWrapper setJavascriptInterfaceScheme:scheme];
|
[_uiWebViewWrapper setJavascriptInterfaceScheme:scheme];
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebViewImpl::loadData(const Data& data,
|
void WebViewImpl::loadData(const Data& data,
|
||||||
const std::string& MIMEType,
|
std::string_view MIMEType,
|
||||||
const std::string& encoding,
|
std::string_view encoding,
|
||||||
const std::string& baseURL)
|
std::string_view baseURL)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::string dataString(reinterpret_cast<char*>(data.getBytes()), static_cast<unsigned int>(data.getSize()));
|
std::string dataString(reinterpret_cast<char*>(data.getBytes()), static_cast<unsigned int>(data.getSize()));
|
||||||
[_uiWebViewWrapper loadData:dataString MIMEType:MIMEType textEncodingName:encoding baseURL:baseURL];
|
[_uiWebViewWrapper loadData:dataString MIMEType:MIMEType textEncodingName:encoding baseURL:baseURL];
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebViewImpl::loadHTMLString(const std::string& string, const std::string& baseURL)
|
void WebViewImpl::loadHTMLString(std::string_view string, std::string_view baseURL)
|
||||||
{
|
{
|
||||||
[_uiWebViewWrapper loadHTMLString:string baseURL:baseURL];
|
[_uiWebViewWrapper loadHTMLString:string baseURL:baseURL];
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebViewImpl::loadURL(const std::string& url)
|
void WebViewImpl::loadURL(std::string_view url)
|
||||||
{
|
{
|
||||||
this->loadURL(url, false);
|
this->loadURL(url, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebViewImpl::loadURL(const std::string& url, bool cleanCachedData)
|
void WebViewImpl::loadURL(std::string_view url, bool cleanCachedData)
|
||||||
{
|
{
|
||||||
[_uiWebViewWrapper loadUrl:url cleanCachedData:cleanCachedData];
|
[_uiWebViewWrapper loadUrl:url cleanCachedData:cleanCachedData];
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebViewImpl::loadFile(const std::string& fileName)
|
void WebViewImpl::loadFile(std::string_view fileName)
|
||||||
{
|
{
|
||||||
auto fullPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(fileName);
|
auto fullPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(fileName);
|
||||||
[_uiWebViewWrapper loadFile:fullPath];
|
[_uiWebViewWrapper loadFile:fullPath];
|
||||||
|
@ -477,7 +477,7 @@ void WebViewImpl::goForward()
|
||||||
[_uiWebViewWrapper goForward];
|
[_uiWebViewWrapper goForward];
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebViewImpl::evaluateJS(const std::string& js)
|
void WebViewImpl::evaluateJS(std::string_view js)
|
||||||
{
|
{
|
||||||
[_uiWebViewWrapper evaluateJS:js];
|
[_uiWebViewWrapper evaluateJS:js];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue