@Name(value="tvm::runtime::String") @NoOffset @Properties(inherit=tvm_runtime.class) public class TVMString extends ObjectRef
// Example to create runtime String reference object from std::string
std::string s = "hello world";
// You can create the reference from existing std::string
String ref{std::move(s)};
// You can rebind the reference to another string.
ref = std::string{"hello world2"};
// You can use the reference as hash map key
std::unordered_map<String, int32_t> m;
m[ref] = 1;
// You can compare the reference object with other string objects
assert(ref == "hello world", true);
// You can convert the reference to std::string again
string s2 = (string)ref;
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter| Modifier and Type | Field and Description |
|---|---|
static boolean |
_type_is_nullable |
| Constructor and Description |
|---|
TVMString()
\brief Construct an empty string.
|
TVMString(BytePointer other)
\brief Construct a new String object
|
TVMString(long size)
Native array allocator.
|
TVMString(ObjectPtr n) |
TVMString(Pointer p)
Pointer cast constructor.
|
TVMString(String other) |
TVMString(TVMString other) |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
_type_is_nullable() |
StringObj |
access() |
BytePointer |
asBytePointer()
\brief Convert String to an std::string object
|
byte |
at(long pos)
\brief Read an element.
|
BytePointer |
c_str()
\brief Returns a pointer to the char array in the string.
|
static boolean |
CanConvertFrom(TVMArgValue val)
\brief Check if a TVMArgValue can be converted to String, i.e.
|
int |
compare(BytePointer other)
\brief Compares this String object to other
|
int |
compare(String other) |
int |
compare(TVMString other)
\brief Compares this String object to other
|
BytePointer |
data()
\brief Return the data pointer
|
boolean |
empty()
\brief Retun if the string is empty
|
StringObj |
get() |
TVMString |
getPointer(long i) |
static long |
HashBytes(BytePointer data,
long size)
\brief Hash the binary bytes
|
static long |
HashBytes(String data,
long size) |
long |
length()
\brief Return the length of the string
|
TVMString |
position(long position) |
TVMString |
put(BytePointer other)
\brief Change the value the reference object points to.
|
TVMString |
put(String other) |
TVMString |
put(TVMString other) |
long |
size()
\brief Return the length of the string
|
defined, equals, lessThan, notEquals, same_as, unique, use_countaddress, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, getDirectBufferAddress, getPointer, getPointer, getPointer, hashCode, interruptDeallocatorThread, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetAddress, offsetof, offsetof, parseBytes, physicalBytes, physicalBytesInaccurate, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, sizeof, toString, totalBytes, totalCount, totalPhysicalBytes, withDeallocator, zeropublic TVMString(Pointer p)
Pointer(Pointer).public TVMString(long size)
Pointer.position(long).public TVMString()
public TVMString(@StdString BytePointer other)
other - The moved/copied std::string object
\note If user passes const reference, it will trigger copy. If it's rvalue,
it will be moved into other.public TVMString(@StdString String other)
public TVMString getPointer(long i)
getPointer in class ObjectRef@ByRef @Name(value="operator =") public TVMString put(@StdString BytePointer other)
other - The value for the new Stringpublic int compare(@Const @ByRef TVMString other)
other - The String to compare with.public int compare(@StdString BytePointer other)
other - The string to compare with.public int compare(@StdString String other)
@Cast(value="const char*") public BytePointer c_str()
@Cast(value="size_t") public long size()
@Cast(value="size_t") public long length()
@Cast(value="bool") public boolean empty()
@Cast(value="char") public byte at(@Cast(value="size_t") long pos)
pos - The position at which to read the character.@Cast(value="const char*") public BytePointer data()
@Name(value="operator std::string") @StdString public BytePointer asBytePointer()
@Cast(value="bool") public static boolean CanConvertFrom(@Const @ByRef TVMArgValue val)
val - The value to be checked@Cast(value="size_t") public static long HashBytes(@Cast(value="const char*") BytePointer data, @Cast(value="size_t") long size)
data - The data pointersize - The size of the bytes.@Cast(value="size_t") public static long HashBytes(String data, @Cast(value="size_t") long size)
@MemberGetter @Cast(value="const bool") public static boolean _type_is_nullable()
Copyright © 2022. All rights reserved.