-
Notifications
You must be signed in to change notification settings - Fork 13
/
JniJavaString.h
63 lines (45 loc) · 1.32 KB
/
JniJavaString.h
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
#pragma once
#ifndef JNI_JAVA_STRING_H
#define JNI_JAVA_STRING_H
#include <JniForwards.h>
#include <JniJavaObjectClassDef.h>
namespace JNI {
class JavaString : public JavaObject {
public:
JavaString();
JavaString(JavaEnv env, const char * val);
JavaString(JavaEnv env, const std::string& val);
JavaString(JavaEnv env, jstring str);
JavaString(const JavaString& str);
JavaString(JavaString&& str);
static JavaString New(JavaEnv env, const char * str);
static JavaString New(JavaEnv env, const std::string& str);
virtual ~JavaString();
JavaString& operator=(const JavaString& str);
JavaString& operator=(JavaString&& str);
using JavaObject::operator==;
using JavaObject::operator!=;
bool operator==(const JavaString& str) const;
bool operator!=(const JavaString& obj) const;
bool operator==(const std::string& str) const;
bool operator!=(const std::string& str) const;
friend bool operator==(const std::string& str, const JavaString& self) {
return self == str;
}
friend bool operator!=(const std::string& str, const JavaString& self) {
return self != str;
}
char operator[](size_t n) const;
jstring Val() const;
const char * Value() const;
jsize Length() const;
jsize Size() const;
private:
const char * val;
void Init();
void Destroy();
protected:
void Reset(const JavaString& str);
};
}
#endif