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
f58c14a7
Commit
f58c14a7
authored
Mar 28, 2021
by
Max Kellermann
Committed by
Max Kellermann
Apr 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Java: no namespace indent
parent
a52ce7bb
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
345 additions
and
329 deletions
+345
-329
Class.hxx
src/java/Class.hxx
+38
-36
Exception.cxx
src/java/Exception.cxx
+1
-1
Exception.hxx
src/java/Exception.hxx
+25
-23
File.hxx
src/java/File.hxx
+25
-23
Global.cxx
src/java/Global.cxx
+8
-6
Global.hxx
src/java/Global.hxx
+21
-19
Object.hxx
src/java/Object.hxx
+30
-28
Ref.hxx
src/java/Ref.hxx
+160
-158
String.hxx
src/java/String.hxx
+37
-35
No files found.
src/java/Class.hxx
View file @
f58c14a7
/*
/*
* Copyright 2010-20
18
Max Kellermann <max.kellermann@gmail.com>
* Copyright 2010-20
21
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
...
@@ -36,47 +36,49 @@
...
@@ -36,47 +36,49 @@
#include <cassert>
#include <cassert>
namespace
Java
{
namespace
Java
{
/**
* Wrapper for a local "jclass" reference.
*/
class
Class
:
public
LocalRef
<
jclass
>
{
public
:
Class
(
JNIEnv
*
env
,
jclass
cls
)
noexcept
:
LocalRef
<
jclass
>
(
env
,
cls
)
{}
Class
(
JNIEnv
*
env
,
const
char
*
name
)
noexcept
/**
:
LocalRef
<
jclass
>
(
env
,
env
->
FindClass
(
name
))
{}
* Wrapper for a local "jclass" reference.
};
*/
class
Class
:
public
LocalRef
<
jclass
>
{
public
:
Class
(
JNIEnv
*
env
,
jclass
cls
)
noexcept
:
LocalRef
<
jclass
>
(
env
,
cls
)
{}
Class
(
JNIEnv
*
env
,
const
char
*
name
)
noexcept
:
LocalRef
<
jclass
>
(
env
,
env
->
FindClass
(
name
))
{}
};
/**
* Wrapper for a global "jclass" reference.
*/
class
TrivialClass
:
public
TrivialRef
<
jclass
>
{
public
:
void
Find
(
JNIEnv
*
env
,
const
char
*
name
)
noexcept
{
assert
(
env
!=
nullptr
);
assert
(
name
!=
nullptr
);
/**
jclass
cls
=
env
->
FindClass
(
name
);
* Wrapper for a global "jclass" reference.
assert
(
cls
!=
nullptr
);
*/
class
TrivialClass
:
public
TrivialRef
<
jclass
>
{
public
:
void
Find
(
JNIEnv
*
env
,
const
char
*
name
)
noexcept
{
assert
(
env
!=
nullptr
);
assert
(
name
!=
nullptr
);
jclass
cls
=
env
->
FindClass
(
name
);
Set
(
env
,
cls
);
assert
(
cls
!=
nullptr
);
env
->
DeleteLocalRef
(
cls
);
}
Set
(
env
,
cls
);
bool
FindOptional
(
JNIEnv
*
env
,
const
char
*
name
)
noexcept
{
env
->
DeleteLocalRef
(
cls
);
assert
(
env
!=
nullptr
);
}
assert
(
name
!=
nullptr
);
bool
FindOptional
(
JNIEnv
*
env
,
const
char
*
name
)
noexcept
{
jclass
cls
=
env
->
FindClass
(
name
);
assert
(
env
!=
nullptr
);
if
(
DiscardException
(
env
))
assert
(
name
!=
nullptr
)
;
return
false
;
jclass
cls
=
env
->
FindClass
(
name
);
Set
(
env
,
cls
);
if
(
DiscardException
(
env
))
env
->
DeleteLocalRef
(
cls
);
return
false
;
return
true
;
}
};
Set
(
env
,
cls
);
}
// namespace Java
env
->
DeleteLocalRef
(
cls
);
return
true
;
}
};
}
#endif
#endif
src/java/Exception.cxx
View file @
f58c14a7
/*
/*
* Copyright 2010-20
19
Max Kellermann <max.kellermann@gmail.com>
* Copyright 2010-20
21
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
...
...
src/java/Exception.hxx
View file @
f58c14a7
/*
/*
* Copyright 2010-20
19
Max Kellermann <max.kellermann@gmail.com>
* Copyright 2010-20
21
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
...
@@ -35,28 +35,30 @@
...
@@ -35,28 +35,30 @@
#include <jni.h>
#include <jni.h>
namespace
Java
{
namespace
Java
{
class
Exception
:
public
std
::
runtime_error
{
public
:
class
Exception
:
public
std
::
runtime_error
{
explicit
Exception
(
JNIEnv
*
env
,
jthrowable
e
)
noexcept
;
public
:
}
;
explicit
Exception
(
JNIEnv
*
env
,
jthrowable
e
)
noexcept
;
};
/**
* Check if a Java exception has occurred, and if yes, convert
/**
* it to a C++ #Exception and throw that.
* Check if a Java exception has occurred, and if yes, convert
*/
* it to a C++ #Exception and throw that.
void
RethrowException
(
JNIEnv
*
env
);
*/
void
RethrowException
(
JNIEnv
*
env
);
/**
* Check if an exception has occurred, and discard it.
/**
*
* Check if an exception has occurred, and discard it.
* @return true if an exception was found (and discarded)
*
*/
* @return true if an exception was found (and discarded)
static
inline
bool
DiscardException
(
JNIEnv
*
env
)
noexcept
{
*/
bool
result
=
env
->
ExceptionCheck
();
static
inline
bool
DiscardException
(
JNIEnv
*
env
)
noexcept
{
if
(
result
)
bool
result
=
env
->
ExceptionCheck
();
env
->
ExceptionClear
();
if
(
result
)
return
result
;
env
->
ExceptionClear
()
;
}
return
result
;
}
}
}
// namespace Java
#endif
#endif
src/java/File.hxx
View file @
f58c14a7
/*
/*
* Copyright 2010-20
18
Max Kellermann <max.kellermann@gmail.com>
* Copyright 2010-20
21
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
...
@@ -37,30 +37,32 @@
...
@@ -37,30 +37,32 @@
class
AllocatedPath
;
class
AllocatedPath
;
namespace
Java
{
namespace
Java
{
/**
* Wrapper for a java.io.File object.
*/
class
File
:
public
LocalObject
{
static
jmethodID
getAbsolutePath_method
;
public
:
/**
gcc_nonnull_all
* Wrapper for a java.io.File object.
static
void
Initialise
(
JNIEnv
*
env
)
noexcept
;
*/
class
File
:
public
LocalObject
{
static
jmethodID
getAbsolutePath_method
;
public
:
gcc_nonnull_all
static
void
Initialise
(
JNIEnv
*
env
)
noexcept
;
gcc_nonnull_all
gcc_nonnull_all
static
jstring
getAbsolutePath
(
JNIEnv
*
env
,
jobject
file
)
noexcept
{
static
jstring
getAbsolutePath
(
JNIEnv
*
env
,
jobject
file
)
noexcept
{
return
(
jstring
)
env
->
CallObjectMethod
(
file
,
return
(
jstring
)
env
->
CallObjectMethod
(
file
,
getAbsolutePath_method
);
getAbsolutePath_method
);
}
}
/**
* Invoke File.getAbsolutePath() and release the
* specified File reference.
*/
gcc_pure
gcc_nonnull_all
static
AllocatedPath
ToAbsolutePath
(
JNIEnv
*
env
,
jobject
file
)
noexcept
;
};
/**
}
// namespace Java
* Invoke File.getAbsolutePath() and release the
* specified File reference.
*/
gcc_pure
gcc_nonnull_all
static
AllocatedPath
ToAbsolutePath
(
JNIEnv
*
env
,
jobject
file
)
noexcept
;
};
}
#endif
#endif
src/java/Global.cxx
View file @
f58c14a7
/*
/*
* Copyright 2010-20
18
Max Kellermann <max.kellermann@gmail.com>
* Copyright 2010-20
21
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
...
@@ -30,10 +30,12 @@
...
@@ -30,10 +30,12 @@
#include "Global.hxx"
#include "Global.hxx"
namespace
Java
{
namespace
Java
{
JavaVM
*
jvm
;
void
Init
(
JNIEnv
*
env
)
noexcept
JavaVM
*
jvm
;
{
env
->
GetJavaVM
(
&
jvm
);
void
Init
(
JNIEnv
*
env
)
noexcept
}
{
env
->
GetJavaVM
(
&
jvm
);
}
}
}
// namespace Java
src/java/Global.hxx
View file @
f58c14a7
/*
/*
* Copyright 2010-20
18
Max Kellermann <max.kellermann@gmail.com>
* Copyright 2010-20
21
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
...
@@ -35,24 +35,26 @@
...
@@ -35,24 +35,26 @@
#include <jni.h>
#include <jni.h>
namespace
Java
{
namespace
Java
{
extern
JavaVM
*
jvm
;
extern
JavaVM
*
jvm
;
void
Init
(
JNIEnv
*
env
)
noexcept
;
void
Init
(
JNIEnv
*
env
)
noexcept
;
static
inline
void
DetachCurrentThread
()
noexcept
static
inline
void
{
DetachCurrentThread
()
noexcept
if
(
jvm
!=
nullptr
)
{
jvm
->
DetachCurrentThread
();
if
(
jvm
!=
nullptr
)
}
jvm
->
DetachCurrentThread
();
static
inline
gcc_pure
JNIEnv
*
GetEnv
()
noexcept
{
JNIEnv
*
env
;
jvm
->
AttachCurrentThread
(
&
env
,
nullptr
);
return
env
;
}
}
}
static
inline
gcc_pure
JNIEnv
*
GetEnv
()
noexcept
{
JNIEnv
*
env
;
jvm
->
AttachCurrentThread
(
&
env
,
nullptr
);
return
env
;
}
}
// namespace Java
#endif
#endif
src/java/Object.hxx
View file @
f58c14a7
/*
/*
* Copyright 2010-20
19
Max Kellermann <max.kellermann@gmail.com>
* Copyright 2010-20
21
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
...
@@ -37,40 +37,42 @@
...
@@ -37,40 +37,42 @@
#include <cassert>
#include <cassert>
namespace
Java
{
namespace
Java
{
/**
* Wrapper for a local "jobject" reference.
*/
typedef
LocalRef
<
jobject
>
LocalObject
;
class
GlobalObject
:
public
GlobalRef
<
jobject
>
{
public
:
/**
/**
* Wrapper for a local "jobject" reference.
* Constructs an uninitialized object. The method
* set() must be called before it is destructed.
*/
*/
typedef
LocalRef
<
jobject
>
LocalObjec
t
;
GlobalObject
()
=
defaul
t
;
class
GlobalObject
:
public
GlobalRef
<
jobject
>
{
GlobalObject
(
JNIEnv
*
env
,
jobject
obj
)
noexcept
public
:
:
GlobalRef
<
jobject
>
(
env
,
obj
)
{}
/**
};
* Constructs an uninitialized object. The method
* set() must be called before it is destructed.
*/
GlobalObject
()
=
default
;
GlobalObject
(
JNIEnv
*
env
,
jobject
obj
)
noexcept
/**
:
GlobalRef
<
jobject
>
(
env
,
obj
)
{}
* Utilities for java.net.Object.
};
*/
class
Object
{
static
jmethodID
toString_method
;
/**
public
:
* Utilities for java.net.Object.
static
void
Initialise
(
JNIEnv
*
env
);
*/
class
Object
{
static
jmethodID
toString_method
;
public
:
static
jstring
toString
(
JNIEnv
*
env
,
jobject
o
)
{
static
void
Initialise
(
JNIEnv
*
env
);
assert
(
env
!=
nullptr
);
assert
(
o
!=
nullptr
);
assert
(
toString_method
!=
nullptr
);
static
jstring
toString
(
JNIEnv
*
env
,
jobject
o
)
{
return
(
jstring
)
env
->
CallObjectMethod
(
o
,
toString_method
);
assert
(
env
!=
nullptr
);
}
assert
(
o
!=
nullptr
);
};
assert
(
toString_method
!=
nullptr
);
return
(
jstring
)
env
->
CallObjectMethod
(
o
,
toString_method
);
}
// namespace Java
}
};
}
#endif
#endif
src/java/Ref.hxx
View file @
f58c14a7
/*
/*
* Copyright 2010-20
18
Max Kellermann <max.kellermann@gmail.com>
* Copyright 2010-20
21
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
...
@@ -38,170 +38,172 @@
...
@@ -38,170 +38,172 @@
#include <utility>
#include <utility>
namespace
Java
{
namespace
Java
{
/**
* Hold a local reference on a JNI object.
*/
template
<
typename
T
>
class
LocalRef
{
JNIEnv
*
env
;
T
value
=
nullptr
;
public
:
LocalRef
()
noexcept
=
default
;
/**
/**
* Hold a local reference on a JNI object.
* The local reference is obtained by the caller. May
* be nullptr.
*/
*/
template
<
typename
T
>
LocalRef
(
JNIEnv
*
_env
,
T
_value
)
noexcept
class
LocalRef
{
:
env
(
_env
),
value
(
_value
)
JNIEnv
*
env
;
{
T
value
=
nullptr
;
assert
(
env
!=
nullptr
);
}
public
:
LocalRef
()
noexcept
=
default
;
LocalRef
(
LocalRef
&&
src
)
noexcept
:
env
(
src
.
env
),
/**
value
(
std
::
exchange
(
src
.
value
,
nullptr
))
{}
* The local reference is obtained by the caller. May
* be nullptr.
~
LocalRef
()
noexcept
{
*/
if
(
value
!=
nullptr
)
LocalRef
(
JNIEnv
*
_env
,
T
_value
)
noexcept
env
->
DeleteLocalRef
(
value
);
:
env
(
_env
),
value
(
_value
)
}
{
assert
(
env
!=
nullptr
);
LocalRef
&
operator
=
(
LocalRef
&&
src
)
noexcept
{
}
using
std
::
swap
;
swap
(
env
,
src
.
env
);
LocalRef
(
LocalRef
&&
src
)
noexcept
swap
(
value
,
src
.
value
);
:
env
(
src
.
env
),
return
*
this
;
value
(
std
::
exchange
(
src
.
value
,
nullptr
))
{}
}
~
LocalRef
()
noexcept
{
JNIEnv
*
GetEnv
()
const
noexcept
{
if
(
value
!=
nullptr
)
return
env
;
env
->
DeleteLocalRef
(
value
);
}
}
operator
bool
()
const
noexcept
{
LocalRef
&
operator
=
(
LocalRef
&&
src
)
noexcept
{
return
value
!=
nullptr
;
using
std
::
swap
;
}
swap
(
env
,
src
.
env
);
swap
(
value
,
src
.
value
);
T
Get
()
const
noexcept
{
return
*
this
;
return
value
;
}
}
JNIEnv
*
GetEnv
()
const
noexcept
{
operator
T
()
const
noexcept
{
return
env
;
return
value
;
}
}
};
operator
bool
()
const
noexcept
{
return
value
!=
nullptr
;
/**
}
* Hold a global reference on a JNI object.
*/
T
Get
()
const
noexcept
{
template
<
typename
T
>
return
value
;
class
GlobalRef
{
}
T
value
;
operator
T
()
const
noexcept
{
return
value
;
}
};
public
:
/**
/**
* Hold a global reference on a JNI object.
* Constructs an uninitialized object. The method
* set() must be called before it is destructed.
*/
*/
template
<
typename
T
>
GlobalRef
()
=
default
;
class
GlobalRef
{
T
value
;
GlobalRef
(
JNIEnv
*
env
,
T
_value
)
noexcept
:
value
(
_value
)
public
:
{
/**
assert
(
env
!=
nullptr
);
* Constructs an uninitialized object. The method
assert
(
value
!=
nullptr
);
* set() must be called before it is destructed.
*/
value
=
(
T
)
env
->
NewGlobalRef
(
value
);
GlobalRef
()
=
default
;
}
GlobalRef
(
JNIEnv
*
env
,
T
_value
)
noexcept
~
GlobalRef
()
noexcept
{
:
value
(
_value
)
GetEnv
()
->
DeleteGlobalRef
(
value
);
{
}
assert
(
env
!=
nullptr
);
assert
(
value
!=
nullptr
);
GlobalRef
(
const
GlobalRef
&
other
)
=
delete
;
GlobalRef
&
operator
=
(
const
GlobalRef
&
other
)
=
delete
;
value
=
(
T
)
env
->
NewGlobalRef
(
value
);
}
~
GlobalRef
()
noexcept
{
GetEnv
()
->
DeleteGlobalRef
(
value
);
}
GlobalRef
(
const
GlobalRef
&
other
)
=
delete
;
GlobalRef
&
operator
=
(
const
GlobalRef
&
other
)
=
delete
;
/**
* Sets the object, ignoring the previous value. This
* is only allowed once after the default constructor
* was used.
*/
void
Set
(
JNIEnv
*
env
,
T
_value
)
noexcept
{
assert
(
_value
!=
nullptr
);
value
=
(
T
)
env
->
NewGlobalRef
(
_value
);
}
T
Get
()
const
noexcept
{
return
value
;
}
operator
T
()
const
noexcept
{
return
value
;
}
};
/**
/**
* Container for a global reference to a JNI object that gets
* Sets the object, ignoring the previous value. This
* initialised and deinitialised explicitly. Since there is
* is only allowed once after the default constructor
* no implicit initialisation in the default constructor, this
* was used.
* is a trivial C++ class. It should only be used for global
* variables that are implicitly initialised with zeroes.
*/
*/
template
<
typename
T
>
void
Set
(
JNIEnv
*
env
,
T
_value
)
noexcept
{
class
TrivialRef
{
assert
(
_value
!=
nullptr
);
T
value
;
value
=
(
T
)
env
->
NewGlobalRef
(
_value
);
public
:
}
TrivialRef
()
=
default
;
T
Get
()
const
noexcept
{
TrivialRef
(
const
TrivialRef
&
other
)
=
delete
;
return
value
;
TrivialRef
&
operator
=
(
const
TrivialRef
&
other
)
=
delete
;
}
bool
IsDefined
()
const
noexcept
{
operator
T
()
const
noexcept
{
return
value
!=
nullptr
;
return
value
;
}
}
};
/**
* Obtain a global reference on the specified object
/**
* and store it. This object must not be set already.
* Container for a global reference to a JNI object that gets
*/
* initialised and deinitialised explicitly. Since there is
void
Set
(
JNIEnv
*
env
,
T
_value
)
noexcept
{
* no implicit initialisation in the default constructor, this
assert
(
value
==
nullptr
);
* is a trivial C++ class. It should only be used for global
assert
(
_value
!=
nullptr
);
* variables that are implicitly initialised with zeroes.
*/
value
=
(
T
)
env
->
NewGlobalRef
(
_value
);
template
<
typename
T
>
}
class
TrivialRef
{
T
value
;
/**
* Release the global reference and clear this object.
public
:
*/
TrivialRef
()
=
default
;
void
Clear
(
JNIEnv
*
env
)
noexcept
{
assert
(
value
!=
nullptr
);
TrivialRef
(
const
TrivialRef
&
other
)
=
delete
;
TrivialRef
&
operator
=
(
const
TrivialRef
&
other
)
=
delete
;
env
->
DeleteGlobalRef
(
value
);
value
=
nullptr
;
bool
IsDefined
()
const
noexcept
{
}
return
value
!=
nullptr
;
}
/**
* Release the global reference and clear this object.
/**
* It is allowed to call this method without ever
* Obtain a global reference on the specified object
* calling Set().
* and store it. This object must not be set already.
*/
*/
void
ClearOptional
(
JNIEnv
*
env
)
noexcept
{
void
Set
(
JNIEnv
*
env
,
T
_value
)
noexcept
{
if
(
value
!=
nullptr
)
assert
(
value
==
nullptr
);
Clear
(
env
);
assert
(
_value
!=
nullptr
);
}
value
=
(
T
)
env
->
NewGlobalRef
(
_value
);
T
Get
()
const
noexcept
{
}
return
value
;
}
/**
* Release the global reference and clear this object.
operator
T
()
const
noexcept
{
*/
return
value
;
void
Clear
(
JNIEnv
*
env
)
noexcept
{
}
assert
(
value
!=
nullptr
);
};
}
env
->
DeleteGlobalRef
(
value
);
value
=
nullptr
;
}
/**
* Release the global reference and clear this object.
* It is allowed to call this method without ever
* calling Set().
*/
void
ClearOptional
(
JNIEnv
*
env
)
noexcept
{
if
(
value
!=
nullptr
)
Clear
(
env
);
}
T
Get
()
const
noexcept
{
return
value
;
}
operator
T
()
const
noexcept
{
return
value
;
}
};
}
// namespace Java
#endif
#endif
src/java/String.hxx
View file @
f58c14a7
/*
/*
* Copyright 2010-20
19
Max Kellermann <max.kellermann@gmail.com>
* Copyright 2010-20
21
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
...
@@ -38,45 +38,47 @@
...
@@ -38,45 +38,47 @@
#include <string>
#include <string>
namespace
Java
{
namespace
Java
{
/**
* Wrapper for a local "jstring" reference.
*/
class
String
:
public
LocalRef
<
jstring
>
{
public
:
String
(
JNIEnv
*
env
,
jstring
value
)
noexcept
:
LocalRef
<
jstring
>
(
env
,
value
)
{}
String
(
JNIEnv
*
_env
,
const
char
*
_value
)
noexcept
:
LocalRef
<
jstring
>
(
_env
,
_env
->
NewStringUTF
(
_value
))
{}
/**
/**
* Wrapper for a local "jstring" reference.
* Copy the value to the specified buffer. Truncates
* the value if it does not fit into the buffer.
*
* @return a pointer to the terminating null byte,
* nullptr on error
*/
*/
class
String
:
public
LocalRef
<
jstring
>
{
static
char
*
CopyTo
(
JNIEnv
*
env
,
jstring
value
,
public
:
char
*
buffer
,
size_t
max_size
)
noexcept
;
String
(
JNIEnv
*
env
,
jstring
value
)
noexcept
:
LocalRef
<
jstring
>
(
env
,
value
)
{}
String
(
JNIEnv
*
_env
,
const
char
*
_value
)
noexcept
/**
:
LocalRef
<
jstring
>
(
_env
,
_env
->
NewStringUTF
(
_value
))
{}
* Copy the value to the specified buffer. Truncates
* the value if it does not fit into the buffer.
/**
*
* Copy the value to the specified buffer. Truncates
* @return a pointer to the terminating null byte,
* the value if it does not fit into the buffer.
* nullptr on error
*
*/
* @return a pointer to the terminating null byte,
char
*
CopyTo
(
JNIEnv
*
env
,
* nullptr on error
char
*
buffer
,
size_t
max_size
)
noexcept
{
*/
return
CopyTo
(
env
,
Get
(),
buffer
,
max_size
);
static
char
*
CopyTo
(
JNIEnv
*
env
,
jstring
value
,
}
char
*
buffer
,
size_t
max_size
)
noexcept
;
/**
static
std
::
string
ToString
(
JNIEnv
*
env
,
jstring
s
)
noexcept
;
* Copy the value to the specified buffer. Truncates
* the value if it does not fit into the buffer.
*
* @return a pointer to the terminating null byte,
* nullptr on error
*/
char
*
CopyTo
(
JNIEnv
*
env
,
char
*
buffer
,
size_t
max_size
)
noexcept
{
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
());
}
};
std
::
string
ToString
()
const
noexcept
{
}
// namespace Java
return
ToString
(
GetEnv
(),
Get
());
}
};
}
#endif
#endif
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