Crypto++  5.6.5
Free C++ class library of cryptographic schemes
fltrimpl.h
1 #ifndef CRYPTOPP_FLTRIMPL_H
2 #define CRYPTOPP_FLTRIMPL_H
3 
4 #if CRYPTOPP_MSC_VERSION
5 # pragma warning(push)
6 # pragma warning(disable: 4100)
7 #endif
8 
9 #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
10 # pragma GCC diagnostic push
11 # pragma GCC diagnostic ignored "-Wunused-value"
12 #endif
13 
14 #define FILTER_BEGIN \
15  switch (m_continueAt) \
16  { \
17  case 0: \
18  m_inputPosition = 0;
19 
20 #define FILTER_END_NO_MESSAGE_END_NO_RETURN \
21  break; \
22  default: \
23  CRYPTOPP_ASSERT(false); \
24  }
25 
26 #define FILTER_END_NO_MESSAGE_END \
27  FILTER_END_NO_MESSAGE_END_NO_RETURN \
28  return 0;
29 
30 /*
31 #define FILTER_END \
32  case -1: \
33  if (messageEnd && Output(-1, NULL, 0, messageEnd, blocking)) \
34  return 1; \
35  FILTER_END_NO_MESSAGE_END
36 */
37 
38 #define FILTER_OUTPUT3(site, statement, output, length, messageEnd, channel) \
39  {\
40  case site: \
41  statement; \
42  if (Output(site, output, length, messageEnd, blocking, channel)) \
43  return STDMAX(size_t(1), length-m_inputPosition);\
44  }
45 
46 #define FILTER_OUTPUT2(site, statement, output, length, messageEnd) \
47  FILTER_OUTPUT3(site, statement, output, length, messageEnd, DEFAULT_CHANNEL)
48 
49 #define FILTER_OUTPUT(site, output, length, messageEnd) \
50  FILTER_OUTPUT2(site, 0, output, length, messageEnd)
51 
52 #define FILTER_OUTPUT_BYTE(site, output) \
53  FILTER_OUTPUT(site, &(const byte &)(byte)output, 1, 0)
54 
55 #define FILTER_OUTPUT2_MODIFIABLE(site, statement, output, length, messageEnd) \
56  {\
57  case site: \
58  statement; \
59  if (OutputModifiable(site, output, length, messageEnd, blocking)) \
60  return STDMAX(size_t(1), length-m_inputPosition);\
61  }
62 
63 #define FILTER_OUTPUT_MODIFIABLE(site, output, length, messageEnd) \
64  FILTER_OUTPUT2_MODIFIABLE(site, 0, output, length, messageEnd)
65 
66 #define FILTER_OUTPUT2_MAYBE_MODIFIABLE(site, statement, output, length, messageEnd, modifiable) \
67  {\
68  case site: \
69  statement; \
70  if (modifiable ? OutputModifiable(site, output, length, messageEnd, blocking) : Output(site, output, length, messageEnd, blocking)) \
71  return STDMAX(size_t(1), length-m_inputPosition);\
72  }
73 
74 #define FILTER_OUTPUT_MAYBE_MODIFIABLE(site, output, length, messageEnd, modifiable) \
75  FILTER_OUTPUT2_MAYBE_MODIFIABLE(site, 0, output, length, messageEnd, modifiable)
76 
77 #if CRYPTOPP_MSC_VERSION
78 # pragma warning(pop)
79 #endif
80 
81 #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
82 # pragma GCC diagnostic pop
83 #endif
84 
85 #endif