OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TextEncodingNone Struct Reference

#include <heavydbTypes.h>

Public Member Functions

 TextEncodingNone ()=default
 
 TextEncodingNone (char const *const c_str)
 
template<typename M >
DEVICE ALWAYS_INLINE TextEncodingNone (M &mgr, const std::string &str)
 
 operator std::string () const
 
std::string getString () const
 
DEVICE ALWAYS_INLINE char & operator[] (const unsigned int index)
 
DEVICE ALWAYS_INLINE bool operator== (const char *rhs) const
 
DEVICE ALWAYS_INLINE bool operator== (const TextEncodingNone &rhs) const
 
DEVICE ALWAYS_INLINE bool operator!= (const char *rhs) const
 
DEVICE ALWAYS_INLINE bool operator!= (const TextEncodingNone &rhs) const
 
DEVICE ALWAYS_INLINE operator char * () const
 
DEVICE ALWAYS_INLINE char * data () const
 
DEVICE ALWAYS_INLINE int64_t size () const
 
DEVICE ALWAYS_INLINE bool isNull () const
 

Public Attributes

char * ptr_
 
int64_t size_
 
int8_t padding
 

Detailed Description

Definition at line 607 of file heavydbTypes.h.

Constructor & Destructor Documentation

TextEncodingNone::TextEncodingNone ( )
default
TextEncodingNone::TextEncodingNone ( char const *const  c_str)
inlineexplicit

Definition at line 617 of file heavydbTypes.h.

618  : ptr_(const_cast<char*>(c_str)), size_(strlen(c_str)) {}
template<typename M >
DEVICE ALWAYS_INLINE TextEncodingNone::TextEncodingNone ( M &  mgr,
const std::string &  str 
)
inlineexplicit

Definition at line 621 of file heavydbTypes.h.

References ptr_, and size_.

621  {
622  static_assert(
623 #ifndef UDF_COMPILED
624  (std::is_same<TableFunctionManager, M>::value) ||
625 #endif // #ifndef UDF_COMPILED
626  (std::is_same<RowFunctionManager, M>::value),
627  "M must be a TableFunctionManager or RowFunctionManager");
628  size_ = str.length();
629  if (str.empty()) {
630  ptr_ = nullptr;
631  } else {
632  int8_t* buffer = mgr.makeBuffer(size_, static_cast<int64_t>(sizeof(char)));
633  ptr_ = reinterpret_cast<char*>(buffer);
634  strcpy(ptr_, str.c_str());
635  }
636  }

Member Function Documentation

DEVICE ALWAYS_INLINE char* TextEncodingNone::data ( ) const
inline

Definition at line 685 of file heavydbTypes.h.

References ptr_.

Referenced by operator==().

685  {
686  return ptr_;
687  }

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE bool TextEncodingNone::isNull ( ) const
inline

Definition at line 691 of file heavydbTypes.h.

References size_.

Referenced by operator==(), strtok_to_array(), and strtok_to_array__1().

691  {
692  return size_ == 0;
693  }

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE TextEncodingNone::operator char * ( ) const
inline

Definition at line 682 of file heavydbTypes.h.

References ptr_.

682  {
683  return ptr_;
684  }
TextEncodingNone::operator std::string ( ) const
inline

Definition at line 638 of file heavydbTypes.h.

References ptr_, and size_.

638  {
639  return std::string(ptr_, size_);
640  }
DEVICE ALWAYS_INLINE bool TextEncodingNone::operator!= ( const char *  rhs) const
inline

Definition at line 676 of file heavydbTypes.h.

References operator==().

676  {
677  return !(this->operator==(rhs));
678  }
DEVICE ALWAYS_INLINE bool operator==(const char *rhs) const
Definition: heavydbTypes.h:649

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE bool TextEncodingNone::operator!= ( const TextEncodingNone rhs) const
inline

Definition at line 679 of file heavydbTypes.h.

References operator==().

679  {
680  return !(this->operator==(rhs));
681  }
DEVICE ALWAYS_INLINE bool operator==(const char *rhs) const
Definition: heavydbTypes.h:649

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE bool TextEncodingNone::operator== ( const char *  rhs) const
inline

Definition at line 649 of file heavydbTypes.h.

References ptr_, and size_.

Referenced by operator!=().

649  {
650 #ifdef __CUDACC__
651  for (int i = 0; i < size_; i++) {
652  if (rhs[i] == '\0' || ptr_[i] != rhs[i]) {
653  return false;
654  }
655  }
656  return rhs[size_] == '\0';
657 #else
658  return strcmp(ptr_, rhs) == 0;
659 #endif
660  }

+ Here is the caller graph for this function:

DEVICE ALWAYS_INLINE bool TextEncodingNone::operator== ( const TextEncodingNone rhs) const
inline

Definition at line 661 of file heavydbTypes.h.

References data(), isNull(), ptr_, size(), and size_.

661  {
662  if (isNull() || rhs.isNull() || size_ != rhs.size()) {
663  return false;
664  }
665 #ifdef __CUDACC__
666  for (int i = 0; i < size_; i++) {
667  if ((*this)[i] != rhs[i]) {
668  return false;
669  }
670  }
671  return true;
672 #else
673  return strncmp(ptr_, rhs.data(), size_) == 0;
674 #endif
675  }
DEVICE ALWAYS_INLINE char * data() const
Definition: heavydbTypes.h:685
DEVICE ALWAYS_INLINE int64_t size() const
Definition: heavydbTypes.h:688
DEVICE ALWAYS_INLINE bool isNull() const
Definition: heavydbTypes.h:691

+ Here is the call graph for this function:

DEVICE ALWAYS_INLINE char& TextEncodingNone::operator[] ( const unsigned int  index)
inline

Definition at line 646 of file heavydbTypes.h.

References ptr_, and size_.

646  {
647  return index < size_ ? ptr_[index] : ptr_[size_ - 1];
648  }
DEVICE ALWAYS_INLINE int64_t TextEncodingNone::size ( ) const
inline

Definition at line 688 of file heavydbTypes.h.

References size_.

Referenced by ct_get_string_chars__template(), ct_hamming_distance(), operator==(), and text_encoding_none_length().

688  {
689  return size_;
690  }

+ Here is the caller graph for this function:

Member Data Documentation

int8_t TextEncodingNone::padding

Definition at line 612 of file heavydbTypes.h.

char* TextEncodingNone::ptr_
int64_t TextEncodingNone::size_

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