WPILibC++ 2024.3.2
wpi::java::detail::JSpanBase< T, IsCritical, Size > Class Template Reference

Helper class for working with JNI arrays. More...

#include <wpi/jni_util.h>

Public Member Functions

 JSpanBase (const JSpanBase &)=delete
 
JSpanBaseoperator= (const JSpanBase &)=delete
 
 JSpanBase (JSpanBase &&other)
 
JSpanBaseoperator= (JSpanBase &&other)
 
 JSpanBase (JNIEnv *env, jobject bb, size_t size)
 
 JSpanBase (JNIEnv *env, jarray_type jarr, size_t size)
 
 JSpanBase (JNIEnv *env, jarray_type jarr)
 
 ~JSpanBase ()
 
 operator std::span< T, Size > () const
 
std::span< T, Size > array () const
 
T * begin () const
 
T * end () const
 
bool is_valid () const
 
 operator bool () const
 
T * data () const
 
size_t size () const
 
const T & operator[] (size_t i) const
 
T & operator[] (size_t i)
 
 operator std::string_view () const
 
std::string_view str () const
 
std::span< copy_cv_t< T, uint8_t >, Size > uarray () const
 

Public Attributes

template<typename U >
operator std::span< U, Size >() const std JNIEnv * m_env
 
jarray_type m_jarr = nullptr
 
size_t m_size
 
std::remove_cv_t< T > * m_elements
 

Detailed Description

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
class wpi::java::detail::JSpanBase< T, IsCritical, Size >

Helper class for working with JNI arrays.

This class exposes an is_valid() member and an explicit conversion to bool which indicate if the span is valid. Operations on invalid spans are undefined.

Note that Set<PrimitiveType>ArrayRegion may be faster for pure writes since it avoids copying the elements from Java to C++.

Template Parameters
TThe element type of the array (e.g., jdouble).
IsCriticalIf true, Get/ReleasePrimitiveArrayCritical will be used instead of Get/Release<PrimitiveType>ArrayElements.
SizeThe number of elements in the span.

Constructor & Destructor Documentation

◆ JSpanBase() [1/5]

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
wpi::java::detail::JSpanBase< T, IsCritical, Size >::JSpanBase ( const JSpanBase< T, IsCritical, Size > &  )
delete

◆ JSpanBase() [2/5]

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
wpi::java::detail::JSpanBase< T, IsCritical, Size >::JSpanBase ( JSpanBase< T, IsCritical, Size > &&  other)
inline

◆ JSpanBase() [3/5]

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
wpi::java::detail::JSpanBase< T, IsCritical, Size >::JSpanBase ( JNIEnv *  env,
jobject  bb,
size_t  size 
)
inline

◆ JSpanBase() [4/5]

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
wpi::java::detail::JSpanBase< T, IsCritical, Size >::JSpanBase ( JNIEnv *  env,
jarray_type  jarr,
size_t  size 
)
inline

◆ JSpanBase() [5/5]

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
wpi::java::detail::JSpanBase< T, IsCritical, Size >::JSpanBase ( JNIEnv *  env,
jarray_type  jarr 
)
inline

◆ ~JSpanBase()

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
wpi::java::detail::JSpanBase< T, IsCritical, Size >::~JSpanBase ( )
inline

Member Function Documentation

◆ array()

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
std::span< T, Size > wpi::java::detail::JSpanBase< T, IsCritical, Size >::array ( ) const
inline

◆ begin()

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
T * wpi::java::detail::JSpanBase< T, IsCritical, Size >::begin ( ) const
inline

◆ data()

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
T * wpi::java::detail::JSpanBase< T, IsCritical, Size >::data ( ) const
inline

◆ end()

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
T * wpi::java::detail::JSpanBase< T, IsCritical, Size >::end ( ) const
inline

◆ is_valid()

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
bool wpi::java::detail::JSpanBase< T, IsCritical, Size >::is_valid ( ) const
inline

◆ operator bool()

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
wpi::java::detail::JSpanBase< T, IsCritical, Size >::operator bool ( ) const
inlineexplicit

◆ operator std::span< T, Size >()

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
wpi::java::detail::JSpanBase< T, IsCritical, Size >::operator std::span< T, Size > ( ) const
inline

◆ operator std::string_view()

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
wpi::java::detail::JSpanBase< T, IsCritical, Size >::operator std::string_view ( ) const
inline

◆ operator=() [1/2]

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
JSpanBase & wpi::java::detail::JSpanBase< T, IsCritical, Size >::operator= ( const JSpanBase< T, IsCritical, Size > &  )
delete

◆ operator=() [2/2]

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
JSpanBase & wpi::java::detail::JSpanBase< T, IsCritical, Size >::operator= ( JSpanBase< T, IsCritical, Size > &&  other)
inline

◆ operator[]() [1/2]

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
T & wpi::java::detail::JSpanBase< T, IsCritical, Size >::operator[] ( size_t  i)
inline

◆ operator[]() [2/2]

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
const T & wpi::java::detail::JSpanBase< T, IsCritical, Size >::operator[] ( size_t  i) const
inline

◆ size()

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
size_t wpi::java::detail::JSpanBase< T, IsCritical, Size >::size ( ) const
inline

◆ str()

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
std::string_view wpi::java::detail::JSpanBase< T, IsCritical, Size >::str ( ) const
inline

◆ uarray()

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
std::span< copy_cv_t< T, uint8_t >, Size > wpi::java::detail::JSpanBase< T, IsCritical, Size >::uarray ( ) const
inline

Member Data Documentation

◆ m_elements

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
std::remove_cv_t<T>* wpi::java::detail::JSpanBase< T, IsCritical, Size >::m_elements

◆ m_env

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
template<typename U >
operator std::span<U, Size> () const std JNIEnv* wpi::java::detail::JSpanBase< T, IsCritical, Size >::m_env

◆ m_jarr

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
jarray_type wpi::java::detail::JSpanBase< T, IsCritical, Size >::m_jarr = nullptr

◆ m_size

template<JArrayType T, bool IsCritical, size_t Size = std::dynamic_extent>
size_t wpi::java::detail::JSpanBase< T, IsCritical, Size >::m_size

The documentation for this class was generated from the following file: