OpenDDS  Snapshot(2023/04/05-13:10)
Classes | Functions
OpenDDS::FileSystemStorage Namespace Reference

Classes

class  Directory
 
class  File
 

Functions

ACE_TString b32h_encode (const ACE_TCHAR *decoded)
 
ACE_TString b32h_decode (const ACE_TCHAR *encoded)
 

Function Documentation

◆ b32h_decode()

OpenDDS_Dcps_Export ACE_TString OpenDDS::FileSystemStorage::b32h_decode ( const ACE_TCHAR encoded)

Definition at line 902 of file FileSystemStorage.cpp.

References ACE_TEXT(), and OPENDDS_END_VERSIONED_NAMESPACE_DECL.

Referenced by OpenDDS::FileSystemStorage::Directory::scan_dir().

903 {
904  // #before first '=' -> #output
905  static const size_t dec[] = {0, 0, 1, 0, 2, 3, 0, 4, 0};
906  ACE_TString decoded;
907 
908  for (; *encoded; encoded += 8) {
909  ACE_UINT64 chunk = 0;
910  size_t i = 0;
911 
912  for (; i < 8 && encoded[i] != ACE_TEXT('='); ++i) {
913  char idx = (encoded[i] <= ACE_TEXT('9'))
914  ? (encoded[i] - ACE_TEXT('0'))
915  : (10 + encoded[i] - ACE_TEXT('A'));
916  chunk |= static_cast<ACE_UINT64>(idx) << ((7 - i) * 5);
917  }
918 
919  size_t limit = (encoded[i] == ACE_TEXT('=')) ? dec[i] : 5;
920 
921  for (size_t j(0); j < limit; ++j) {
922  decoded += static_cast<ACE_TCHAR>(chunk >>((4 - j) * 8)) & 0xFF;
923  }
924  }
925 
926  return decoded;
927 }
char ACE_TCHAR
ACE_TEXT("TCP_Factory")
unsigned long long ACE_UINT64

◆ b32h_encode()

OpenDDS_Dcps_Export ACE_TString OpenDDS::FileSystemStorage::b32h_encode ( const ACE_TCHAR decoded)

Definition at line 870 of file FileSystemStorage.cpp.

References ACE_TEXT(), ACE_String_Base< char >::append(), and ACE_OS::strlen().

Referenced by OpenDDS::FileSystemStorage::Directory::make_new_file(), and OpenDDS::FileSystemStorage::Directory::make_new_subdir().

871 {
872  static const ACE_TCHAR lookup[] =
873  ACE_TEXT("0123456789ABCDEFGHIJKLMNOPQRSTUV");
874  static const ACE_TCHAR padding[] = ACE_TEXT("======");
875  static const size_t enc[] = {0, 2, 4, 5, 7}; // #input -> #non-padded output
876  ACE_TString encoded;
877 
878  for (size_t len = ACE_OS::strlen(decoded); *decoded; decoded += 5, len -= 5) {
879  ACE_UINT64 chunk = 0;
880 
881  for (size_t i(0); i < 5 && i < len; ++i) {
882  chunk |= static_cast<ACE_UINT64>(decoded[i] & 0xFF) << ((4 - i) * 8);
883  }
884 
885  size_t limit = (len < 5) ? enc[len] : 8;
886 
887  for (size_t i(0); i < limit; ++i) {
888  unsigned char val =
889  static_cast<unsigned char>(chunk >>((7 - i) * 5)) & 0x1F;
890  encoded += lookup[val];
891  }
892 
893  if (len < 5) {
894  encoded.append(padding, 8 - enc[len]);
895  return encoded;
896  }
897  }
898 
899  return encoded;
900 }
size_t strlen(const char *s)
char ACE_TCHAR
ACE_String_Base< char > & append(const char *s, size_type slen)
ACE_TEXT("TCP_Factory")
unsigned long long ACE_UINT64