NSDataBigString.h 753 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #import <Foundation/Foundation.h>
  8. #include <cxxreact/JSBigString.h>
  9. namespace facebook {
  10. namespace react {
  11. class NSDataBigString : public JSBigString {
  12. public:
  13. // The NSData passed in must be be null-terminated.
  14. NSDataBigString(NSData *data);
  15. // The ASCII optimization is not enabled on iOS
  16. bool isAscii() const override
  17. {
  18. return false;
  19. }
  20. const char *c_str() const override
  21. {
  22. return (const char *)[m_data bytes];
  23. }
  24. size_t size() const override
  25. {
  26. return m_length;
  27. }
  28. private:
  29. NSData *m_data;
  30. size_t m_length;
  31. };
  32. }
  33. }