Version: 9.15.0
Any.cxx File Reference
#include "Any.hxx"
#include "Runtime.hxx"
#include "TypeCode.hxx"
#include "InvalidExtractionException.hxx"
#include <boost/archive/iterators/base64_from_binary.hpp>
#include <boost/archive/iterators/binary_from_base64.hpp>
#include <boost/archive/iterators/transform_width.hpp>
#include <boost/archive/iterators/insert_linebreaks.hpp>
#include <boost/archive/iterators/remove_whitespace.hpp>
#include <algorithm>
#include <cstring>
#include <cstdlib>
Include dependency graph for Any.cxx:

Go to the source code of this file.

Functions

unsigned char BitAtPosSimple (char val, std::size_t bitPos)
 
unsigned char BitAtPos (char pt0, char pt1, std::size_t bitPos)
 
unsigned char ChunkInternal (char pt0, char pt1, std::size_t startBitIdInByte)
 
unsigned char ChunkAtPos (const char *pt, std::size_t len, std::size_t posChunk)
 
std::size_t OnOff (std::size_t i)
 
unsigned char BitAtPosSimple2 (char val, std::size_t bitPos)
 
char BitAtPosOnChunk (char pt0, char pt1, std::size_t bitPos)
 
unsigned char CheckEntry (char c)
 
char ByteInternal (char c0, char c1, std::size_t startBitIdInByte)
 
char ByteAtPos (const char *chunckPt, std::size_t bytePos)
 

Variables

constexpr unsigned NB_BITS = 6
 
constexpr unsigned char TAB [64] ={46, 61, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122}
 
constexpr unsigned MAX_VAL_TAB2 =123
 
constexpr unsigned NOT_OK_VAL = 128
 
constexpr unsigned char TAB2 [MAX_VAL_TAB2] = { NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, 0, NOT_OK_VAL, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, 1, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, 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, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, 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 }
 

Function Documentation

◆ BitAtPos()

unsigned char BitAtPos ( char  pt0,
char  pt1,
std::size_t  bitPos 
)

Definition at line 50 of file Any.cxx.

51 {
52  if(bitPos<8)
53  return BitAtPosSimple(pt0,bitPos);
54  else
55  return BitAtPosSimple(pt1,bitPos-8);
56 }
unsigned char BitAtPosSimple(char val, std::size_t bitPos)
Definition: Any.cxx:45

References BitAtPosSimple().

Referenced by ChunkInternal().

◆ BitAtPosOnChunk()

char BitAtPosOnChunk ( char  pt0,
char  pt1,
std::size_t  bitPos 
)

Definition at line 111 of file Any.cxx.

112 {
113  if(bitPos<6)
114  return BitAtPosSimple2(pt0,bitPos);
115  else
116  return BitAtPosSimple2(pt1,bitPos-6);
117 }
unsigned char BitAtPosSimple2(char val, std::size_t bitPos)
Definition: Any.cxx:106

References BitAtPosSimple2().

Referenced by ByteInternal().

◆ BitAtPosSimple()

unsigned char BitAtPosSimple ( char  val,
std::size_t  bitPos 
)

Definition at line 45 of file Any.cxx.

46 {
47  return (val >> bitPos) & 0x1;
48 }

Referenced by BitAtPos().

◆ BitAtPosSimple2()

unsigned char BitAtPosSimple2 ( char  val,
std::size_t  bitPos 
)

Definition at line 106 of file Any.cxx.

107 {
108  return ( val >> (5-bitPos) ) & 0x1;
109 }

Referenced by BitAtPosOnChunk().

◆ ByteAtPos()

char ByteAtPos ( const char *  chunckPt,
std::size_t  bytePos 
)

Definition at line 144 of file Any.cxx.

145 {
146  std::size_t startChunk((bytePos*8)/NB_BITS);
147  std::size_t startBitId((bytePos*8)%NB_BITS);
148  return ByteInternal(chunckPt[startChunk],chunckPt[startChunk+1],startBitId);
149 }
char ByteInternal(char c0, char c1, std::size_t startBitIdInByte)
Definition: Any.cxx:131
constexpr unsigned NB_BITS
Definition: Any.cxx:41

References ByteInternal(), and NB_BITS.

Referenced by YACS::ENGINE::FromBase64().

◆ ByteInternal()

char ByteInternal ( char  c0,
char  c1,
std::size_t  startBitIdInByte 
)

Definition at line 131 of file Any.cxx.

132 {
133  unsigned char ret(0);
134  char ct0(CheckEntry(c0)),ct1(CheckEntry(c1));
135  for(int i = 7; i>=0; --i)
136  {
137  ret |= BitAtPosOnChunk(ct0,ct1,startBitIdInByte+i);
138  if(i!=0)
139  ret <<= 1;
140  }
141  return ret;
142 }
unsigned char CheckEntry(char c)
Definition: Any.cxx:119
char BitAtPosOnChunk(char pt0, char pt1, std::size_t bitPos)
Definition: Any.cxx:111

References BitAtPosOnChunk(), gui.GraphViewer::c1, CheckEntry(), and yacsorb.CORBAEngineTest::i.

Referenced by ByteAtPos().

◆ CheckEntry()

unsigned char CheckEntry ( char  c)

Definition at line 119 of file Any.cxx.

120 {
121  if( ((unsigned) c) < MAX_VAL_TAB2 )
122  {
123  unsigned char ret(TAB2[(unsigned char)c]);
124  if(ret != NOT_OK_VAL)
125  return ret;
126  throw YACS::Exception("Invalid character found !");
127  }
128  throw YACS::Exception("Invalid character found !");
129 }
constexpr unsigned char TAB2[MAX_VAL_TAB2]
Definition: Any.cxx:104
constexpr unsigned MAX_VAL_TAB2
Definition: Any.cxx:100
constexpr unsigned NOT_OK_VAL
Definition: Any.cxx:102

References gui.CONNECTOR::c, MAX_VAL_TAB2, NOT_OK_VAL, and TAB2.

Referenced by ByteInternal().

◆ ChunkAtPos()

unsigned char ChunkAtPos ( const char *  pt,
std::size_t  len,
std::size_t  posChunk 
)

Definition at line 70 of file Any.cxx.

71 {
72  std::size_t startByte((posChunk*NB_BITS)/8);
73  std::size_t startBitIdInByte((posChunk*NB_BITS)%8);
74  char pt1(startByte!=len-1?pt[startByte+1]:pt[startByte]);
75  return ChunkInternal(pt[startByte],pt1,startBitIdInByte);
76 }
unsigned char ChunkInternal(char pt0, char pt1, std::size_t startBitIdInByte)
Definition: Any.cxx:58

References ChunkInternal(), and NB_BITS.

Referenced by YACS::ENGINE::ToBase64().

◆ ChunkInternal()

unsigned char ChunkInternal ( char  pt0,
char  pt1,
std::size_t  startBitIdInByte 
)

Definition at line 58 of file Any.cxx.

59 {
60  unsigned char ret(0);
61  for(unsigned i = 0; i<NB_BITS; ++i)
62  {
63  ret |= BitAtPos(pt0,pt1,startBitIdInByte+i);
64  ret <<= 1;
65  }
66  ret >>= 1;
67  return ret;
68 }
unsigned char BitAtPos(char pt0, char pt1, std::size_t bitPos)
Definition: Any.cxx:50

References BitAtPos(), yacsorb.CORBAEngineTest::i, and NB_BITS.

Referenced by ChunkAtPos().

◆ OnOff()

std::size_t OnOff ( std::size_t  i)

Definition at line 78 of file Any.cxx.

79 {
80  if(i!=0)
81  return 1;
82  return 0;
83 }

References yacsorb.CORBAEngineTest::i.

Referenced by YACS::ENGINE::ToBase64().

Variable Documentation

◆ MAX_VAL_TAB2

constexpr unsigned MAX_VAL_TAB2 =123
constexpr

Definition at line 100 of file Any.cxx.

Referenced by CheckEntry().

◆ NB_BITS

constexpr unsigned NB_BITS = 6
constexpr

◆ NOT_OK_VAL

constexpr unsigned NOT_OK_VAL = 128
constexpr

Definition at line 102 of file Any.cxx.

Referenced by CheckEntry().

◆ TAB

constexpr unsigned char TAB[64] ={46, 61, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122}
constexpr

Definition at line 43 of file Any.cxx.

Referenced by YACS::ENGINE::ToBase64().

◆ TAB2

constexpr unsigned char TAB2[MAX_VAL_TAB2] = { NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, 0, NOT_OK_VAL, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, 1, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, 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, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, 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 }
constexpr

Definition at line 104 of file Any.cxx.

Referenced by CheckEntry().