GTMReadMonitorInputStream.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* Copyright 2014 Google Inc. All rights reserved.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. #import <Foundation/Foundation.h>
  16. #ifndef GTM_NONNULL
  17. #if defined(__has_attribute)
  18. #if __has_attribute(nonnull)
  19. #define GTM_NONNULL(x) __attribute__((nonnull x))
  20. #else
  21. #define GTM_NONNULL(x)
  22. #endif
  23. #else
  24. #define GTM_NONNULL(x)
  25. #endif
  26. #endif
  27. @interface GTMReadMonitorInputStream : NSInputStream <NSStreamDelegate>
  28. + (instancetype)inputStreamWithStream:(NSInputStream *)input GTM_NONNULL((1));
  29. - (instancetype)initWithStream:(NSInputStream *)input GTM_NONNULL((1));
  30. // The read monitor selector is called when bytes have been read. It should have this signature:
  31. //
  32. // - (void)inputStream:(GTMReadMonitorInputStream *)stream
  33. // readIntoBuffer:(uint8_t *)buffer
  34. // length:(int64_t)length;
  35. @property(atomic, weak) id readDelegate;
  36. @property(atomic, assign) SEL readSelector;
  37. // Modes for invoking callbacks, when necessary.
  38. @property(atomic, strong) NSArray *runLoopModes;
  39. @end