Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
61b2ae0f
Commit
61b2ae0f
authored
Apr 24, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
java/String: add method ToString()
parent
0d2ec5ea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
2 deletions
+28
-2
String.cxx
src/java/String.cxx
+19
-1
String.hxx
src/java/String.hxx
+9
-1
No files found.
src/java/String.cxx
View file @
61b2ae0f
/*
/*
* Copyright 2010-201
8
Max Kellermann <max.kellermann@gmail.com>
* Copyright 2010-201
9
Max Kellermann <max.kellermann@gmail.com>
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* modification, are permitted provided that the following conditions
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
#include "String.hxx"
#include "String.hxx"
#include "util/TruncateString.hxx"
#include "util/TruncateString.hxx"
#include "util/ScopeExit.hxx"
char
*
char
*
Java
::
String
::
CopyTo
(
JNIEnv
*
env
,
jstring
value
,
Java
::
String
::
CopyTo
(
JNIEnv
*
env
,
jstring
value
,
...
@@ -42,3 +43,20 @@ Java::String::CopyTo(JNIEnv *env, jstring value,
...
@@ -42,3 +43,20 @@ Java::String::CopyTo(JNIEnv *env, jstring value,
env
->
ReleaseStringUTFChars
(
value
,
p
);
env
->
ReleaseStringUTFChars
(
value
,
p
);
return
result
;
return
result
;
}
}
std
::
string
Java
::
String
::
ToString
(
JNIEnv
*
env
,
jstring
s
)
noexcept
{
assert
(
env
!=
nullptr
);
assert
(
s
!=
nullptr
);
const
char
*
p
=
env
->
GetStringUTFChars
(
s
,
nullptr
);
if
(
p
==
nullptr
)
return
std
::
string
();
AtScopeExit
(
env
,
s
,
p
)
{
env
->
ReleaseStringUTFChars
(
s
,
p
);
};
return
std
::
string
(
p
);
}
src/java/String.hxx
View file @
61b2ae0f
/*
/*
* Copyright 2010-201
8
Max Kellermann <max.kellermann@gmail.com>
* Copyright 2010-201
9
Max Kellermann <max.kellermann@gmail.com>
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* modification, are permitted provided that the following conditions
...
@@ -34,6 +34,8 @@
...
@@ -34,6 +34,8 @@
#include <jni.h>
#include <jni.h>
#include <string>
#include <stddef.h>
#include <stddef.h>
namespace
Java
{
namespace
Java
{
...
@@ -69,6 +71,12 @@ namespace Java {
...
@@ -69,6 +71,12 @@ namespace Java {
char
*
buffer
,
size_t
max_size
)
noexcept
{
char
*
buffer
,
size_t
max_size
)
noexcept
{
return
CopyTo
(
env
,
Get
(),
buffer
,
max_size
);
return
CopyTo
(
env
,
Get
(),
buffer
,
max_size
);
}
}
static
std
::
string
ToString
(
JNIEnv
*
env
,
jstring
s
)
noexcept
;
std
::
string
ToString
()
const
noexcept
{
return
ToString
(
GetEnv
(),
Get
());
}
};
};
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment