autodoc.xml 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <?xml version="1.0" standalone="yes"?>
  2. <library-reference><header name="boost/crc.hpp">
  3. <para>A collection of function templates and class templates that compute various forms of Cyclic Redundancy Codes (CRCs). </para><para><para>Daryle Walker</para>
  4. <para>1.5</para>
  5. <para>Boost Software License, version 1.0</para>
  6. Contains the declarations (and definitions) of various kinds of CRC computation functions, function object types, and encapsulated policy types.</para><para><warning><para>The sample CRC-computer types were just checked against the <ulink url="http://regregex.bbcmicro.net/crc-catalogue.htm">Catalogue of parametrised CRC algorithms</ulink>. New type aliases were added where I got a standard wrong. However, the mistaken <computeroutput>typedef</computeroutput>s are still there for backwards compatibility. </para>
  7. </warning>
  8. <note><para>There are references to the <emphasis>Rocksoft<trademark/> Model CRC Algorithm</emphasis>, as described within "A Painless Guide to CRC Error Detection Algorithms," linked from "<ulink url="http://www.ross.net/crc/crcpaper.html">CRC: A Paper On CRCs</ulink>" by Ross Williams. It will be abbreviated "RMCA" in other documentation blocks. </para>
  9. </note>
  10. </para><namespace name="boost">
  11. <class name="crc_basic"><template>
  12. <template-nontype-parameter name="Bits"><type>std::size_t</type><purpose><para>The order of the modulo-2 polynomial divisor. (<emphasis>Width</emphasis> from the RMCA) </para></purpose></template-nontype-parameter>
  13. </template><purpose>Bit-wise CRC computer. </purpose><description><para>Objects of this type compute the CRC checksum of submitted data, where said data can be entered piecemeal through several different kinds of groupings. Modulo-2 polynomial division steps are always performed bit-wise, without the use of pre-computation tables. Said division uses the altered algorithm, so any data has to be unaugmented.</para><para>
  14. </para></description><typedef name="value_type"><purpose>The register type used for computations. </purpose><description><para>This type is used for CRC calculations and is the type for any returned checksums and returned or submitted remainders, (truncated) divisors, or XOR masks. It is a built-in unsigned integer type. </para></description><type>boost::uint_t&lt; Bits &gt;::fast</type></typedef>
  15. <method-group name="public member functions">
  16. <method name="BOOST_STATIC_CONSTANT"><type/><parameter name=""><paramtype>std::size_t</paramtype></parameter><parameter name=""><paramtype>bit_count</paramtype><default>Bits</default></parameter><purpose>A copy of <emphasis>Bits</emphasis> provided for meta-programming purposes. </purpose></method>
  17. <method name="get_truncated_polynominal" cv="const"><type>value_type</type><purpose>Return the (truncated) polynomial divisor. </purpose><description><para>Returns a representation of the polynomial divisor. The value of the 2<superscript>i</superscript> bit is the value of the coefficient of the polynomial's x<superscript>i</superscript> term. The omitted bit for x<superscript>(#bit_count)</superscript> term is always 1.</para><para>
  18. </para></description><returns><para>The bit-packed list of coefficients. If the bit-length of value_type exceeds #bit_count, the values of higher-placed bits should be ignored (even any for x<superscript>(#bit_count)</superscript>) since they're unregulated. </para>
  19. </returns></method>
  20. <method name="get_initial_remainder" cv="const"><type>value_type</type><purpose>Return what the polynomial remainder was set to during construction. </purpose><description><para>Returns a representation of the polynomial remainder before any input has been submitted. The value of the 2<superscript>i</superscript> bit is the value of the coefficient of the polynomial's x<superscript>i</superscript> term.</para><para>
  21. </para></description><returns><para>The bit-packed list of coefficients. If the bit-length of value_type exceeds #bit_count, the values of higher-placed bits should be ignored since they're unregulated. </para>
  22. </returns></method>
  23. <method name="get_final_xor_value" cv="const"><type>value_type</type><purpose>Return the XOR-mask used during output processing. </purpose><description><para>Returns the mask to be used during creation of a checksum. The mask is used for an exclusive-or (XOR) operation applied bit-wise to the interim remainder representation (after any reflection, if get_reflect_remainder() returns <computeroutput>true</computeroutput>).</para><para>
  24. </para></description><returns><para>The bit-mask. If the bit-length of value_type exceeds #bit_count, the values of higher-placed bits should be ignored since they're unregulated. </para>
  25. </returns></method>
  26. <method name="get_reflect_input" cv="const"><type>bool</type><purpose>Check if input-bytes will be reflected before processing. </purpose><description><para>Returns a whether or not a submitted byte will be "reflected" before it is used to update the interim remainder. Only the byte-wise operations process_byte, process_block, and process_bytes are affected.</para><para>
  27. </para></description></method>
  28. <method name="get_reflect_remainder" cv="const"><type>bool</type><purpose>Check if the remainder will be reflected during output processing. </purpose><description><para>Indicates if the interim remainder will be "reflected" before it is passed to the XOR-mask stage when returning a checksum.</para><para>
  29. </para></description></method>
  30. <method name="get_interim_remainder" cv="const"><type>value_type</type><purpose>Return the remainder based from already-processed bits. </purpose><description><para>Returns a representation of the polynomial remainder after all the input submissions since construction or the last reset call. The value of the 2<superscript>i</superscript> bit is the value of the coefficient of the polynomial's x<superscript>i</superscript> term. If CRC processing gets interrupted here, retain the value returned, and use it to start up the next CRC computer where you left off (with reset(value_type) or construction). The next computer has to have its other parameters compatible with this computer.</para><para>
  31. </para></description><returns><para>The bit-packed list of coefficients. If the bit-length of value_type exceeds #bit_count, the values of higher-placed bits should be ignored since they're unregulated. No output processing (reflection or XOR mask) has been applied to the value. </para>
  32. </returns></method>
  33. <method name="reset"><type>void</type><parameter name="new_rem"><paramtype>value_type</paramtype><description><para>The (unaugmented) state of the polynomial remainder starting from this point, with no output processing applied.</para></description></parameter><purpose>Change the interim remainder to a new value. </purpose><description><para>Changes the interim polynomial remainder to <emphasis>new_rem</emphasis>, purging any influence previously submitted input has had. The value of the 2<superscript>i</superscript> bit is the value of the coefficient of the polynomial's x<superscript>i</superscript> term.</para><para>
  34. </para></description><postconditions><para><computeroutput><emphasis>new_rem</emphasis> == this-&gt;get_interim_remainder()</computeroutput> </para>
  35. </postconditions><postconditions><para><computeroutput>((this-&gt;get_reflect_remainder() ? REFLECT(<emphasis>new_rem</emphasis>) : <emphasis>new_rem</emphasis>) ^ this-&gt;get_final_xor_value()) == this-&gt;checksum()</computeroutput> </para>
  36. </postconditions></method>
  37. <method name="reset"><type>void</type><purpose>Change the interim remainder back to the initial value. </purpose><description><para>Changes the interim polynomial remainder to the initial remainder given during construction, purging any influence previously submitted input has had. The value of the 2<superscript>i</superscript> bit is the value of the coefficient of the polynomial's x<superscript>i</superscript> term.</para><para>
  38. </para></description><postconditions><para><computeroutput>this-&gt;get_initial_remainder() == this-&gt;get_interim_remainder()</computeroutput> </para>
  39. </postconditions><postconditions><para><computeroutput>((this-&gt;get_reflect_remainder() ? REFLECT(this-&gt;get_initial_remainder()) : this-&gt;get_initial_remainder()) ^ this-&gt;get_final_xor_value()) == this-&gt;checksum()</computeroutput> </para>
  40. </postconditions></method>
  41. <method name="process_bit"><type>void</type><parameter name="bit"><paramtype>bool</paramtype><description><para>The new input bit.</para></description></parameter><purpose>Submit a single bit for input processing. </purpose><description><para>Updates the interim remainder with a single altered-CRC-division step.</para><para>
  42. </para></description><postconditions><para>The interim remainder is updated though a modulo-2 polynomial division, where the division steps are altered for unaugmented CRCs. </para>
  43. </postconditions></method>
  44. <method name="process_bits"><type>void</type><parameter name="bits"><paramtype>unsigned char</paramtype><description><para>The byte containing the new input bits. </para></description></parameter><parameter name="bit_length"><paramtype>std::size_t</paramtype><description><para>The number of bits in the byte to be read.</para></description></parameter><purpose>Submit the lowest <emphasis>bit_length</emphasis> bits of a byte for input processing. </purpose><description><para>Updates the interim remainder with several altered-CRC-division steps. Each bit is processed separately, starting from the one at the 2<superscript><emphasis>bit_length</emphasis> - 1</superscript> place, then proceeding down to the lowest-placed bit. Any order imposed by <computeroutput>this-&gt;get_reflect_input()</computeroutput> is ignored.</para><para>
  45. </para></description><requires><para>0 &lt; <emphasis>bit_length</emphasis> &lt;= <computeroutput>CHAR_BIT</computeroutput> </para>
  46. </requires><postconditions><para>The interim remainder is updated though <emphasis>bit_length</emphasis> modulo-2 polynomial divisions, where the division steps are altered for unaugmented CRCs. </para>
  47. </postconditions></method>
  48. <method name="process_byte"><type>void</type><parameter name="byte"><paramtype>unsigned char</paramtype><description><para>The new input byte.</para></description></parameter><purpose>Submit a single byte for input processing. </purpose><description><para>Updates the interim remainder with a byte's worth of altered-CRC-division steps. The bits within the byte are processed from the highest place down if <computeroutput>this-&gt;get_reflect_input()</computeroutput> is <computeroutput>false</computeroutput>, and lowest place up otherwise.</para><para>
  49. </para></description><postconditions><para>The interim remainder is updated though <computeroutput>CHAR_BIT</computeroutput> modulo-2 polynomial divisions, where the division steps are altered for unaugmented CRCs. </para>
  50. </postconditions></method>
  51. <method name="process_block"><type>void</type><parameter name="bytes_begin"><paramtype>void const *</paramtype><description><para>The address where the memory block begins. </para></description></parameter><parameter name="bytes_end"><paramtype>void const *</paramtype><description><para>Points to one-byte past the address of the memory block's last byte, or <emphasis>bytes_begin</emphasis> if no bytes are to be read.</para></description></parameter><purpose>Submit a memory block for input processing, iterator-pair style. </purpose><description><para>Updates the interim remainder with several bytes' worth of altered-CRC-division steps. The bits within each byte are processed from the highest place down if <computeroutput>this-&gt;get_reflect_input()</computeroutput> is <computeroutput>false</computeroutput>, and lowest place up otherwise. The bytes themselves are processed starting from the one pointed by <emphasis>bytes_begin</emphasis> until <emphasis>bytes_end</emphasis> is reached through forward iteration, treating the two pointers as if they point to <computeroutput>unsigned char</computeroutput> objects.</para><para>
  52. </para></description><requires><para><emphasis>bytes_end</emphasis> has to equal <emphasis>bytes_begin</emphasis> if the latter is <computeroutput>NULL</computeroutput> or otherwise doesn't point to a valid buffer. </para>
  53. </requires><requires><para><emphasis>bytes_end</emphasis>, if not equal to <emphasis>bytes_begin</emphasis>, has to point within or one-byte-past the same buffer <emphasis>bytes_begin</emphasis> points into. </para>
  54. </requires><requires><para><emphasis>bytes_end</emphasis> has to be reachable from <emphasis>bytes_begin</emphasis> through a finite number of forward byte-pointer increments.</para>
  55. </requires><postconditions><para>The interim remainder is updated though <computeroutput>CHAR_BIT * (((unsigned char const *) bytes_end) - ((unsigned char const *) bytes_begin))</computeroutput> modulo-2 polynomial divisions, where the division steps are altered for unaugmented CRCs. </para>
  56. </postconditions></method>
  57. <method name="process_bytes"><type>void</type><parameter name="buffer"><paramtype>void const *</paramtype><description><para>The address where the memory block begins. </para></description></parameter><parameter name="byte_count"><paramtype>std::size_t</paramtype><description><para>The number of bytes in the memory block.</para></description></parameter><purpose>Submit a memory block for input processing, pointer-and-size style. </purpose><description><para>Updates the interim remainder with several bytes' worth of altered-CRC-division steps. The bits within each byte are processed from the highest place down if <computeroutput>this-&gt;get_reflect_input()</computeroutput> is <computeroutput>false</computeroutput>, and lowest place up otherwise. The bytes themselves are processed starting from the one pointed by <emphasis>buffer</emphasis>, forward-iterated (as if the pointed-to objects were of <computeroutput>unsigned char</computeroutput>) until <emphasis>byte_count</emphasis> bytes are read.</para><para>
  58. </para></description><requires><para><emphasis>byte_count</emphasis> has to equal 0 if <emphasis>buffer</emphasis> is <computeroutput>NULL</computeroutput> or otherwise doesn't point to valid memory. </para>
  59. </requires><requires><para>If <emphasis>buffer</emphasis> points within valid memory, then that block has to have at least <emphasis>byte_count</emphasis> more valid bytes allocated from that point.</para>
  60. </requires><postconditions><para>The interim remainder is updated though <computeroutput>CHAR_BIT * <emphasis>byte_count</emphasis></computeroutput> modulo-2 polynomial divisions, where the division steps are altered for unaugmented CRCs. </para>
  61. </postconditions></method>
  62. <method name="checksum" cv="const"><type>value_type</type><purpose>Return the checksum of the already-processed bits. </purpose><description><para>Computes the checksum of all the submitted bits since construction or the last call to reset. The checksum will be the raw checksum, i.e. the (interim) remainder after all the modulo-2 polynomial division, plus any output processing.</para><para>
  63. <note><para>Since checksums are meant to be compared, any higher-placed bits (when the bit-length of value_type exceeds #bit_count) will be set to 0. </para>
  64. </note>
  65. </para></description><returns><para><computeroutput>(this-&gt;get_reflect_remainder() ? REFLECT(this-&gt;get_interim_remainder()) : this-&gt;get_interim_remainder()) ^ this-&gt;get_final_xor_value()</computeroutput></para>
  66. </returns></method>
  67. </method-group>
  68. <constructor specifiers="explicit"><parameter name="truncated_polynomial"><paramtype>value_type</paramtype><description><para>The lowest coefficients of the divisor polynomial. The highest-order coefficient is omitted and always assumed to be 1. (<emphasis>Poly</emphasis> from the RMCA) </para></description></parameter><parameter name="initial_remainder"><paramtype>value_type</paramtype><default>0</default><description><para>The (unaugmented) initial state of the polynomial remainder. Defaults to <computeroutput>0</computeroutput> if omitted. (<emphasis>Init</emphasis> from the RMCA) </para></description></parameter><parameter name="final_xor_value"><paramtype>value_type</paramtype><default>0</default><description><para>The (XOR) bit-mask to be applied to the output remainder, after possible reflection but before returning. Defaults to <computeroutput>0</computeroutput> (i.e. no bit changes) if omitted. (<emphasis>XorOut</emphasis> from the RMCA) </para></description></parameter><parameter name="reflect_input"><paramtype>bool</paramtype><default>false</default><description><para>If <computeroutput>true</computeroutput>, input bytes are read lowest-order bit first, otherwise highest-order bit first. Defaults to <computeroutput>false</computeroutput> if omitted. (<emphasis>RefIn</emphasis> from the RMCA) </para></description></parameter><parameter name="reflect_remainder"><paramtype>bool</paramtype><default>false</default><description><para>If <computeroutput>true</computeroutput>, the output remainder is reflected before the XOR-mask. Defaults to <computeroutput>false</computeroutput> if omitted. (<emphasis>RefOut</emphasis> from the RMCA)</para></description></parameter><purpose>Create a computer, separately listing each needed parameter. </purpose><description><para>Constructs a <computeroutput><classname alt="boost::crc_basic">crc_basic</classname></computeroutput> object with at least the required parameters to a particular CRC formula to be processed upon receiving input.</para><para>
  69. </para></description><postconditions><para><computeroutput><emphasis>truncated_polynomial</emphasis> == this-&gt;get_truncated_polynominal()</computeroutput> </para>
  70. </postconditions><postconditions><para><computeroutput><emphasis>initial_remainder</emphasis> == this-&gt;get_initial_remainder()</computeroutput> </para>
  71. </postconditions><postconditions><para><computeroutput><emphasis>final_xor_value</emphasis> == this-&gt;get_final_xor_value()</computeroutput> </para>
  72. </postconditions><postconditions><para><computeroutput><emphasis>reflect_input</emphasis> == this-&gt;get_reflect_input()</computeroutput> </para>
  73. </postconditions><postconditions><para><computeroutput><emphasis>reflect_remainder</emphasis> == this-&gt;get_reflect_remainder()</computeroutput> </para>
  74. </postconditions><postconditions><para><computeroutput><emphasis>initial_remainder</emphasis> == this-&gt;get_interim_remainder()</computeroutput> </para>
  75. </postconditions><postconditions><para><computeroutput>(<emphasis>reflect_remainder</emphasis> ? REFLECT(<emphasis>initial_remainder</emphasis>) : <emphasis>initial_remainder</emphasis>) ^ <emphasis>final_xor_value</emphasis> == this-&gt;checksum()</computeroutput> </para>
  76. </postconditions></constructor>
  77. </class><class name="crc_optimal"><template>
  78. <template-nontype-parameter name="Bits"><type>std::size_t</type><purpose><para>The order of the modulo-2 polynomial divisor. (<emphasis>Width</emphasis> from the RMCA) </para></purpose></template-nontype-parameter>
  79. <template-nontype-parameter name="TruncPoly"><type>typename ::boost::uint_t&lt; Bits &gt;::fast</type><purpose><para>The lowest coefficients of the divisor polynomial. The highest-order coefficient is omitted and always assumed to be 1. Defaults to <computeroutput>0</computeroutput>, i.e. the only non-zero term is the implicit one for x<superscript><emphasis>Bits</emphasis></superscript>. (<emphasis>Poly</emphasis> from the RMCA) </para></purpose></template-nontype-parameter>
  80. <template-nontype-parameter name="InitRem"><type>typename ::boost::uint_t&lt; Bits &gt;::fast</type><purpose><para>The (unaugmented) initial state of the polynomial remainder. Defaults to <computeroutput>0</computeroutput> if omitted. (<emphasis>Init</emphasis> from the RMCA) </para></purpose></template-nontype-parameter>
  81. <template-nontype-parameter name="FinalXor"><type>typename ::boost::uint_t&lt; Bits &gt;::fast</type><purpose><para>The (XOR) bit-mask to be applied to the output remainder, after possible reflection but before returning. Defaults to <computeroutput>0</computeroutput> (i.e. no bit changes) if omitted. (<emphasis>XorOut</emphasis> from the RMCA) </para></purpose></template-nontype-parameter>
  82. <template-nontype-parameter name="ReflectIn"><type>bool</type><purpose><para>If <computeroutput>true</computeroutput>, input bytes are read lowest-order bit first, otherwise highest-order bit first. Defaults to <computeroutput>false</computeroutput> if omitted. (<emphasis>RefIn</emphasis> from the RMCA) </para></purpose></template-nontype-parameter>
  83. <template-nontype-parameter name="ReflectRem"><type>bool</type><purpose><para>If <computeroutput>true</computeroutput>, the output remainder is reflected before the XOR-mask. Defaults to <computeroutput>false</computeroutput> if omitted. (<emphasis>RefOut</emphasis> from the RMCA)</para></purpose></template-nontype-parameter>
  84. </template><purpose>Table-driven CRC computer, usable as a function object. </purpose><description><para>Objects of this type compute the CRC checksum of submitted data, where said data can be entered piecemeal through several different kinds of groupings. Modulo-2 polynomial division steps are performed byte-wise, aided by the use of pre-computation tables. Said division uses the altered algorithm, so any data has to be unaugmented.</para><para>
  85. <xrefsect id="todo_1_todo000001"><xreftitle>Todo</xreftitle><xrefdescription><para>Get rid of the default value for <emphasis>TruncPoly</emphasis>. Choosing a divisor is an important decision with many factors, so a default is never useful, especially a bad one. </para>
  86. </xrefdescription></xrefsect></para></description><typedef name="value_type"><purpose>The register type used for computations. </purpose><description><para>This type is used for CRC calculations and is the type for any returned checksums and returned or submitted remainders, (truncated) divisors, or XOR masks. It is a built-in unsigned integer type. </para></description><type>boost::uint_t&lt; Bits &gt;::fast</type></typedef>
  87. <method-group name="public member functions">
  88. <method name="BOOST_STATIC_CONSTANT"><type/><parameter name=""><paramtype>std::size_t</paramtype></parameter><parameter name=""><paramtype>bit_count</paramtype><default>Bits</default></parameter></method>
  89. <method name="BOOST_STATIC_CONSTANT"><type/><parameter name=""><paramtype>value_type</paramtype></parameter><parameter name=""><paramtype>truncated_polynominal</paramtype><default>TruncPoly</default></parameter><purpose>A copy of <emphasis>TruncPoly</emphasis> provided for meta-programming purposes. </purpose></method>
  90. <method name="BOOST_STATIC_CONSTANT"><type/><parameter name=""><paramtype>value_type</paramtype></parameter><parameter name=""><paramtype>initial_remainder</paramtype><default>InitRem</default></parameter><purpose>A copy of <emphasis>InitRem</emphasis> provided for meta-programming purposes. </purpose></method>
  91. <method name="BOOST_STATIC_CONSTANT"><type/><parameter name=""><paramtype>value_type</paramtype></parameter><parameter name=""><paramtype>final_xor_value</paramtype><default>FinalXor</default></parameter><purpose>A copy of <emphasis>FinalXor</emphasis> provided for meta-programming purposes. </purpose></method>
  92. <method name="BOOST_STATIC_CONSTANT"><type/><parameter name=""><paramtype>bool</paramtype></parameter><parameter name=""><paramtype>reflect_input</paramtype><default>ReflectIn</default></parameter><purpose>A copy of <emphasis>ReflectIn</emphasis> provided for meta-programming purposes. </purpose></method>
  93. <method name="BOOST_STATIC_CONSTANT"><type/><parameter name=""><paramtype>bool</paramtype></parameter><parameter name=""><paramtype>reflect_remainder</paramtype><default>ReflectRem</default></parameter><purpose>A copy of <emphasis>ReflectRem</emphasis> provided for meta-programming purposes. </purpose></method>
  94. <method name="get_truncated_polynominal" cv="const"><type>value_type</type><purpose>Return the (truncated) polynomial divisor. </purpose><description><para>Returns a representation of the polynomial divisor. The value of the 2<superscript>i</superscript> bit is the value of the coefficient of the polynomial's x<superscript>i</superscript> term. The omitted bit for x<superscript>(#bit_count)</superscript> term is always 1.</para><para>
  95. </para></description><returns><para>The bit-packed list of coefficients. If the bit-length of value_type exceeds #bit_count, the values of higher-placed bits should be ignored (even any for x<superscript>(#bit_count)</superscript>) since they're unregulated. </para>
  96. </returns></method>
  97. <method name="get_initial_remainder" cv="const"><type>value_type</type><purpose>Return what the polynomial remainder was set to during construction. </purpose><description><para>Returns a representation of the polynomial remainder before any input has been submitted. The value of the 2<superscript>i</superscript> bit is the value of the coefficient of the polynomial's x<superscript>i</superscript> term.</para><para>
  98. </para></description><returns><para>The bit-packed list of coefficients. If the bit-length of value_type exceeds #bit_count, the values of higher-placed bits should be ignored since they're unregulated. </para>
  99. </returns></method>
  100. <method name="get_final_xor_value" cv="const"><type>value_type</type><purpose>Return the XOR-mask used during output processing. </purpose><description><para>Returns the mask to be used during creation of a checksum. The mask is used for an exclusive-or (XOR) operation applied bit-wise to the interim remainder representation (after any reflection, if get_reflect_remainder() returns <computeroutput>true</computeroutput>).</para><para>
  101. </para></description><returns><para>The bit-mask. If the bit-length of value_type exceeds #bit_count, the values of higher-placed bits should be ignored since they're unregulated. </para>
  102. </returns></method>
  103. <method name="get_reflect_input" cv="const"><type>bool</type><purpose>Check if input-bytes will be reflected before processing. </purpose><description><para>Returns a whether or not a submitted byte will be "reflected" before it is used to update the interim remainder. Only the byte-wise operations process_byte, process_block, and process_bytes are affected.</para><para>
  104. </para></description></method>
  105. <method name="get_reflect_remainder" cv="const"><type>bool</type><purpose>Check if the remainder will be reflected during output processing. </purpose><description><para>Indicates if the interim remainder will be "reflected" before it is passed to the XOR-mask stage when returning a checksum.</para><para>
  106. </para></description></method>
  107. <method name="get_interim_remainder" cv="const"><type>value_type</type><purpose>Return the remainder based from already-processed bits. </purpose><description><para>Returns a representation of the polynomial remainder after all the input submissions since construction or the last reset call. The value of the 2<superscript>i</superscript> bit is the value of the coefficient of the polynomial's x<superscript>i</superscript> term. If CRC processing gets interrupted here, retain the value returned, and use it to start up the next CRC computer where you left off (with reset(value_type) or construction). The next computer has to have its other parameters compatible with this computer.</para><para>
  108. </para></description><returns><para>The bit-packed list of coefficients. If the bit-length of value_type exceeds #bit_count, the values of higher-placed bits should be ignored since they're unregulated. No output processing (reflection or XOR mask) has been applied to the value. </para>
  109. </returns></method>
  110. <method name="reset"><type>void</type><parameter name="new_rem"><paramtype>value_type</paramtype><default>initial_remainder</default><description><para>The (unaugmented) state of the polynomial remainder starting from this point, with no output processing applied. Defaults to <computeroutput>this-&gt;get_initial_remainder()</computeroutput> if omitted.</para></description></parameter><purpose>Change the interim remainder to either a given value or the initial one. </purpose><description><para>Changes the interim polynomial remainder to <emphasis>new_rem</emphasis>, purging any influence previously submitted input has had. The value of the 2<superscript>i</superscript> bit is the value of the coefficient of the polynomial's x<superscript>i</superscript> term.</para><para>
  111. </para></description><postconditions><para><computeroutput><emphasis>new_rem</emphasis> == this-&gt;get_interim_remainder()</computeroutput> </para>
  112. </postconditions><postconditions><para><computeroutput>((this-&gt;get_reflect_remainder() ? REFLECT(<emphasis>new_rem</emphasis>) : <emphasis>new_rem</emphasis>) ^ this-&gt;get_final_xor_value()) == this-&gt;checksum()</computeroutput> </para>
  113. </postconditions></method>
  114. <method name="process_byte"><type>void</type><parameter name="byte"><paramtype>unsigned char</paramtype><description><para>The new input byte.</para></description></parameter><purpose>Submit a single byte for input processing. </purpose><description><para>Updates the interim remainder with a byte's worth of altered-CRC-division steps. The bits within the byte are processed from the highest place down if <computeroutput>this-&gt;get_reflect_input()</computeroutput> is <computeroutput>false</computeroutput>, and lowest place up otherwise.</para><para>
  115. <note><para>Any modulo-2 polynomial divisions may use a table of pre-computed remainder changes (as XOR masks) to speed computation when reading data byte-wise. </para>
  116. </note>
  117. </para></description><postconditions><para>The interim remainder is updated though <computeroutput>CHAR_BIT</computeroutput> modulo-2 polynomial divisions, where the division steps are altered for unaugmented CRCs.</para>
  118. </postconditions></method>
  119. <method name="process_block"><type>void</type><parameter name="bytes_begin"><paramtype>void const *</paramtype><description><para>The address where the memory block begins. </para></description></parameter><parameter name="bytes_end"><paramtype>void const *</paramtype><description><para>Points to one-byte past the address of the memory block's last byte, or <emphasis>bytes_begin</emphasis> if no bytes are to be read.</para></description></parameter><purpose>Submit a memory block for input processing, iterator-pair style. </purpose><description><para>Updates the interim remainder with several bytes' worth of altered-CRC-division steps. The bits within each byte are processed from the highest place down if <computeroutput>this-&gt;get_reflect_input()</computeroutput> is <computeroutput>false</computeroutput>, and lowest place up otherwise. The bytes themselves are processed starting from the one pointed by <emphasis>bytes_begin</emphasis> until <emphasis>bytes_end</emphasis> is reached through forward iteration, treating the two pointers as if they point to <computeroutput>unsigned char</computeroutput> objects.</para><para>
  120. <note><para>Any modulo-2 polynomial divisions may use a table of pre-computed remainder changes (as XOR masks) to speed computation when reading data byte-wise. </para>
  121. </note>
  122. </para></description><requires><para><emphasis>bytes_end</emphasis> has to equal <emphasis>bytes_begin</emphasis> if the latter is <computeroutput>NULL</computeroutput> or otherwise doesn't point to a valid buffer. </para>
  123. </requires><requires><para><emphasis>bytes_end</emphasis>, if not equal to <emphasis>bytes_begin</emphasis>, has to point within or one-byte-past the same buffer <emphasis>bytes_begin</emphasis> points into. </para>
  124. </requires><requires><para><emphasis>bytes_end</emphasis> has to be reachable from <emphasis>bytes_begin</emphasis> through a finite number of forward byte-pointer increments.</para>
  125. </requires><postconditions><para>The interim remainder is updated though <computeroutput>CHAR_BIT * (((unsigned char const *) bytes_end) - ((unsigned char const *) bytes_begin))</computeroutput> modulo-2 polynomial divisions, where the division steps are altered for unaugmented CRCs.</para>
  126. </postconditions></method>
  127. <method name="process_bytes"><type>void</type><parameter name="buffer"><paramtype>void const *</paramtype><description><para>The address where the memory block begins. </para></description></parameter><parameter name="byte_count"><paramtype>std::size_t</paramtype><description><para>The number of bytes in the memory block.</para></description></parameter><purpose>Submit a memory block for input processing, pointer-and-size style. </purpose><description><para>Updates the interim remainder with several bytes' worth of altered-CRC-division steps. The bits within each byte are processed from the highest place down if <computeroutput>this-&gt;get_reflect_input()</computeroutput> is <computeroutput>false</computeroutput>, and lowest place up otherwise. The bytes themselves are processed starting from the one pointed by <emphasis>buffer</emphasis>, forward-iterated (as if the pointed-to objects were of <computeroutput>unsigned char</computeroutput>) until <emphasis>byte_count</emphasis> bytes are read.</para><para>
  128. <note><para>Any modulo-2 polynomial divisions may use a table of pre-computed remainder changes (as XOR masks) to speed computation when reading data byte-wise. </para>
  129. </note>
  130. </para></description><requires><para><emphasis>byte_count</emphasis> has to equal 0 if <emphasis>buffer</emphasis> is <computeroutput>NULL</computeroutput> or otherwise doesn't point to valid memory. </para>
  131. </requires><requires><para>If <emphasis>buffer</emphasis> points within valid memory, then that block has to have at least <emphasis>byte_count</emphasis> more valid bytes allocated from that point.</para>
  132. </requires><postconditions><para>The interim remainder is updated though <computeroutput>CHAR_BIT * <emphasis>byte_count</emphasis></computeroutput> modulo-2 polynomial divisions, where the division steps are altered for unaugmented CRCs.</para>
  133. </postconditions></method>
  134. <method name="checksum" cv="const"><type>value_type</type><purpose>Return the checksum of the already-processed bits. </purpose><description><para>Computes the checksum of all the submitted bits since construction or the last call to reset. The checksum will be the raw checksum, i.e. the (interim) remainder after all the modulo-2 polynomial division, plus any output processing.</para><para>
  135. <note><para>Since checksums are meant to be compared, any higher-placed bits (when the bit-length of value_type exceeds #bit_count) will be set to 0. </para>
  136. </note>
  137. </para></description><returns><para><computeroutput>(this-&gt;get_reflect_remainder() ? REFLECT(this-&gt;get_interim_remainder()) : this-&gt;get_interim_remainder()) ^ this-&gt;get_final_xor_value()</computeroutput></para>
  138. </returns></method>
  139. <method name="operator()"><type>void</type><parameter name="byte"><paramtype>unsigned char</paramtype><description><para>The new input byte.</para></description></parameter><purpose>Submit a single byte for input processing, suitable for the STL. </purpose><description><para>Updates the interim remainder with a byte's worth of altered-CRC-division steps. The bits within the byte are processed from the highest place down if <computeroutput>this-&gt;get_reflect_input()</computeroutput> is <computeroutput>false</computeroutput>, and lowest place up otherwise. This function is meant to present a function-object interface to code that wants to process a stream of bytes with <computeroutput>std::for_each</computeroutput> or similar range-processing algorithms. Since some of these algorithms takes their function object by value, make sure to copy back the result to this object so the updates can be remembered.</para><para>
  140. <note><para>Any modulo-2 polynomial divisions may use a table of pre-computed remainder changes (as XOR masks) to speed computation when reading data byte-wise. </para>
  141. </note>
  142. </para></description><postconditions><para>The interim remainder is updated though <computeroutput>CHAR_BIT</computeroutput> modulo-2 polynomial divisions, where the division steps are altered for unaugmented CRCs.</para>
  143. </postconditions></method>
  144. <method name="operator()" cv="const"><type>value_type</type><purpose>Return the checksum of the already-processed bits, suitable for the STL. </purpose><description><para>Computes the checksum of all the submitted bits since construction or the last call to reset. The checksum will be the raw checksum, i.e. the (interim) remainder after all the modulo-2 polynomial division, plus any output processing. This function is meant to present a function-object interface to code that wants to receive data like <computeroutput>std::generate_n</computeroutput> or similar data-processing algorithms. Note that if this object is used as a generator multiple times without an intervening mutating operation, the same value will always be returned.</para><para>
  145. <note><para>Since checksums are meant to be compared, any higher-placed bits (when the bit-length of value_type exceeds #bit_count) will be set to 0. </para>
  146. </note>
  147. </para></description><returns><para><computeroutput>(this-&gt;get_reflect_remainder() ? REFLECT(this-&gt;get_interim_remainder()) : this-&gt;get_interim_remainder()) ^ this-&gt;get_final_xor_value()</computeroutput></para>
  148. </returns></method>
  149. </method-group>
  150. <constructor specifiers="explicit"><parameter name="init_rem"><paramtype>value_type</paramtype><default>initial_remainder</default><description><para>The (unaugmented) initial state of the polynomial remainder. Defaults to #initial_remainder if omitted.</para></description></parameter><purpose>Create a computer, giving an initial remainder if desired. </purpose><description><para>Constructs a <computeroutput><classname alt="boost::crc_optimal">crc_optimal</classname></computeroutput> object with a particular CRC formula to be processed upon receiving input. The initial remainder may be overridden.</para><para>
  151. </para></description><postconditions><para><computeroutput>#truncated_polynominal == this-&gt;get_truncated_polynominal()</computeroutput> </para>
  152. </postconditions><postconditions><para><computeroutput>#initial_remainder == this-&gt;get_initial_remainder()</computeroutput> </para>
  153. </postconditions><postconditions><para><computeroutput>#final_xor_value == this-&gt;get_final_xor_value()</computeroutput> </para>
  154. </postconditions><postconditions><para><computeroutput>#reflect_input == this-&gt;get_reflect_input()</computeroutput> </para>
  155. </postconditions><postconditions><para><computeroutput>#reflect_remainder == this-&gt;get_reflect_remainder()</computeroutput> </para>
  156. </postconditions><postconditions><para><computeroutput><emphasis>init_rem</emphasis> == this-&gt;get_interim_remainder()</computeroutput> </para>
  157. </postconditions><postconditions><para><computeroutput>(#reflect_remainder ? REFLECT(<emphasis>init_rem</emphasis>) : <emphasis>init_rem</emphasis>) ^ #final_xor_value == this-&gt;checksum()</computeroutput> </para>
  158. </postconditions></constructor>
  159. </class><typedef name="crc_16_type"><purpose>Computation type for ARC|CRC-16|CRC-IBM|CRC-16/ARC|CRC-16/LHA standard. </purpose><type><classname>crc_optimal</classname>&lt; 16, 0x8005, 0, 0, true, true &gt;</type></typedef>
  160. <typedef name="crc_ccitt_false_t"><purpose>Computation type for CRC-16/CCITT-FALSE standard. </purpose><type><classname>crc_optimal</classname>&lt; 16, 0x1021, 0xFFFF, 0, false, false &gt;</type></typedef>
  161. <typedef name="crc_ccitt_type"><purpose>Computation type for the CRC mistakenly called the CCITT standard. </purpose><type>crc_ccitt_false_t</type></typedef>
  162. <typedef name="crc_ccitt_true_t"><description><para>Computation type for the actual KERMIT|CRC-16/CCITT|CRC-16/CCITT-TRUE|CRC-CCITT standard </para></description><type><classname>crc_optimal</classname>&lt; 16, 0x1021, 0, 0, true, true &gt;</type></typedef>
  163. <typedef name="crc_xmodem_type"><description><para>Computation type that I mistakenly called the XMODEM standard; it inverts both reflection parameters and reflects the truncated divisor (Don't use?!) </para></description><type><classname>crc_optimal</classname>&lt; 16, 0x8408, 0, 0, true, true &gt;</type></typedef>
  164. <typedef name="crc_xmodem_t"><purpose>Computation type for the actual XMODEM|ZMODEM|CRC-16/ACORN standard. </purpose><type><classname>crc_optimal</classname>&lt; 16, 0x1021, 0, 0, false, false &gt;</type></typedef>
  165. <typedef name="crc_32_type"><purpose>Computation type for CRC-32|CRC-32/ADCCP|PKZIP standard. </purpose><type><classname>crc_optimal</classname>&lt; 32, 0x04C11DB7, 0xFFFFFFFF, 0xFFFFFFFF, true, true &gt;</type></typedef>
  166. <function name="crc"><type>uint_t&lt; Bits &gt;::fast</type><template>
  167. <template-nontype-parameter name="Bits"><type>std::size_t</type><purpose><para>The order of the modulo-2 polynomial divisor. (<emphasis>Width</emphasis> from the RMCA) </para></purpose></template-nontype-parameter>
  168. <template-nontype-parameter name="TruncPoly"><type>typename ::boost::uint_t&lt; Bits &gt;::fast</type><purpose><para>The lowest coefficients of the divisor polynomial. The highest-order coefficient is omitted and always assumed to be 1. (<emphasis>Poly</emphasis> from the RMCA) </para></purpose></template-nontype-parameter>
  169. <template-nontype-parameter name="InitRem"><type>typename ::boost::uint_t&lt; Bits &gt;::fast</type><purpose><para>The (unaugmented) initial state of the polynomial remainder. (<emphasis>Init</emphasis> from the RMCA) </para></purpose></template-nontype-parameter>
  170. <template-nontype-parameter name="FinalXor"><type>typename ::boost::uint_t&lt; Bits &gt;::fast</type><purpose><para>The (XOR) bit-mask to be applied to the output remainder, after possible reflection but before returning. (<emphasis>XorOut</emphasis> from the RMCA) </para></purpose></template-nontype-parameter>
  171. <template-nontype-parameter name="ReflectIn"><type>bool</type><purpose><para>If <computeroutput>True</computeroutput>, input bytes are read lowest-order bit first, otherwise highest-order bit first. (<emphasis>RefIn</emphasis> from the RMCA) </para></purpose></template-nontype-parameter>
  172. <template-nontype-parameter name="ReflectRem"><type>bool</type><purpose><para>If <computeroutput>True</computeroutput>, the output remainder is reflected before the XOR-mask. (<emphasis>RefOut</emphasis> from the RMCA)</para></purpose></template-nontype-parameter>
  173. </template><parameter name="buffer"><paramtype>void const *</paramtype><description><para>The address where the memory block begins. </para></description></parameter><parameter name="byte_count"><paramtype>std::size_t</paramtype><description><para>The number of bytes in the memory block.</para></description></parameter><purpose>Compute the (unaugmented) CRC of a memory block. </purpose><description><para>Computes the polynomial remainder of a CRC run, assuming that <emphasis>buffer</emphasis> and <emphasis>byte_count</emphasis> describe a memory block representing the polynomial dividend. The division steps are altered so the result directly gives a checksum, without need to augment the memory block with scratch-space bytes. The first byte is considered the highest order, going down for subsequent bytes.</para><para>
  174. <note><para>Unaugmented-style CRC runs perform modulo-2 polynomial division in an altered order. The trailing <emphasis>Bits</emphasis> number of zero-valued bits needed to extracted an (unprocessed) checksum is virtually moved to near the beginning of the message. This is OK since the XOR operation is commutative and associative. It also means that you can get a checksum anytime. Since data is being read byte-wise, a table of pre-computed remainder changes (as XOR masks) can be used to speed computation. </para>
  175. </note>
  176. </para></description><requires><para>0 &lt; <emphasis>Bits</emphasis> &lt;= <computeroutput>std::numeric_limits&lt;uintmax_t&gt;::digits</computeroutput> </para>
  177. </requires><returns><para>The checksum, which is the last (interim) remainder plus any output processing.</para>
  178. </returns></function>
  179. <function name="augmented_crc"><type>uint_t&lt; Bits &gt;::fast</type><template>
  180. <template-nontype-parameter name="Bits"><type>std::size_t</type><purpose><para>The order of the modulo-2 polynomial divisor. (<emphasis>Width</emphasis> from the RMCA) </para></purpose></template-nontype-parameter>
  181. <template-nontype-parameter name="TruncPoly"><type>typename ::boost::uint_t&lt; Bits &gt;::fast</type><purpose><para>The lowest coefficients of the divisor polynomial. The highest-order coefficient is omitted and always assumed to be 1. (<emphasis>Poly</emphasis> from the RMCA)</para></purpose></template-nontype-parameter>
  182. </template><parameter name="buffer"><paramtype>void const *</paramtype><description><para>The address where the memory block begins. </para></description></parameter><parameter name="byte_count"><paramtype>std::size_t</paramtype><description><para>The number of bytes in the memory block. </para></description></parameter><parameter name="initial_remainder"><paramtype>typename uint_t&lt; Bits &gt;::fast</paramtype><default>0u</default><description><para>The initial state of the polynomial remainder, defaulting to zero if omitted. If you are reading a memory block in multiple runs, put the return value of the previous run here. (Note that initial-remainders given by RMCA parameter lists, as <emphasis>Init</emphasis>, assume that the initial remainder is in its <emphasis role="bold">unaugmented</emphasis> state, so you would need to convert the value to make it suitable for this function. I currently don't provide a conversion routine.)</para></description></parameter><purpose>Compute the CRC of a memory block, with any augmentation provided by user. </purpose><description><para>Computes the polynomial remainder of a CRC run, assuming that <emphasis>buffer</emphasis> and <emphasis>byte_count</emphasis> describe a memory block representing the polynomial dividend. The first byte is considered the highest order, going down for subsequent bytes. Within a byte, the highest-order bit is read first (corresponding to <emphasis>RefIn</emphasis> = <computeroutput>False</computeroutput> in the RMCA). Check the other parts of this function's documentation to see how a checksum can be gained and/or used.</para><para>
  183. <note><para>Augmented-style CRC runs use straight-up modulo-2 polynomial division. Since data is being read byte-wise, a table of pre-computed remainder changes (as XOR masks) can be used to speed computation. </para>
  184. </note>
  185. <note><para>Reading just a memory block will yield an interim remainder, and not the final checksum. To get that checksum, allocate <emphasis>Bits</emphasis> / <computeroutput>CHAR_BIT</computeroutput> bytes directly after the block and fill them with zero values, then extend <emphasis>byte_count</emphasis> to include those extra bytes. A data block is corrupt if the return value doesn't equal your separately given checksum. </para>
  186. </note>
  187. <note><para>Another way to perform a check is use the zero-byte extension method, but replace the zero values with your separately-given checksum. The checksum must be loaded in big-endian order. Here corruption, in either the data block or the given checksum, is confirmed if the return value is not zero. </para>
  188. </note>
  189. <note><para>The two checksum techniques assume the CRC-run is performed bit-wise, while this function works byte-wise. That means that the techniques can be used only if <computeroutput>CHAR_BIT</computeroutput> divides <emphasis>Bits</emphasis> evenly! </para>
  190. </note>
  191. </para></description><requires><para>0 &lt; <emphasis>Bits</emphasis> &lt;= <computeroutput>std::numeric_limit&lt;uintmax_t&gt;::digits</computeroutput> </para>
  192. </requires><returns><para>The interim remainder, if no augmentation is used. A special value if augmentation is used (see the notes). No output processing is done on the value. (In RMCA terms, <emphasis>RefOut</emphasis> is <computeroutput>False</computeroutput> and <emphasis>XorOut</emphasis> is <computeroutput>0</computeroutput>.)</para>
  193. </returns></function>
  194. </namespace>
  195. <macro name="BOOST_CRC_PARM_TYPE"/>
  196. <macro name="BOOST_CRC_OPTIMAL_NAME"/>
  197. </header>
  198. </library-reference>