Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright 2012 ZXing authors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. @class ZXByteArray;
  17. /**
  18. * This provides an easy abstraction to read bits at a time from a sequence of bytes, where the
  19. * number of bits read is not often a multiple of 8.
  20. *
  21. * This class is thread-safe but not reentrant -- unless the caller modifies the bytes array
  22. * it passed in, in which case all bets are off.
  23. */
  24. @interface ZXBitSource : NSObject
  25. /**
  26. * @return index of next bit in current byte which would be read by the next call to {@link #readBits(int)}.
  27. */
  28. @property (nonatomic, assign, readonly) int bitOffset;
  29. /**
  30. * @return index of next byte in input byte array which would be read by the next call to {@link #readBits(int)}.
  31. */
  32. @property (nonatomic, assign, readonly) int byteOffset;
  33. /**
  34. * @param bytes bytes from which this will read bits. Bits will be read from the first byte first.
  35. * Bits are read within a byte from most-significant to least-significant bit.
  36. */
  37. - (id)initWithBytes:(ZXByteArray *)bytes;
  38. /**
  39. * @param numBits number of bits to read
  40. * @return int representing the bits read. The bits will appear as the least-significant
  41. * bits of the int
  42. * @throws NSInvalidArgumentException if numBits isn't in [1,32] or more than is available
  43. */
  44. - (int)readBits:(int)numBits;
  45. /**
  46. * @return number of bits that can be read successfully
  47. */
  48. - (int)available;
  49. @end