No Description

FIRInstanceIDStringEncoding.h 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // GTMStringEncoding.h
  3. //
  4. // Copyright 2010 Google Inc.
  5. //
  6. // Licensed under the Apache License, Version 2.0 (the "License"); you may not
  7. // use this file except in compliance with the License. You may obtain a copy
  8. // of the License at
  9. //
  10. // http://www.apache.org/licenses/LICENSE-2.0
  11. //
  12. // Unless required by applicable law or agreed to in writing, software
  13. // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  14. // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  15. // License for the specific language governing permissions and limitations under
  16. // the License.
  17. //
  18. // This is a copy of GTMStringEncoding. FIRInstanceID wants to avoid
  19. // a CocoaPods GTM dependency. Hence we use our own version of StringEncoding.
  20. #import <Foundation/Foundation.h>
  21. // A generic class for arbitrary base-2 to 128 string encoding and decoding.
  22. @interface FIRInstanceIDStringEncoding : NSObject {
  23. @private
  24. NSData *charMapData_;
  25. char *charMap_;
  26. int reverseCharMap_[128];
  27. int shift_;
  28. unsigned int mask_;
  29. BOOL doPad_;
  30. char paddingChar_;
  31. int padLen_;
  32. }
  33. + (id)rfc4648Base64WebsafeStringEncoding;
  34. // Create a new, autoreleased GTMStringEncoding object with the given string,
  35. // as described below.
  36. + (id)stringEncodingWithString:(NSString *)string;
  37. // Initialize a new GTMStringEncoding object with the string.
  38. //
  39. // The length of the string must be a power of 2, at least 2 and at most 128.
  40. // Only 7-bit ASCII characters are permitted in the string.
  41. //
  42. // These characters are the canonical set emitted during encoding.
  43. // If the characters have alternatives (e.g. case, easily transposed) then use
  44. // addDecodeSynonyms: to configure them.
  45. - (id)initWithString:(NSString *)string;
  46. // Indicates whether padding is performed during encoding.
  47. - (BOOL)doPad;
  48. - (void)setDoPad:(BOOL)doPad;
  49. // Sets the padding character to use during encoding.
  50. - (void)setPaddingChar:(char)c;
  51. // Encode a raw binary buffer to a 7-bit ASCII string.
  52. - (NSString *)encode:(NSData *)data;
  53. // Decode a 7-bit ASCII string to a raw binary buffer.
  54. - (NSData *)decode:(NSString *)string;
  55. @end