FUtilities.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright 2017 Google
  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. #import "FirebaseCore/Extension/FirebaseCoreInternal.h"
  17. #import <Foundation/Foundation.h>
  18. #import "FirebaseDatabase/Sources/Utilities/FParsedUrl.h"
  19. @interface FUtilities : NSObject
  20. + (NSArray *)splitString:(NSString *)str intoMaxSize:(const unsigned int)size;
  21. + (NSNumber *)LUIDGenerator;
  22. + (FParsedUrl *)parseUrl:(NSString *)url;
  23. + (NSString *)getJavascriptType:(id)obj;
  24. + (NSError *)errorForStatus:(NSString *)status andReason:(NSString *)reason;
  25. + (NSNumber *)intForString:(NSString *)string;
  26. + (NSInteger)int32min;
  27. + (NSInteger)int32max;
  28. + (NSString *)ieee754StringForNumber:(NSNumber *)val;
  29. + (BOOL)tryParseString:(NSString *)string asInt:(NSInteger *)integer;
  30. + (void)setLoggingEnabled:(BOOL)enabled;
  31. + (BOOL)getLoggingEnabled;
  32. + (NSString *)minName;
  33. + (NSString *)maxName;
  34. + (NSComparisonResult)compareKey:(NSString *)a toKey:(NSString *)b;
  35. + (NSComparator)stringComparator;
  36. + (NSComparator)keyComparator;
  37. + (double)randomDouble;
  38. @end
  39. typedef enum {
  40. FLogLevelDebug = 1,
  41. FLogLevelInfo = 2,
  42. FLogLevelWarn = 3,
  43. FLogLevelError = 4,
  44. FLogLevelNone = 5
  45. } FLogLevel;
  46. // Log tags
  47. FOUNDATION_EXPORT NSString *const kFPersistenceLogTag;
  48. #define FFLog(code, format, ...) FFDebug((code), (format), ##__VA_ARGS__)
  49. #define FFDebug(code, format, ...) \
  50. do { \
  51. if (FFIsLoggingEnabled(FLogLevelDebug)) { \
  52. FIRLogDebug(kFIRLoggerDatabase, (code), (format), ##__VA_ARGS__); \
  53. } \
  54. } while (0)
  55. #define FFInfo(code, format, ...) \
  56. do { \
  57. if (FFIsLoggingEnabled(FLogLevelInfo)) { \
  58. FIRLogError(kFIRLoggerDatabase, (code), (format), ##__VA_ARGS__); \
  59. } \
  60. } while (0)
  61. #define FFWarn(code, format, ...) \
  62. do { \
  63. if (FFIsLoggingEnabled(FLogLevelWarn)) { \
  64. FIRLogWarning(kFIRLoggerDatabase, (code), (format), \
  65. ##__VA_ARGS__); \
  66. } \
  67. } while (0)
  68. #define INTEGER_32_MIN (-2147483648)
  69. #define INTEGER_32_MAX 2147483647
  70. extern FIRLoggerService kFIRLoggerDatabase;
  71. BOOL FFIsLoggingEnabled(FLogLevel logLevel);
  72. void firebaseUncaughtExceptionHandler(NSException *exception);
  73. void firebaseJobsTroll(void);