diff --git a/Crashlytics.framework/Crashlytics b/Crashlytics.framework/Crashlytics new file mode 100755 index 0000000..a33d1cc Binary files /dev/null and b/Crashlytics.framework/Crashlytics differ diff --git a/Crashlytics.framework/Headers/ANSCompatibility.h b/Crashlytics.framework/Headers/ANSCompatibility.h new file mode 100644 index 0000000..6ec011d --- /dev/null +++ b/Crashlytics.framework/Headers/ANSCompatibility.h @@ -0,0 +1,31 @@ +// +// ANSCompatibility.h +// AnswersKit +// +// Copyright (c) 2015 Crashlytics, Inc. All rights reserved. +// + +#pragma once + +#if !__has_feature(nullability) +#define nonnull +#define nullable +#define _Nullable +#define _Nonnull +#endif + +#ifndef NS_ASSUME_NONNULL_BEGIN +#define NS_ASSUME_NONNULL_BEGIN +#endif + +#ifndef NS_ASSUME_NONNULL_END +#define NS_ASSUME_NONNULL_END +#endif + +#if __has_feature(objc_generics) +#define ANS_GENERIC_NSARRAY(type) NSArray +#define ANS_GENERIC_NSDICTIONARY(key_type,object_key) NSDictionary +#else +#define ANS_GENERIC_NSARRAY(type) NSArray +#define ANS_GENERIC_NSDICTIONARY(key_type,object_key) NSDictionary +#endif diff --git a/Crashlytics.framework/Headers/Answers.h b/Crashlytics.framework/Headers/Answers.h new file mode 100644 index 0000000..8deacbe --- /dev/null +++ b/Crashlytics.framework/Headers/Answers.h @@ -0,0 +1,210 @@ +// +// Answers.h +// Crashlytics +// +// Copyright (c) 2015 Crashlytics, Inc. All rights reserved. +// + +#import +#import "ANSCompatibility.h" + +NS_ASSUME_NONNULL_BEGIN + +/** + * This class exposes the Answers Events API, allowing you to track key + * user user actions and metrics in your app. + */ +@interface Answers : NSObject + +/** + * Log a Sign Up event to see users signing up for your app in real-time, understand how + * many users are signing up with different methods and their success rate signing up. + * + * @param signUpMethodOrNil The method by which a user logged in, e.g. Twitter or Digits. + * @param signUpSucceededOrNil The ultimate success or failure of the login + * @param customAttributesOrNil A dictionary of custom attributes to associate with this event. + */ ++ (void)logSignUpWithMethod:(nullable NSString *)signUpMethodOrNil + success:(nullable NSNumber *)signUpSucceededOrNil + customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil; + +/** + * Log an Log In event to see users logging into your app in real-time, understand how many + * users are logging in with different methods and their success rate logging into your app. + * + * @param loginMethodOrNil The method by which a user logged in, e.g. email, Twitter or Digits. + * @param loginSucceededOrNil The ultimate success or failure of the login + * @param customAttributesOrNil A dictionary of custom attributes to associate with this event. + */ ++ (void)logLoginWithMethod:(nullable NSString *)loginMethodOrNil + success:(nullable NSNumber *)loginSucceededOrNil + customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil; + +/** + * Log a Share event to see users sharing from your app in real-time, letting you + * understand what content they're sharing from the type or genre down to the specific id. + * + * @param shareMethodOrNil The method by which a user shared, e.g. email, Twitter, SMS. + * @param contentNameOrNil The human readable name for this piece of content. + * @param contentTypeOrNil The type of content shared. + * @param contentIdOrNil The unique identifier for this piece of content. Useful for finding the top shared item. + * @param customAttributesOrNil A dictionary of custom attributes to associate with this event. + */ ++ (void)logShareWithMethod:(nullable NSString *)shareMethodOrNil + contentName:(nullable NSString *)contentNameOrNil + contentType:(nullable NSString *)contentTypeOrNil + contentId:(nullable NSString *)contentIdOrNil + customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil; + +/** + * Log an Invite Event to track how users are inviting other users into + * your application. + * + * @param inviteMethodOrNil The method of invitation, e.g. GameCenter, Twitter, email. + * @param customAttributesOrNil A dictionary of custom attributes to associate with this event. + */ ++ (void)logInviteWithMethod:(nullable NSString *)inviteMethodOrNil + customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil; + +/** + * Log a Purchase event to see your revenue in real-time, understand how many users are making purchases, see which + * items are most popular, and track plenty of other important purchase-related metrics. + * + * @param itemPriceOrNil The purchased item's price. + * @param currencyOrNil The ISO4217 currency code. Example: USD + * @param purchaseSucceededOrNil Was the purchase successful or unsuccessful + * @param itemNameOrNil The human-readable form of the item's name. Example: + * @param itemTypeOrNil The type, or genre of the item. Example: Song + * @param itemIdOrNil The machine-readable, unique item identifier Example: SKU + * @param customAttributesOrNil A dictionary of custom attributes to associate with this purchase. + */ ++ (void)logPurchaseWithPrice:(nullable NSDecimalNumber *)itemPriceOrNil + currency:(nullable NSString *)currencyOrNil + success:(nullable NSNumber *)purchaseSucceededOrNil + itemName:(nullable NSString *)itemNameOrNil + itemType:(nullable NSString *)itemTypeOrNil + itemId:(nullable NSString *)itemIdOrNil + customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil; + +/** + * Log a Level Start Event to track where users are in your game. + * + * @param levelNameOrNil The level name + * @param customAttributesOrNil A dictionary of custom attributes to associate with this level start event. + */ ++ (void)logLevelStart:(nullable NSString *)levelNameOrNil + customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil; + +/** + * Log a Level End event to track how users are completing levels in your game. + * + * @param levelNameOrNil The name of the level completed, E.G. "1" or "Training" + * @param scoreOrNil The score the user completed the level with. + * @param levelCompletedSuccesfullyOrNil A boolean representing whether or not the level was completed successfully. + * @param customAttributesOrNil A dictionary of custom attributes to associate with this event. + */ ++ (void)logLevelEnd:(nullable NSString *)levelNameOrNil + score:(nullable NSNumber *)scoreOrNil + success:(nullable NSNumber *)levelCompletedSuccesfullyOrNil + customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil; + +/** + * Log an Add to Cart event to see users adding items to a shopping cart in real-time, understand how + * many users start the purchase flow, see which items are most popular, and track plenty of other important + * purchase-related metrics. + * + * @param itemPriceOrNil The purchased item's price. + * @param currencyOrNil The ISO4217 currency code. Example: USD + * @param itemNameOrNil The human-readable form of the item's name. Example: + * @param itemTypeOrNil The type, or genre of the item. Example: Song + * @param itemIdOrNil The machine-readable, unique item identifier Example: SKU + * @param customAttributesOrNil A dictionary of custom attributes to associate with this event. + */ ++ (void)logAddToCartWithPrice:(nullable NSDecimalNumber *)itemPriceOrNil + currency:(nullable NSString *)currencyOrNil + itemName:(nullable NSString *)itemNameOrNil + itemType:(nullable NSString *)itemTypeOrNil + itemId:(nullable NSString *)itemIdOrNil + customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil; + +/** + * Log a Start Checkout event to see users moving through the purchase funnel in real-time, understand how many + * users are doing this and how much they're spending per checkout, and see how it related to other important + * purchase-related metrics. + * + * @param totalPriceOrNil The total price of the cart. + * @param currencyOrNil The ISO4217 currency code. Example: USD + * @param itemCountOrNil The number of items in the cart. + * @param customAttributesOrNil A dictionary of custom attributes to associate with this event. + */ ++ (void)logStartCheckoutWithPrice:(nullable NSDecimalNumber *)totalPriceOrNil + currency:(nullable NSString *)currencyOrNil + itemCount:(nullable NSNumber *)itemCountOrNil + customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil; + +/** + * Log a Rating event to see users rating content within your app in real-time and understand what + * content is most engaging, from the type or genre down to the specific id. + * + * @param ratingOrNil The integer rating given by the user. + * @param contentNameOrNil The human readable name for this piece of content. + * @param contentTypeOrNil The type of content shared. + * @param contentIdOrNil The unique identifier for this piece of content. Useful for finding the top shared item. + * @param customAttributesOrNil A dictionary of custom attributes to associate with this event. + */ ++ (void)logRating:(nullable NSNumber *)ratingOrNil + contentName:(nullable NSString *)contentNameOrNil + contentType:(nullable NSString *)contentTypeOrNil + contentId:(nullable NSString *)contentIdOrNil + customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil; + +/** + * Log a Content View event to see users viewing content within your app in real-time and + * understand what content is most engaging, from the type or genre down to the specific id. + * + * @param contentNameOrNil The human readable name for this piece of content. + * @param contentTypeOrNil The type of content shared. + * @param contentIdOrNil The unique identifier for this piece of content. Useful for finding the top shared item. + * @param customAttributesOrNil A dictionary of custom attributes to associate with this event. + */ ++ (void)logContentViewWithName:(nullable NSString *)contentNameOrNil + contentType:(nullable NSString *)contentTypeOrNil + contentId:(nullable NSString *)contentIdOrNil + customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil; + +/** + * Log a Search event allows you to see users searching within your app in real-time and understand + * exactly what they're searching for. + * + * @param queryOrNil The user's query. + * @param customAttributesOrNil A dictionary of custom attributes to associate with this event. + */ ++ (void)logSearchWithQuery:(nullable NSString *)queryOrNil + customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil; + +/** + * Log a Custom Event to see user actions that are uniquely important for your app in real-time, to see how often + * they're performing these actions with breakdowns by different categories you add. Use a human-readable name for + * the name of the event, since this is how the event will appear in Answers. + * + * @param eventName The human-readable name for the event. + * @param customAttributesOrNil A dictionary of custom attributes to associate with this event. Attribute keys + * must be NSString and values must be NSNumber or NSString. + * @discussion How we treat NSNumbers: + * We will provide information about the distribution of values over time. + * + * How we treat NSStrings: + * NSStrings are used as categorical data, allowing comparison across different category values. + * Strings are limited to a maximum length of 100 characters, attributes over this length will be + * truncated. + * + * When tracking the Tweet views to better understand user engagement, sending the tweet's length + * and the type of media present in the tweet allows you to track how tweet length and the type of media influence + * engagement. + */ ++ (void)logCustomEventWithName:(NSString *)eventName + customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Crashlytics.framework/Headers/CLSAttributes.h b/Crashlytics.framework/Headers/CLSAttributes.h new file mode 100644 index 0000000..1526b0d --- /dev/null +++ b/Crashlytics.framework/Headers/CLSAttributes.h @@ -0,0 +1,33 @@ +// +// CLSAttributes.h +// Crashlytics +// +// Copyright (c) 2015 Crashlytics, Inc. All rights reserved. +// + +#pragma once + +#define CLS_DEPRECATED(x) __attribute__ ((deprecated(x))) + +#if !__has_feature(nullability) + #define nonnull + #define nullable + #define _Nullable + #define _Nonnull +#endif + +#ifndef NS_ASSUME_NONNULL_BEGIN + #define NS_ASSUME_NONNULL_BEGIN +#endif + +#ifndef NS_ASSUME_NONNULL_END + #define NS_ASSUME_NONNULL_END +#endif + +#if __has_feature(objc_generics) + #define CLS_GENERIC_NSARRAY(type) NSArray + #define CLS_GENERIC_NSDICTIONARY(key_type,object_key) NSDictionary +#else + #define CLS_GENERIC_NSARRAY(type) NSArray + #define CLS_GENERIC_NSDICTIONARY(key_type,object_key) NSDictionary +#endif diff --git a/Crashlytics.framework/Headers/CLSLogging.h b/Crashlytics.framework/Headers/CLSLogging.h new file mode 100644 index 0000000..59590d5 --- /dev/null +++ b/Crashlytics.framework/Headers/CLSLogging.h @@ -0,0 +1,64 @@ +// +// CLSLogging.h +// Crashlytics +// +// Copyright (c) 2015 Crashlytics, Inc. All rights reserved. +// +#ifdef __OBJC__ +#import "CLSAttributes.h" +#import + +NS_ASSUME_NONNULL_BEGIN +#endif + + + +/** + * + * The CLS_LOG macro provides as easy way to gather more information in your log messages that are + * sent with your crash data. CLS_LOG prepends your custom log message with the function name and + * line number where the macro was used. If your app was built with the DEBUG preprocessor macro + * defined CLS_LOG uses the CLSNSLog function which forwards your log message to NSLog and CLSLog. + * If the DEBUG preprocessor macro is not defined CLS_LOG uses CLSLog only. + * + * Example output: + * -[AppDelegate login:] line 134 $ login start + * + * If you would like to change this macro, create a new header file, unset our define and then define + * your own version. Make sure this new header file is imported after the Crashlytics header file. + * + * #undef CLS_LOG + * #define CLS_LOG(__FORMAT__, ...) CLSNSLog... + * + **/ +#ifdef __OBJC__ +#ifdef DEBUG +#define CLS_LOG(__FORMAT__, ...) CLSNSLog((@"%s line %d $ " __FORMAT__), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__) +#else +#define CLS_LOG(__FORMAT__, ...) CLSLog((@"%s line %d $ " __FORMAT__), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__) +#endif +#endif + +/** + * + * Add logging that will be sent with your crash data. This logging will not show up in the system.log + * and will only be visible in your Crashlytics dashboard. + * + **/ + +#ifdef __OBJC__ +OBJC_EXTERN void CLSLog(NSString *format, ...) NS_FORMAT_FUNCTION(1,2); +OBJC_EXTERN void CLSLogv(NSString *format, va_list ap) NS_FORMAT_FUNCTION(1,0); + +/** + * + * Add logging that will be sent with your crash data. This logging will show up in the system.log + * and your Crashlytics dashboard. It is not recommended for Release builds. + * + **/ +OBJC_EXTERN void CLSNSLog(NSString *format, ...) NS_FORMAT_FUNCTION(1,2); +OBJC_EXTERN void CLSNSLogv(NSString *format, va_list ap) NS_FORMAT_FUNCTION(1,0); + + +NS_ASSUME_NONNULL_END +#endif diff --git a/Crashlytics.framework/Headers/CLSReport.h b/Crashlytics.framework/Headers/CLSReport.h new file mode 100644 index 0000000..a8ff3b0 --- /dev/null +++ b/Crashlytics.framework/Headers/CLSReport.h @@ -0,0 +1,103 @@ +// +// CLSReport.h +// Crashlytics +// +// Copyright (c) 2015 Crashlytics, Inc. All rights reserved. +// + +#import +#import "CLSAttributes.h" + +NS_ASSUME_NONNULL_BEGIN + +/** + * The CLSCrashReport protocol is deprecated. See the CLSReport class and the CrashyticsDelegate changes for details. + **/ +@protocol CLSCrashReport + +@property (nonatomic, copy, readonly) NSString *identifier; +@property (nonatomic, copy, readonly) NSDictionary *customKeys; +@property (nonatomic, copy, readonly) NSString *bundleVersion; +@property (nonatomic, copy, readonly) NSString *bundleShortVersionString; +@property (nonatomic, readonly, nullable) NSDate *crashedOnDate; +@property (nonatomic, copy, readonly) NSString *OSVersion; +@property (nonatomic, copy, readonly) NSString *OSBuildVersion; + +@end + +/** + * The CLSReport exposes an interface to the phsyical report that Crashlytics has created. You can + * use this class to get information about the event, and can also set some values after the + * event has occurred. + **/ +@interface CLSReport : NSObject + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +/** + * Returns the session identifier for the report. + **/ +@property (nonatomic, copy, readonly) NSString *identifier; + +/** + * Returns the custom key value data for the report. + **/ +@property (nonatomic, copy, readonly) NSDictionary *customKeys; + +/** + * Returns the CFBundleVersion of the application that generated the report. + **/ +@property (nonatomic, copy, readonly) NSString *bundleVersion; + +/** + * Returns the CFBundleShortVersionString of the application that generated the report. + **/ +@property (nonatomic, copy, readonly) NSString *bundleShortVersionString; + +/** + * Returns the date that the report was created. + **/ +@property (nonatomic, copy, readonly) NSDate *dateCreated; + +/** + * Returns the os version that the application crashed on. + **/ +@property (nonatomic, copy, readonly) NSString *OSVersion; + +/** + * Returns the os build version that the application crashed on. + **/ +@property (nonatomic, copy, readonly) NSString *OSBuildVersion; + +/** + * Returns YES if the report contains any crash information, otherwise returns NO. + **/ +@property (nonatomic, assign, readonly) BOOL isCrash; + +/** + * You can use this method to set, after the event, additional custom keys. The rules + * and semantics for this method are the same as those documented in Crashlytics.h. Be aware + * that the maximum size and count of custom keys is still enforced, and you can overwrite keys + * and/or cause excess keys to be deleted by using this method. + **/ +- (void)setObjectValue:(nullable id)value forKey:(NSString *)key; + +/** + * Record an application-specific user identifier. See Crashlytics.h for details. + **/ +@property (nonatomic, copy, nullable) NSString * userIdentifier; + +/** + * Record a user name. See Crashlytics.h for details. + **/ +@property (nonatomic, copy, nullable) NSString * userName; + +/** + * Record a user email. See Crashlytics.h for details. + **/ +@property (nonatomic, copy, nullable) NSString * userEmail; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Crashlytics.framework/Headers/CLSStackFrame.h b/Crashlytics.framework/Headers/CLSStackFrame.h new file mode 100644 index 0000000..cdb5596 --- /dev/null +++ b/Crashlytics.framework/Headers/CLSStackFrame.h @@ -0,0 +1,38 @@ +// +// CLSStackFrame.h +// Crashlytics +// +// Copyright 2015 Crashlytics, Inc. All rights reserved. +// + +#import +#import "CLSAttributes.h" + +NS_ASSUME_NONNULL_BEGIN + +/** + * + * This class is used in conjunction with -[Crashlytics recordCustomExceptionName:reason:frameArray:] to + * record information about non-ObjC/C++ exceptions. All information included here will be displayed + * in the Crashlytics UI, and can influence crash grouping. Be particularly careful with the use of the + * address property. If set, Crashlytics will attempt symbolication and could overwrite other properities + * in the process. + * + **/ +@interface CLSStackFrame : NSObject + ++ (instancetype)stackFrame; ++ (instancetype)stackFrameWithAddress:(NSUInteger)address; ++ (instancetype)stackFrameWithSymbol:(NSString *)symbol; + +@property (nonatomic, copy, nullable) NSString *symbol; +@property (nonatomic, copy, nullable) NSString *rawSymbol; +@property (nonatomic, copy, nullable) NSString *library; +@property (nonatomic, copy, nullable) NSString *fileName; +@property (nonatomic, assign) uint32_t lineNumber; +@property (nonatomic, assign) uint64_t offset; +@property (nonatomic, assign) uint64_t address; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Crashlytics.framework/Headers/Crashlytics.h b/Crashlytics.framework/Headers/Crashlytics.h new file mode 100644 index 0000000..7104ca8 --- /dev/null +++ b/Crashlytics.framework/Headers/Crashlytics.h @@ -0,0 +1,288 @@ +// +// Crashlytics.h +// Crashlytics +// +// Copyright (c) 2015 Crashlytics, Inc. All rights reserved. +// + +#import + +#import "CLSAttributes.h" +#import "CLSLogging.h" +#import "CLSReport.h" +#import "CLSStackFrame.h" +#import "Answers.h" + +NS_ASSUME_NONNULL_BEGIN + +@protocol CrashlyticsDelegate; + +/** + * Crashlytics. Handles configuration and initialization of Crashlytics. + * + * Note: The Crashlytics class cannot be subclassed. If this is causing you pain for + * testing, we suggest using either a wrapper class or a protocol extension. + */ +@interface Crashlytics : NSObject + +@property (nonatomic, readonly, copy) NSString *APIKey; +@property (nonatomic, readonly, copy) NSString *version; +@property (nonatomic, assign) BOOL debugMode; + +/** + * + * The delegate can be used to influence decisions on reporting and behavior, as well as reacting + * to previous crashes. + * + * Make certain that the delegate is setup before starting Crashlytics with startWithAPIKey:... or + * via +[Fabric with:...]. Failure to do will result in missing any delegate callbacks that occur + * synchronously during start. + * + **/ +@property (nonatomic, assign, nullable) id delegate; + +/** + * The recommended way to install Crashlytics into your application is to place a call to +startWithAPIKey: + * in your -application:didFinishLaunchingWithOptions: or -applicationDidFinishLaunching: + * method. + * + * Note: Starting with 3.0, the submission process has been significantly improved. The delay parameter + * is no longer required to throttle submissions on launch, performance will be great without it. + * + * @param apiKey The Crashlytics API Key for this app + * + * @return The singleton Crashlytics instance + */ ++ (Crashlytics *)startWithAPIKey:(NSString *)apiKey; ++ (Crashlytics *)startWithAPIKey:(NSString *)apiKey afterDelay:(NSTimeInterval)delay CLS_DEPRECATED("Crashlytics no longer needs or uses the delay parameter. Please use +startWithAPIKey: instead."); + +/** + * If you need the functionality provided by the CrashlyticsDelegate protocol, you can use + * these convenience methods to activate the framework and set the delegate in one call. + * + * @param apiKey The Crashlytics API Key for this app + * @param delegate A delegate object which conforms to CrashlyticsDelegate. + * + * @return The singleton Crashlytics instance + */ ++ (Crashlytics *)startWithAPIKey:(NSString *)apiKey delegate:(nullable id)delegate; ++ (Crashlytics *)startWithAPIKey:(NSString *)apiKey delegate:(nullable id)delegate afterDelay:(NSTimeInterval)delay CLS_DEPRECATED("Crashlytics no longer needs or uses the delay parameter. Please use +startWithAPIKey:delegate: instead."); + +/** + * Access the singleton Crashlytics instance. + * + * @return The singleton Crashlytics instance + */ ++ (Crashlytics *)sharedInstance; + +/** + * The easiest way to cause a crash - great for testing! + */ +- (void)crash; + +/** + * The easiest way to cause a crash with an exception - great for testing. + */ +- (void)throwException; + +/** + * Specify a user identifier which will be visible in the Crashlytics UI. + * + * Many of our customers have requested the ability to tie crashes to specific end-users of their + * application in order to facilitate responses to support requests or permit the ability to reach + * out for more information. We allow you to specify up to three separate values for display within + * the Crashlytics UI - but please be mindful of your end-user's privacy. + * + * We recommend specifying a user identifier - an arbitrary string that ties an end-user to a record + * in your system. This could be a database id, hash, or other value that is meaningless to a + * third-party observer but can be indexed and queried by you. + * + * Optionally, you may also specify the end-user's name or username, as well as email address if you + * do not have a system that works well with obscured identifiers. + * + * Pursuant to our EULA, this data is transferred securely throughout our system and we will not + * disseminate end-user data unless required to by law. That said, if you choose to provide end-user + * contact information, we strongly recommend that you disclose this in your application's privacy + * policy. Data privacy is of our utmost concern. + * + * @param identifier An arbitrary user identifier string which ties an end-user to a record in your system. + */ +- (void)setUserIdentifier:(nullable NSString *)identifier; + +/** + * Specify a user name which will be visible in the Crashlytics UI. + * Please be mindful of your end-user's privacy and see if setUserIdentifier: can fulfil your needs. + * @see setUserIdentifier: + * + * @param name An end user's name. + */ +- (void)setUserName:(nullable NSString *)name; + +/** + * Specify a user email which will be visible in the Crashlytics UI. + * Please be mindful of your end-user's privacy and see if setUserIdentifier: can fulfil your needs. + * + * @see setUserIdentifier: + * + * @param email An end user's email address. + */ +- (void)setUserEmail:(nullable NSString *)email; + ++ (void)setUserIdentifier:(nullable NSString *)identifier CLS_DEPRECATED("Please access this method via +sharedInstance"); ++ (void)setUserName:(nullable NSString *)name CLS_DEPRECATED("Please access this method via +sharedInstance"); ++ (void)setUserEmail:(nullable NSString *)email CLS_DEPRECATED("Please access this method via +sharedInstance"); + +/** + * Set a value for a for a key to be associated with your crash data which will be visible in the Crashlytics UI. + * When setting an object value, the object is converted to a string. This is typically done by calling + * -[NSObject description]. + * + * @param value The object to be associated with the key + * @param key The key with which to associate the value + */ +- (void)setObjectValue:(nullable id)value forKey:(NSString *)key; + +/** + * Set an int value for a key to be associated with your crash data which will be visible in the Crashlytics UI. + * + * @param value The integer value to be set + * @param key The key with which to associate the value + */ +- (void)setIntValue:(int)value forKey:(NSString *)key; + +/** + * Set an BOOL value for a key to be associated with your crash data which will be visible in the Crashlytics UI. + * + * @param value The BOOL value to be set + * @param key The key with which to associate the value + */ +- (void)setBoolValue:(BOOL)value forKey:(NSString *)key; + +/** + * Set an float value for a key to be associated with your crash data which will be visible in the Crashlytics UI. + * + * @param value The float value to be set + * @param key The key with which to associate the value + */ +- (void)setFloatValue:(float)value forKey:(NSString *)key; + ++ (void)setObjectValue:(nullable id)value forKey:(NSString *)key CLS_DEPRECATED("Please access this method via +sharedInstance"); ++ (void)setIntValue:(int)value forKey:(NSString *)key CLS_DEPRECATED("Please access this method via +sharedInstance"); ++ (void)setBoolValue:(BOOL)value forKey:(NSString *)key CLS_DEPRECATED("Please access this method via +sharedInstance"); ++ (void)setFloatValue:(float)value forKey:(NSString *)key CLS_DEPRECATED("Please access this method via +sharedInstance"); + +/** + * This method can be used to record a single exception structure in a report. This is particularly useful + * when your code interacts with non-native languages like Lua, C#, or Javascript. This call can be + * expensive and should only be used shortly before process termination. This API is not intended be to used + * to log NSException objects. All safely-reportable NSExceptions are automatically captured by + * Crashlytics. + * + * @param name The name of the custom exception + * @param reason The reason this exception occurred + * @param frameArray An array of CLSStackFrame objects + */ +- (void)recordCustomExceptionName:(NSString *)name reason:(nullable NSString *)reason frameArray:(CLS_GENERIC_NSARRAY(CLSStackFrame *) *)frameArray; + +/** + * + * This allows you to record a non-fatal event, described by an NSError object. These events will be grouped and + * displayed similarly to crashes. Keep in mind that this method can be expensive. Also, the total number of + * NSErrors that can be recorded during your app's life-cycle is limited by a fixed-size circular buffer. If the + * buffer is overrun, the oldest data is dropped. Errors are relayed to Crashlytics on a subsequent launch + * of your application. + * + * You can also use the -recordError:withAdditionalUserInfo: to include additional context not represented + * by the NSError instance itself. + * + **/ +- (void)recordError:(NSError *)error; +- (void)recordError:(NSError *)error withAdditionalUserInfo:(nullable CLS_GENERIC_NSDICTIONARY(NSString *, id) *)userInfo; + +- (void)logEvent:(NSString *)eventName CLS_DEPRECATED("Please refer to Answers +logCustomEventWithName:"); +- (void)logEvent:(NSString *)eventName attributes:(nullable NSDictionary *) attributes CLS_DEPRECATED("Please refer to Answers +logCustomEventWithName:"); ++ (void)logEvent:(NSString *)eventName CLS_DEPRECATED("Please refer to Answers +logCustomEventWithName:"); ++ (void)logEvent:(NSString *)eventName attributes:(nullable NSDictionary *) attributes CLS_DEPRECATED("Please refer to Answers +logCustomEventWithName:"); + +@end + +/** + * + * The CrashlyticsDelegate protocol provides a mechanism for your application to take + * action on events that occur in the Crashlytics crash reporting system. You can make + * use of these calls by assigning an object to the Crashlytics' delegate property directly, + * or through the convenience +startWithAPIKey:delegate: method. + * + */ +@protocol CrashlyticsDelegate +@optional + + +- (void)crashlyticsDidDetectCrashDuringPreviousExecution:(Crashlytics *)crashlytics CLS_DEPRECATED("Please refer to -crashlyticsDidDetectReportForLastExecution:"); +- (void)crashlytics:(Crashlytics *)crashlytics didDetectCrashDuringPreviousExecution:(id )crash CLS_DEPRECATED("Please refer to -crashlyticsDidDetectReportForLastExecution:"); + +/** + * + * Called when a Crashlytics instance has determined that the last execution of the + * application resulted in a saved report. This is called synchronously on Crashlytics + * initialization. Your delegate must invoke the completionHandler, but does not need to do so + * synchronously, or even on the main thread. Invoking completionHandler with NO will cause the + * detected report to be deleted and not submitted to Crashlytics. This is useful for + * implementing permission prompts, or other more-complex forms of logic around submitting crashes. + * + * Instead of using this method, you should try to make use of -crashlyticsDidDetectReportForLastExecution: + * if you can. + * + * @warning Failure to invoke the completionHandler will prevent submissions from being reported. Watch out. + * + * @warning Just implementing this delegate method will disable all forms of synchronous report submission. This can + * impact the reliability of reporting crashes very early in application launch. + * + * @param report The CLSReport object representing the last detected report + * @param completionHandler The completion handler to call when your logic has completed. + * + */ +- (void)crashlyticsDidDetectReportForLastExecution:(CLSReport *)report completionHandler:(void (^)(BOOL submit))completionHandler; + +/** + * + * Called when a Crashlytics instance has determined that the last execution of the + * application resulted in a saved report. This method differs from + * -crashlyticsDidDetectReportForLastExecution:completionHandler: in three important ways: + * + * - it is not called synchronously during initialization + * - it does not give you the ability to prevent the report from being submitted + * - the report object itself is immutable + * + * Thanks to these limitations, making use of this method does not impact reporting + * reliabilty in any way. + * + * @param report The read-only CLSReport object representing the last detected report + * + */ + +- (void)crashlyticsDidDetectReportForLastExecution:(CLSReport *)report; + +/** + * If your app is running on an OS that supports it (OS X 10.9+, iOS 7.0+), Crashlytics will submit + * most reports using out-of-process background networking operations. This results in a significant + * improvement in reliability of reporting, as well as power and performance wins for your users. + * If you don't want this functionality, you can disable by returning NO from this method. + * + * @warning Background submission is not supported for extensions on iOS or OS X. + * + * @param crashlytics The Crashlytics singleton instance + * + * @return Return NO if you don't want out-of-process background network operations. + * + */ +- (BOOL)crashlyticsCanUseBackgroundSessions:(Crashlytics *)crashlytics; + +@end + +/** + * `CrashlyticsKit` can be used as a parameter to `[Fabric with:@[CrashlyticsKit]];` in Objective-C. In Swift, use Crashlytics.sharedInstance() + */ +#define CrashlyticsKit [Crashlytics sharedInstance] + +NS_ASSUME_NONNULL_END diff --git a/Crashlytics.framework/Info.plist b/Crashlytics.framework/Info.plist new file mode 100644 index 0000000..e5719bc Binary files /dev/null and b/Crashlytics.framework/Info.plist differ diff --git a/Crashlytics.framework/Modules/module.modulemap b/Crashlytics.framework/Modules/module.modulemap new file mode 100644 index 0000000..da0845e --- /dev/null +++ b/Crashlytics.framework/Modules/module.modulemap @@ -0,0 +1,14 @@ +framework module Crashlytics { + header "Crashlytics.h" + header "Answers.h" + header "ANSCompatibility.h" + header "CLSLogging.h" + header "CLSReport.h" + header "CLSStackFrame.h" + header "CLSAttributes.h" + + export * + + link "z" + link "c++" +} diff --git a/Crashlytics.framework/run b/Crashlytics.framework/run new file mode 100755 index 0000000..9058ea6 --- /dev/null +++ b/Crashlytics.framework/run @@ -0,0 +1,28 @@ +#!/bin/sh + +# run +# +# Copyright (c) 2015 Crashlytics. All rights reserved. + +# Figure out where we're being called from +DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) + +# Quote path in case of spaces or special chars +DIR="\"${DIR}" + +PATH_SEP="/" +VALIDATE_COMMAND="uploadDSYM\" $@ validate run-script" +UPLOAD_COMMAND="uploadDSYM\" $@ run-script" + +# Ensure params are as expected, run in sync mode to validate +eval $DIR$PATH_SEP$VALIDATE_COMMAND +return_code=$? + +if [[ $return_code != 0 ]]; then + exit $return_code +fi + +# Verification passed, upload dSYM in background to prevent Xcode from waiting +# Note: Validation is performed again before upload. +# Output can still be found in Console.app +eval $DIR$PATH_SEP$UPLOAD_COMMAND > /dev/null 2>&1 & diff --git a/Crashlytics.framework/submit b/Crashlytics.framework/submit new file mode 100755 index 0000000..aa41e9e Binary files /dev/null and b/Crashlytics.framework/submit differ diff --git a/Crashlytics.framework/uploadDSYM b/Crashlytics.framework/uploadDSYM new file mode 100755 index 0000000..b5e9f58 Binary files /dev/null and b/Crashlytics.framework/uploadDSYM differ diff --git a/Fabric.framework/Fabric b/Fabric.framework/Fabric new file mode 100755 index 0000000..07246ea Binary files /dev/null and b/Fabric.framework/Fabric differ diff --git a/Fabric.framework/Headers/FABAttributes.h b/Fabric.framework/Headers/FABAttributes.h new file mode 100644 index 0000000..3a9355a --- /dev/null +++ b/Fabric.framework/Headers/FABAttributes.h @@ -0,0 +1,51 @@ +// +// FABAttributes.h +// Fabric +// +// Copyright (C) 2015 Twitter, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#pragma once + +#define FAB_UNAVAILABLE(x) __attribute__((unavailable(x))) + +#if !__has_feature(nullability) + #define nonnull + #define nullable + #define _Nullable + #define _Nonnull +#endif + +#ifndef NS_ASSUME_NONNULL_BEGIN + #define NS_ASSUME_NONNULL_BEGIN +#endif + +#ifndef NS_ASSUME_NONNULL_END + #define NS_ASSUME_NONNULL_END +#endif + + +/** + * The following macros are defined here to provide + * backwards compatability. If you are still using + * them you should migrate to the native nullability + * macros. + */ +#define fab_nullable nullable +#define fab_nonnull nonnull +#define FAB_NONNULL __fab_nonnull +#define FAB_NULLABLE __fab_nullable +#define FAB_START_NONNULL NS_ASSUME_NONNULL_BEGIN +#define FAB_END_NONNULL NS_ASSUME_NONNULL_END diff --git a/Fabric.framework/Headers/Fabric.h b/Fabric.framework/Headers/Fabric.h new file mode 100644 index 0000000..ecbdb53 --- /dev/null +++ b/Fabric.framework/Headers/Fabric.h @@ -0,0 +1,82 @@ +// +// Fabric.h +// Fabric +// +// Copyright (C) 2015 Twitter, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#import +#import "FABAttributes.h" + +NS_ASSUME_NONNULL_BEGIN + +#if TARGET_OS_IPHONE +#if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000 + #error "Fabric's minimum iOS version is 6.0" +#endif +#else +#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1070 + #error "Fabric's minimum OS X version is 10.7" +#endif +#endif + +/** + * Fabric Base. Coordinates configuration and starts all provided kits. + */ +@interface Fabric : NSObject + +/** + * Initialize Fabric and all provided kits. Call this method within your App Delegate's `application:didFinishLaunchingWithOptions:` and provide the kits you wish to use. + * + * For example, in Objective-C: + * + * `[Fabric with:@[[Crashlytics class], [Twitter class], [Digits class], [MoPub class]]];` + * + * Swift: + * + * `Fabric.with([Crashlytics.self(), Twitter.self(), Digits.self(), MoPub.self()])` + * + * Only the first call to this method is honored. Subsequent calls are no-ops. + * + * @param kitClasses An array of kit Class objects + * + * @return Returns the shared Fabric instance. In most cases this can be ignored. + */ ++ (instancetype)with:(NSArray *)kitClasses; + +/** + * Returns the Fabric singleton object. + */ ++ (instancetype)sharedSDK; + +/** + * This BOOL enables or disables debug logging, such as kit version information. The default value is NO. + */ +@property (nonatomic, assign) BOOL debug; + +/** + * Unavailable. Use `+sharedSDK` to retrieve the shared Fabric instance. + */ +- (id)init FAB_UNAVAILABLE("Use +sharedSDK to retrieve the shared Fabric instance."); + +/** + * Unavailable. Use `+sharedSDK` to retrieve the shared Fabric instance. + */ ++ (instancetype)new FAB_UNAVAILABLE("Use +sharedSDK to retrieve the shared Fabric instance."); + +@end + +NS_ASSUME_NONNULL_END + diff --git a/Fabric.framework/Info.plist b/Fabric.framework/Info.plist new file mode 100644 index 0000000..302cb01 Binary files /dev/null and b/Fabric.framework/Info.plist differ diff --git a/Fabric.framework/Modules/module.modulemap b/Fabric.framework/Modules/module.modulemap new file mode 100644 index 0000000..2a31223 --- /dev/null +++ b/Fabric.framework/Modules/module.modulemap @@ -0,0 +1,6 @@ +framework module Fabric { + umbrella header "Fabric.h" + + export * + module * { export * } +} \ No newline at end of file diff --git a/Fabric.framework/run b/Fabric.framework/run new file mode 100755 index 0000000..9058ea6 --- /dev/null +++ b/Fabric.framework/run @@ -0,0 +1,28 @@ +#!/bin/sh + +# run +# +# Copyright (c) 2015 Crashlytics. All rights reserved. + +# Figure out where we're being called from +DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) + +# Quote path in case of spaces or special chars +DIR="\"${DIR}" + +PATH_SEP="/" +VALIDATE_COMMAND="uploadDSYM\" $@ validate run-script" +UPLOAD_COMMAND="uploadDSYM\" $@ run-script" + +# Ensure params are as expected, run in sync mode to validate +eval $DIR$PATH_SEP$VALIDATE_COMMAND +return_code=$? + +if [[ $return_code != 0 ]]; then + exit $return_code +fi + +# Verification passed, upload dSYM in background to prevent Xcode from waiting +# Note: Validation is performed again before upload. +# Output can still be found in Console.app +eval $DIR$PATH_SEP$UPLOAD_COMMAND > /dev/null 2>&1 & diff --git a/Fabric.framework/uploadDSYM b/Fabric.framework/uploadDSYM new file mode 100755 index 0000000..ec7b802 Binary files /dev/null and b/Fabric.framework/uploadDSYM differ diff --git a/Podfile b/Podfile new file mode 100644 index 0000000..85ce140 --- /dev/null +++ b/Podfile @@ -0,0 +1,13 @@ +# Uncomment the next line to define a global platform for your project +# platform :ios, '9.0' + +target 'blista' do + # Comment the next line if you're not using Swift and don't want to use dynamic frameworks + use_frameworks! + + # Pods for blista + +pod 'Firebase/Core' +pod 'Firebase/Messaging' + +end diff --git a/Podfile.lock b/Podfile.lock new file mode 100644 index 0000000..17a1c16 --- /dev/null +++ b/Podfile.lock @@ -0,0 +1,51 @@ +PODS: + - Firebase/Core (4.10.1): + - FirebaseAnalytics (= 4.1.0) + - FirebaseCore (= 4.0.17) + - Firebase/Messaging (4.10.1): + - Firebase/Core + - FirebaseMessaging (= 2.1.1) + - FirebaseAnalytics (4.1.0): + - FirebaseCore (~> 4.0) + - FirebaseInstanceID (~> 2.0) + - GoogleToolboxForMac/NSData+zlib (~> 2.1) + - nanopb (~> 0.3) + - FirebaseCore (4.0.17): + - GoogleToolboxForMac/NSData+zlib (~> 2.1) + - FirebaseInstanceID (2.0.9): + - FirebaseCore (~> 4.0) + - FirebaseMessaging (2.1.1): + - FirebaseAnalytics (~> 4.1) + - FirebaseCore (~> 4.0) + - FirebaseInstanceID (~> 2.0) + - GoogleToolboxForMac/Logger (~> 2.1) + - Protobuf (~> 3.5) + - GoogleToolboxForMac/Defines (2.1.3) + - GoogleToolboxForMac/Logger (2.1.3): + - GoogleToolboxForMac/Defines (= 2.1.3) + - GoogleToolboxForMac/NSData+zlib (2.1.3): + - GoogleToolboxForMac/Defines (= 2.1.3) + - nanopb (0.3.8): + - nanopb/decode (= 0.3.8) + - nanopb/encode (= 0.3.8) + - nanopb/decode (0.3.8) + - nanopb/encode (0.3.8) + - Protobuf (3.5.0) + +DEPENDENCIES: + - Firebase/Core + - Firebase/Messaging + +SPEC CHECKSUMS: + Firebase: 92c6ba593e32db0defde464a9adc981d5cb49f97 + FirebaseAnalytics: 3dfae28d4a5e06f86c4fae830efc2ad3fadb19bc + FirebaseCore: 872307b001bbefda1dfa0dbfffa50a6919023d4a + FirebaseInstanceID: d2058a35e9bebda1b6dd42486b84917bde552a9d + FirebaseMessaging: db0e01c52ef7e1f42846431273558107d084ede4 + GoogleToolboxForMac: 2501e2ad72a52eb3dfe7bd9aee7dad11b858bd20 + nanopb: 5601e6bca2dbf1ed831b519092ec110f66982ca3 + Protobuf: 8a9838fba8dae3389230e1b7f8c104aa32389c03 + +PODFILE CHECKSUM: 520344186de1f29c76e02112d62a271448eeb812 + +COCOAPODS: 1.4.0 diff --git a/Pods/Firebase/Core/Sources/Firebase.h b/Pods/Firebase/Core/Sources/Firebase.h new file mode 100755 index 0000000..8180111 --- /dev/null +++ b/Pods/Firebase/Core/Sources/Firebase.h @@ -0,0 +1,68 @@ +#import +#import + +#if !defined(__has_include) + #error "Firebase.h won't import anything if your compiler doesn't support __has_include. Please \ + import the headers individually." +#else + #if __has_include() + #import + #endif + + #if __has_include() + #import + #endif + + #if __has_include() + #import + #endif + + #if __has_include() + #import + #endif + + #if __has_include() + #import + #endif + + #if __has_include() + #import + #endif + + #if __has_include() + #import + #endif + + #if __has_include() + #import + #endif + + #if __has_include() + #import + #endif + + #if __has_include() + #import + #endif + + #if __has_include() + #import + #endif + + #if __has_include() + #import + #endif + + #if __has_include() + #import + #endif + + #if __has_include() + #import + #endif + + #if __has_include() + #import + #endif + +#endif // defined(__has_include) diff --git a/Pods/Firebase/Core/Sources/module.modulemap b/Pods/Firebase/Core/Sources/module.modulemap new file mode 100755 index 0000000..3685b54 --- /dev/null +++ b/Pods/Firebase/Core/Sources/module.modulemap @@ -0,0 +1,4 @@ +module Firebase { + export * + header "Firebase.h" +} \ No newline at end of file diff --git a/Pods/Firebase/README.md b/Pods/Firebase/README.md new file mode 100755 index 0000000..0a7837e --- /dev/null +++ b/Pods/Firebase/README.md @@ -0,0 +1,76 @@ +# Firebase APIs for iOS + +Simplify your iOS development, grow your user base, and monetize more +effectively with Firebase services. + +Much more information can be found at [https://firebase.google.com](https://firebase.google.com). + +## Install a Firebase SDK using CocoaPods + +Firebase distributes several iOS specific APIs and SDKs via CocoaPods. +You can install the CocoaPods tool on OS X by running the following command from +the terminal. Detailed information is available in the [Getting Started +guide](https://guides.cocoapods.org/using/getting-started.html#getting-started). + +``` +$ sudo gem install cocoapods +``` + +## Try out an SDK + +You can try any of the SDKs with `pod try`. Run the following command and select +the SDK you are interested in when prompted: + +``` +$ pod try Firebase +``` + +Note that some SDKs may require credentials. More information is available in +the SDK-specific documentation at [https://firebase.google.com/docs/](https://firebase.google.com/docs/). + +## Add a Firebase SDK to your iOS app + +CocoaPods is used to install and manage dependencies in existing Xcode projects. + +1. Create an Xcode project, and save it to your local machine. +2. Create a file named `Podfile` in your project directory. This file defines + your project's dependencies, and is commonly referred to as a Podspec. +3. Open `Podfile`, and add your dependencies. A simple Podspec is shown here: + + ``` + platform :ios, '7.0' + pod 'Firebase' + ``` + +4. Save the file. +5. Open a terminal and `cd` to the directory containing the Podfile. + + ``` + $ cd /project/ + ``` + +6. Run the `pod install` command. This will install the SDKs specified in the + Podspec, along with any dependencies they may have. + + ``` + $ pod install + ``` + +7. Open your app's `.xcworkspace` file to launch Xcode. + Use this file for all development on your app. +8. You can also install other Firebase SDKs by adding the subspecs in the + Podfile. + + ``` + pod 'Firebase/AdMob' + pod 'Firebase/Analytics' + pod 'Firebase/Auth' + pod 'Firebase/Crash' + pod 'Firebase/Database' + pod 'Firebase/DynamicLinks' + pod 'Firebase/Invites' + pod 'Firebase/Messaging' + pod 'Firebase/Performance' + pod 'Firebase/RemoteConfig' + pod 'Firebase/Storage' + ``` diff --git a/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/FirebaseAnalytics b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/FirebaseAnalytics new file mode 100755 index 0000000..018d9cd Binary files /dev/null and b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/FirebaseAnalytics differ diff --git a/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalytics+AppDelegate.h b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalytics+AppDelegate.h new file mode 100755 index 0000000..d499af6 --- /dev/null +++ b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalytics+AppDelegate.h @@ -0,0 +1,62 @@ +#import + +#import "FIRAnalytics.h" + +NS_ASSUME_NONNULL_BEGIN + +/** + * Provides App Delegate handlers to be used in your App Delegate. + * + * To save time integrating Firebase Analytics in an application, Firebase Analytics does not + * require delegation implementation from the AppDelegate. Instead this is automatically done by + * Firebase Analytics. Should you choose instead to delegate manually, you can turn off the App + * Delegate Proxy by adding FirebaseAppDelegateProxyEnabled into your app's Info.plist and setting + * it to NO, and adding the methods in this category to corresponding delegation handlers. + * + * To handle Universal Links, you must return YES in + * [UIApplicationDelegate application:didFinishLaunchingWithOptions:]. + */ +@interface FIRAnalytics (AppDelegate) + +/** + * Handles events related to a URL session that are waiting to be processed. + * + * For optimal use of Firebase Analytics, call this method from the + * [UIApplicationDelegate application:handleEventsForBackgroundURLSession:completionHandler] + * method of the app delegate in your app. + * + * @param identifier The identifier of the URL session requiring attention. + * @param completionHandler The completion handler to call when you finish processing the events. + * Calling this completion handler lets the system know that your app's user interface is + * updated and a new snapshot can be taken. + */ ++ (void)handleEventsForBackgroundURLSession:(NSString *)identifier + completionHandler:(nullable void (^)(void))completionHandler; + +/** + * Handles the event when the app is launched by a URL. + * + * Call this method from [UIApplicationDelegate application:openURL:options:] (on iOS 9.0 and + * above), or [UIApplicationDelegate application:openURL:sourceApplication:annotation:] (on + * iOS 8.x and below) in your app. + * + * @param url The URL resource to open. This resource can be a network resource or a file. + */ ++ (void)handleOpenURL:(NSURL *)url; + +/** + * Handles the event when the app receives data associated with user activity that includes a + * Universal Link (on iOS 9.0 and above). + * + * Call this method from [UIApplication continueUserActivity:restorationHandler:] in your app + * delegate (on iOS 9.0 and above). + * + * @param userActivity The activity object containing the data associated with the task the user + * was performing. + */ ++ (void)handleUserActivity:(id)userActivity; + +@end + +NS_ASSUME_NONNULL_END + diff --git a/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalytics.h b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalytics.h new file mode 100755 index 0000000..d4c6320 --- /dev/null +++ b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalytics.h @@ -0,0 +1,115 @@ +#import + +#import "FIREventNames.h" +#import "FIRParameterNames.h" +#import "FIRUserPropertyNames.h" + +NS_ASSUME_NONNULL_BEGIN + +/// The top level Firebase Analytics singleton that provides methods for logging events and setting +/// user properties. See the developer guides for general +/// information on using Firebase Analytics in your apps. +NS_SWIFT_NAME(Analytics) +@interface FIRAnalytics : NSObject + +/// Logs an app event. The event can have up to 25 parameters. Events with the same name must have +/// the same parameters. Up to 500 event names are supported. Using predefined events and/or +/// parameters is recommended for optimal reporting. +/// +/// The following event names are reserved and cannot be used: +///
    +///
  • ad_activeview
  • +///
  • ad_click
  • +///
  • ad_exposure
  • +///
  • ad_impression
  • +///
  • ad_query
  • +///
  • adunit_exposure
  • +///
  • app_clear_data
  • +///
  • app_remove
  • +///
  • app_update
  • +///
  • error
  • +///
  • first_open
  • +///
  • in_app_purchase
  • +///
  • notification_dismiss
  • +///
  • notification_foreground
  • +///
  • notification_open
  • +///
  • notification_receive
  • +///
  • os_update
  • +///
  • screen_view
  • +///
  • session_start
  • +///
  • user_engagement
  • +///
+/// +/// @param name The name of the event. Should contain 1 to 40 alphanumeric characters or +/// underscores. The name must start with an alphabetic character. Some event names are +/// reserved. See FIREventNames.h for the list of reserved event names. The "firebase_", +/// "google_", and "ga_" prefixes are reserved and should not be used. Note that event names are +/// case-sensitive and that logging two events whose names differ only in case will result in +/// two distinct events. +/// @param parameters The dictionary of event parameters. Passing nil indicates that the event has +/// no parameters. Parameter names can be up to 40 characters long and must start with an +/// alphabetic character and contain only alphanumeric characters and underscores. Only NSString +/// and NSNumber (signed 64-bit integer and 64-bit floating-point number) parameter types are +/// supported. NSString parameter values can be up to 100 characters long. The "firebase_", +/// "google_", and "ga_" prefixes are reserved and should not be used for parameter names. ++ (void)logEventWithName:(NSString *)name + parameters:(nullable NSDictionary *)parameters + NS_SWIFT_NAME(logEvent(_:parameters:)); + +/// Sets a user property to a given value. Up to 25 user property names are supported. Once set, +/// user property values persist throughout the app lifecycle and across sessions. +/// +/// The following user property names are reserved and cannot be used: +///
    +///
  • first_open_time
  • +///
  • last_deep_link_referrer
  • +///
  • user_id
  • +///
+/// +/// @param value The value of the user property. Values can be up to 36 characters long. Setting the +/// value to nil removes the user property. +/// @param name The name of the user property to set. Should contain 1 to 24 alphanumeric characters +/// or underscores and must start with an alphabetic character. The "firebase_", "google_", and +/// "ga_" prefixes are reserved and should not be used for user property names. ++ (void)setUserPropertyString:(nullable NSString *)value forName:(NSString *)name + NS_SWIFT_NAME(setUserProperty(_:forName:)); + +/// Sets the user ID property. This feature must be used in accordance with +/// Google's Privacy Policy +/// +/// @param userID The user ID to ascribe to the user of this app on this device, which must be +/// non-empty and no more than 256 characters long. Setting userID to nil removes the user ID. ++ (void)setUserID:(nullable NSString *)userID; + +/// Sets the current screen name, which specifies the current visual context in your app. This helps +/// identify the areas in your app where users spend their time and how they interact with your app. +/// Must be called on the main thread. +/// +/// Note that screen reporting is enabled automatically and records the class name of the current +/// UIViewController for you without requiring you to call this method. If you implement +/// viewDidAppear in your UIViewController but do not call [super viewDidAppear:], that screen class +/// will not be automatically tracked. The class name can optionally be overridden by calling this +/// method in the viewDidAppear callback of your UIViewController and specifying the +/// screenClassOverride parameter. setScreenName:screenClass: must be called after +/// [super viewDidAppear:]. +/// +/// If your app does not use a distinct UIViewController for each screen, you should call this +/// method and specify a distinct screenName each time a new screen is presented to the user. +/// +/// The screen name and screen class remain in effect until the current UIViewController changes or +/// a new call to setScreenName:screenClass: is made. +/// +/// @param screenName The name of the current screen. Should contain 1 to 100 characters. Set to nil +/// to clear the current screen name. +/// @param screenClassOverride The name of the screen class. Should contain 1 to 100 characters. By +/// default this is the class name of the current UIViewController. Set to nil to revert to the +/// default class name. ++ (void)setScreenName:(nullable NSString *)screenName + screenClass:(nullable NSString *)screenClassOverride; + +/// The unique ID for this instance of the application. ++ (NSString *)appInstanceID; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalyticsConfiguration.h b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalyticsConfiguration.h new file mode 100755 index 0000000..dc227a4 --- /dev/null +++ b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalyticsConfiguration.h @@ -0,0 +1 @@ +#import diff --git a/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalyticsSwiftNameSupport.h b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalyticsSwiftNameSupport.h new file mode 100755 index 0000000..50fbf2e --- /dev/null +++ b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalyticsSwiftNameSupport.h @@ -0,0 +1,13 @@ +#ifndef FIR_SWIFT_NAME + +#import + +// NS_SWIFT_NAME can only translate factory methods before the iOS 9.3 SDK. +// Wrap it in our own macro if it's a non-compatible SDK. +#ifdef __IPHONE_9_3 +#define FIR_SWIFT_NAME(X) NS_SWIFT_NAME(X) +#else +#define FIR_SWIFT_NAME(X) // Intentionally blank. +#endif // #ifdef __IPHONE_9_3 + +#endif // FIR_SWIFT_NAME diff --git a/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRApp.h b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRApp.h new file mode 100755 index 0000000..de24da1 --- /dev/null +++ b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRApp.h @@ -0,0 +1 @@ +#import diff --git a/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRConfiguration.h b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRConfiguration.h new file mode 100755 index 0000000..be2ff7b --- /dev/null +++ b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRConfiguration.h @@ -0,0 +1 @@ +#import diff --git a/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIREventNames.h b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIREventNames.h new file mode 100755 index 0000000..c75536d --- /dev/null +++ b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIREventNames.h @@ -0,0 +1,405 @@ +/// @file FIREventNames.h +/// +/// Predefined event names. +/// +/// An Event is an important occurrence in your app that you want to measure. You can report up to +/// 500 different types of Events per app and you can associate up to 25 unique parameters with each +/// Event type. Some common events are suggested below, but you may also choose to specify custom +/// Event types that are associated with your specific app. Each event type is identified by a +/// unique name. Event names can be up to 40 characters long, may only contain alphanumeric +/// characters and underscores ("_"), and must start with an alphabetic character. The "firebase_", +/// "google_", and "ga_" prefixes are reserved and should not be used. + +/// Add Payment Info event. This event signifies that a user has submitted their payment information +/// to your app. +static NSString *const kFIREventAddPaymentInfo NS_SWIFT_NAME(AnalyticsEventAddPaymentInfo) = + @"add_payment_info"; + +/// E-Commerce Add To Cart event. This event signifies that an item was added to a cart for +/// purchase. Add this event to a funnel with kFIREventEcommercePurchase to gauge the effectiveness +/// of your checkout process. Note: If you supply the @c kFIRParameterValue parameter, you must +/// also supply the @c kFIRParameterCurrency parameter so that revenue metrics can be computed +/// accurately. Params: +/// +///
    +///
  • @c kFIRParameterQuantity (signed 64-bit integer as NSNumber)
  • +///
  • @c kFIRParameterItemID (NSString)
  • +///
  • @c kFIRParameterItemName (NSString)
  • +///
  • @c kFIRParameterItemCategory (NSString)
  • +///
  • @c kFIRParameterItemLocationID (NSString) (optional)
  • +///
  • @c kFIRParameterPrice (double as NSNumber) (optional)
  • +///
  • @c kFIRParameterCurrency (NSString) (optional)
  • +///
  • @c kFIRParameterValue (double as NSNumber) (optional)
  • +///
  • @c kFIRParameterOrigin (NSString) (optional)
  • +///
  • @c kFIRParameterDestination (NSString) (optional)
  • +///
  • @c kFIRParameterStartDate (NSString) (optional)
  • +///
  • @c kFIRParameterEndDate (NSString) (optional)
  • +///
+static NSString *const kFIREventAddToCart NS_SWIFT_NAME(AnalyticsEventAddToCart) = @"add_to_cart"; + +/// E-Commerce Add To Wishlist event. This event signifies that an item was added to a wishlist. +/// Use this event to identify popular gift items in your app. Note: If you supply the +/// @c kFIRParameterValue parameter, you must also supply the @c kFIRParameterCurrency +/// parameter so that revenue metrics can be computed accurately. Params: +/// +///
    +///
  • @c kFIRParameterQuantity (signed 64-bit integer as NSNumber)
  • +///
  • @c kFIRParameterItemID (NSString)
  • +///
  • @c kFIRParameterItemName (NSString)
  • +///
  • @c kFIRParameterItemCategory (NSString)
  • +///
  • @c kFIRParameterItemLocationID (NSString) (optional)
  • +///
  • @c kFIRParameterPrice (double as NSNumber) (optional)
  • +///
  • @c kFIRParameterCurrency (NSString) (optional)
  • +///
  • @c kFIRParameterValue (double as NSNumber) (optional)
  • +///
+static NSString *const kFIREventAddToWishlist NS_SWIFT_NAME(AnalyticsEventAddToWishlist) = + @"add_to_wishlist"; + +/// App Open event. By logging this event when an App becomes active, developers can understand how +/// often users leave and return during the course of a Session. Although Sessions are automatically +/// reported, this event can provide further clarification around the continuous engagement of +/// app-users. +static NSString *const kFIREventAppOpen NS_SWIFT_NAME(AnalyticsEventAppOpen) = @"app_open"; + +/// E-Commerce Begin Checkout event. This event signifies that a user has begun the process of +/// checking out. Add this event to a funnel with your kFIREventEcommercePurchase event to gauge the +/// effectiveness of your checkout process. Note: If you supply the @c kFIRParameterValue +/// parameter, you must also supply the @c kFIRParameterCurrency parameter so that revenue +/// metrics can be computed accurately. Params: +/// +///
    +///
  • @c kFIRParameterValue (double as NSNumber) (optional)
  • +///
  • @c kFIRParameterCurrency (NSString) (optional)
  • +///
  • @c kFIRParameterTransactionID (NSString) (optional)
  • +///
  • @c kFIRParameterStartDate (NSString) (optional)
  • +///
  • @c kFIRParameterEndDate (NSString) (optional)
  • +///
  • @c kFIRParameterNumberOfNights (signed 64-bit integer as NSNumber) (optional) for +/// hotel bookings
  • +///
  • @c kFIRParameterNumberOfRooms (signed 64-bit integer as NSNumber) (optional) for +/// hotel bookings
  • +///
  • @c kFIRParameterNumberOfPassengers (signed 64-bit integer as NSNumber) (optional) +/// for travel bookings
  • +///
  • @c kFIRParameterOrigin (NSString) (optional)
  • +///
  • @c kFIRParameterDestination (NSString) (optional)
  • +///
  • @c kFIRParameterTravelClass (NSString) (optional) for travel bookings
  • +///
+static NSString *const kFIREventBeginCheckout NS_SWIFT_NAME(AnalyticsEventBeginCheckout) = + @"begin_checkout"; + +/// Campaign Detail event. Log this event to supply the referral details of a re-engagement +/// campaign. Note: you must supply at least one of the required parameters kFIRParameterSource, +/// kFIRParameterMedium or kFIRParameterCampaign. Params: +/// +///
    +///
  • @c kFIRParameterSource (NSString)
  • +///
  • @c kFIRParameterMedium (NSString)
  • +///
  • @c kFIRParameterCampaign (NSString)
  • +///
  • @c kFIRParameterTerm (NSString) (optional)
  • +///
  • @c kFIRParameterContent (NSString) (optional)
  • +///
  • @c kFIRParameterAdNetworkClickID (NSString) (optional)
  • +///
  • @c kFIRParameterCP1 (NSString) (optional)
  • +///
+static NSString *const kFIREventCampaignDetails NS_SWIFT_NAME(AnalyticsEventCampaignDetails) = + @"campaign_details"; + +/// Checkout progress. Params: +/// +///
    +///
  • @c kFIRParameterCheckoutStep (unsigned 64-bit integer as NSNumber)
  • +///
  • @c kFIRParameterCheckoutOption (NSString) (optional)
  • +///
+static NSString *const kFIREventCheckoutProgress NS_SWIFT_NAME(AnalyticsEventCheckoutProgress) = + @"checkout_progress"; + +/// Earn Virtual Currency event. This event tracks the awarding of virtual currency in your app. Log +/// this along with @c kFIREventSpendVirtualCurrency to better understand your virtual economy. +/// Params: +/// +///
    +///
  • @c kFIRParameterVirtualCurrencyName (NSString)
  • +///
  • @c kFIRParameterValue (signed 64-bit integer or double as NSNumber)
  • +///
+static NSString *const kFIREventEarnVirtualCurrency + NS_SWIFT_NAME(AnalyticsEventEarnVirtualCurrency) = @"earn_virtual_currency"; + +/// E-Commerce Purchase event. This event signifies that an item was purchased by a user. Note: +/// This is different from the in-app purchase event, which is reported automatically for App +/// Store-based apps. Note: If you supply the @c kFIRParameterValue parameter, you must also +/// supply the @c kFIRParameterCurrency parameter so that revenue metrics can be computed +/// accurately. Params: +/// +///
    +///
  • @c kFIRParameterCurrency (NSString) (optional)
  • +///
  • @c kFIRParameterValue (double as NSNumber) (optional)
  • +///
  • @c kFIRParameterTransactionID (NSString) (optional)
  • +///
  • @c kFIRParameterTax (double as NSNumber) (optional)
  • +///
  • @c kFIRParameterShipping (double as NSNumber) (optional)
  • +///
  • @c kFIRParameterCoupon (NSString) (optional)
  • +///
  • @c kFIRParameterLocation (NSString) (optional)
  • +///
  • @c kFIRParameterStartDate (NSString) (optional)
  • +///
  • @c kFIRParameterEndDate (NSString) (optional)
  • +///
  • @c kFIRParameterNumberOfNights (signed 64-bit integer as NSNumber) (optional) for +/// hotel bookings
  • +///
  • @c kFIRParameterNumberOfRooms (signed 64-bit integer as NSNumber) (optional) for +/// hotel bookings
  • +///
  • @c kFIRParameterNumberOfPassengers (signed 64-bit integer as NSNumber) (optional) +/// for travel bookings
  • +///
  • @c kFIRParameterOrigin (NSString) (optional)
  • +///
  • @c kFIRParameterDestination (NSString) (optional)
  • +///
  • @c kFIRParameterTravelClass (NSString) (optional) for travel bookings
  • +///
+static NSString *const kFIREventEcommercePurchase NS_SWIFT_NAME(AnalyticsEventEcommercePurchase) = + @"ecommerce_purchase"; + +/// Generate Lead event. Log this event when a lead has been generated in the app to understand the +/// efficacy of your install and re-engagement campaigns. Note: If you supply the +/// @c kFIRParameterValue parameter, you must also supply the @c kFIRParameterCurrency +/// parameter so that revenue metrics can be computed accurately. Params: +/// +///
    +///
  • @c kFIRParameterCurrency (NSString) (optional)
  • +///
  • @c kFIRParameterValue (double as NSNumber) (optional)
  • +///
+static NSString *const kFIREventGenerateLead NS_SWIFT_NAME(AnalyticsEventGenerateLead) = + @"generate_lead"; + +/// Join Group event. Log this event when a user joins a group such as a guild, team or family. Use +/// this event to analyze how popular certain groups or social features are in your app. Params: +/// +///
    +///
  • @c kFIRParameterGroupID (NSString)
  • +///
+static NSString *const kFIREventJoinGroup NS_SWIFT_NAME(AnalyticsEventJoinGroup) = @"join_group"; + +/// Level Up event. This event signifies that a player has leveled up in your gaming app. It can +/// help you gauge the level distribution of your userbase and help you identify certain levels that +/// are difficult to pass. Params: +/// +///
    +///
  • @c kFIRParameterLevel (signed 64-bit integer as NSNumber)
  • +///
  • @c kFIRParameterCharacter (NSString) (optional)
  • +///
+static NSString *const kFIREventLevelUp NS_SWIFT_NAME(AnalyticsEventLevelUp) = @"level_up"; + +/// Login event. Apps with a login feature can report this event to signify that a user has logged +/// in. +static NSString *const kFIREventLogin NS_SWIFT_NAME(AnalyticsEventLogin) = @"login"; + +/// Post Score event. Log this event when the user posts a score in your gaming app. This event can +/// help you understand how users are actually performing in your game and it can help you correlate +/// high scores with certain audiences or behaviors. Params: +/// +///
    +///
  • @c kFIRParameterScore (signed 64-bit integer as NSNumber)
  • +///
  • @c kFIRParameterLevel (signed 64-bit integer as NSNumber) (optional)
  • +///
  • @c kFIRParameterCharacter (NSString) (optional)
  • +///
+static NSString *const kFIREventPostScore NS_SWIFT_NAME(AnalyticsEventPostScore) = @"post_score"; + +/// Present Offer event. This event signifies that the app has presented a purchase offer to a user. +/// Add this event to a funnel with the kFIREventAddToCart and kFIREventEcommercePurchase to gauge +/// your conversion process. Note: If you supply the @c kFIRParameterValue parameter, you must +/// also supply the @c kFIRParameterCurrency parameter so that revenue metrics can be computed +/// accurately. Params: +/// +///
    +///
  • @c kFIRParameterQuantity (signed 64-bit integer as NSNumber)
  • +///
  • @c kFIRParameterItemID (NSString)
  • +///
  • @c kFIRParameterItemName (NSString)
  • +///
  • @c kFIRParameterItemCategory (NSString)
  • +///
  • @c kFIRParameterItemLocationID (NSString) (optional)
  • +///
  • @c kFIRParameterPrice (double as NSNumber) (optional)
  • +///
  • @c kFIRParameterCurrency (NSString) (optional)
  • +///
  • @c kFIRParameterValue (double as NSNumber) (optional)
  • +///
+static NSString *const kFIREventPresentOffer NS_SWIFT_NAME(AnalyticsEventPresentOffer) = + @"present_offer"; + +/// E-Commerce Purchase Refund event. This event signifies that an item purchase was refunded. +/// Note: If you supply the @c kFIRParameterValue parameter, you must also supply the +/// @c kFIRParameterCurrency parameter so that revenue metrics can be computed accurately. +/// Params: +/// +///
    +///
  • @c kFIRParameterCurrency (NSString) (optional)
  • +///
  • @c kFIRParameterValue (double as NSNumber) (optional)
  • +///
  • @c kFIRParameterTransactionID (NSString) (optional)
  • +///
+static NSString *const kFIREventPurchaseRefund NS_SWIFT_NAME(AnalyticsEventPurchaseRefund) = + @"purchase_refund"; + +/// Remove from cart event. Params: +/// +///
    +///
  • @c kFIRParameterQuantity (signed 64-bit integer as NSNumber)
  • +///
  • @c kFIRParameterItemID (NSString)
  • +///
  • @c kFIRParameterItemName (NSString)
  • +///
  • @c kFIRParameterItemCategory (NSString)
  • +///
  • @c kFIRParameterItemLocationID (NSString) (optional)
  • +///
  • @c kFIRParameterPrice (double as NSNumber) (optional)
  • +///
  • @c kFIRParameterCurrency (NSString) (optional)
  • +///
  • @c kFIRParameterValue (double as NSNumber) (optional)
  • +///
  • @c kFIRParameterOrigin (NSString) (optional)
  • +///
  • @c kFIRParameterDestination (NSString) (optional)
  • +///
  • @c kFIRParameterStartDate (NSString) (optional)
  • +///
  • @c kFIRParameterEndDate (NSString) (optional)
  • +///
+static NSString *const kFIREventRemoveFromCart NS_SWIFT_NAME(AnalyticsEventRemoveFromCart) = + @"remove_from_cart"; + +/// Search event. Apps that support search features can use this event to contextualize search +/// operations by supplying the appropriate, corresponding parameters. This event can help you +/// identify the most popular content in your app. Params: +/// +///
    +///
  • @c kFIRParameterSearchTerm (NSString)
  • +///
  • @c kFIRParameterStartDate (NSString) (optional)
  • +///
  • @c kFIRParameterEndDate (NSString) (optional)
  • +///
  • @c kFIRParameterNumberOfNights (signed 64-bit integer as NSNumber) (optional) for +/// hotel bookings
  • +///
  • @c kFIRParameterNumberOfRooms (signed 64-bit integer as NSNumber) (optional) for +/// hotel bookings
  • +///
  • @c kFIRParameterNumberOfPassengers (signed 64-bit integer as NSNumber) (optional) +/// for travel bookings
  • +///
  • @c kFIRParameterOrigin (NSString) (optional)
  • +///
  • @c kFIRParameterDestination (NSString) (optional)
  • +///
  • @c kFIRParameterTravelClass (NSString) (optional) for travel bookings
  • +///
+static NSString *const kFIREventSearch NS_SWIFT_NAME(AnalyticsEventSearch) = @"search"; + +/// Select Content event. This general purpose event signifies that a user has selected some content +/// of a certain type in an app. The content can be any object in your app. This event can help you +/// identify popular content and categories of content in your app. Params: +/// +///
    +///
  • @c kFIRParameterContentType (NSString)
  • +///
  • @c kFIRParameterItemID (NSString)
  • +///
+static NSString *const kFIREventSelectContent NS_SWIFT_NAME(AnalyticsEventSelectContent) = + @"select_content"; + +/// Set checkout option. Params: +/// +///
    +///
  • @c kFIRParameterCheckoutStep (unsigned 64-bit integer as NSNumber)
  • +///
  • @c kFIRParameterCheckoutOption (NSString)
  • +///
+static NSString *const kFIREventSetCheckoutOption NS_SWIFT_NAME(AnalyticsEventSetCheckoutOption) = + @"set_checkout_option"; + +/// Share event. Apps with social features can log the Share event to identify the most viral +/// content. Params: +/// +///
    +///
  • @c kFIRParameterContentType (NSString)
  • +///
  • @c kFIRParameterItemID (NSString)
  • +///
+static NSString *const kFIREventShare NS_SWIFT_NAME(AnalyticsEventShare) = @"share"; + +/// Sign Up event. This event indicates that a user has signed up for an account in your app. The +/// parameter signifies the method by which the user signed up. Use this event to understand the +/// different behaviors between logged in and logged out users. Params: +/// +///
    +///
  • @c kFIRParameterSignUpMethod (NSString)
  • +///
+static NSString *const kFIREventSignUp NS_SWIFT_NAME(AnalyticsEventSignUp) = @"sign_up"; + +/// Spend Virtual Currency event. This event tracks the sale of virtual goods in your app and can +/// help you identify which virtual goods are the most popular objects of purchase. Params: +/// +///
    +///
  • @c kFIRParameterItemName (NSString)
  • +///
  • @c kFIRParameterVirtualCurrencyName (NSString)
  • +///
  • @c kFIRParameterValue (signed 64-bit integer or double as NSNumber)
  • +///
+static NSString *const kFIREventSpendVirtualCurrency + NS_SWIFT_NAME(AnalyticsEventSpendVirtualCurrency) = @"spend_virtual_currency"; + +/// Tutorial Begin event. This event signifies the start of the on-boarding process in your app. Use +/// this in a funnel with kFIREventTutorialComplete to understand how many users complete this +/// process and move on to the full app experience. +static NSString *const kFIREventTutorialBegin NS_SWIFT_NAME(AnalyticsEventTutorialBegin) = + @"tutorial_begin"; + +/// Tutorial End event. Use this event to signify the user's completion of your app's on-boarding +/// process. Add this to a funnel with kFIREventTutorialBegin to gauge the completion rate of your +/// on-boarding process. +static NSString *const kFIREventTutorialComplete NS_SWIFT_NAME(AnalyticsEventTutorialComplete) = + @"tutorial_complete"; + +/// Unlock Achievement event. Log this event when the user has unlocked an achievement in your +/// game. Since achievements generally represent the breadth of a gaming experience, this event can +/// help you understand how many users are experiencing all that your game has to offer. Params: +/// +///
    +///
  • @c kFIRParameterAchievementID (NSString)
  • +///
+static NSString *const kFIREventUnlockAchievement NS_SWIFT_NAME(AnalyticsEventUnlockAchievement) = + @"unlock_achievement"; + +/// View Item event. This event signifies that some content was shown to the user. This content may +/// be a product, a webpage or just a simple image or text. Use the appropriate parameters to +/// contextualize the event. Use this event to discover the most popular items viewed in your app. +/// Note: If you supply the @c kFIRParameterValue parameter, you must also supply the +/// @c kFIRParameterCurrency parameter so that revenue metrics can be computed accurately. +/// Params: +/// +///
    +///
  • @c kFIRParameterItemID (NSString)
  • +///
  • @c kFIRParameterItemName (NSString)
  • +///
  • @c kFIRParameterItemCategory (NSString)
  • +///
  • @c kFIRParameterItemLocationID (NSString) (optional)
  • +///
  • @c kFIRParameterPrice (double as NSNumber) (optional)
  • +///
  • @c kFIRParameterQuantity (signed 64-bit integer as NSNumber) (optional)
  • +///
  • @c kFIRParameterCurrency (NSString) (optional)
  • +///
  • @c kFIRParameterValue (double as NSNumber) (optional)
  • +///
  • @c kFIRParameterStartDate (NSString) (optional)
  • +///
  • @c kFIRParameterEndDate (NSString) (optional)
  • +///
  • @c kFIRParameterFlightNumber (NSString) (optional) for travel bookings
  • +///
  • @c kFIRParameterNumberOfPassengers (signed 64-bit integer as NSNumber) (optional) +/// for travel bookings
  • +///
  • @c kFIRParameterNumberOfNights (signed 64-bit integer as NSNumber) (optional) for +/// travel bookings
  • +///
  • @c kFIRParameterNumberOfRooms (signed 64-bit integer as NSNumber) (optional) for +/// travel bookings
  • +///
  • @c kFIRParameterOrigin (NSString) (optional)
  • +///
  • @c kFIRParameterDestination (NSString) (optional)
  • +///
  • @c kFIRParameterSearchTerm (NSString) (optional) for travel bookings
  • +///
  • @c kFIRParameterTravelClass (NSString) (optional) for travel bookings
  • +///
+static NSString *const kFIREventViewItem NS_SWIFT_NAME(AnalyticsEventViewItem) = @"view_item"; + +/// View Item List event. Log this event when the user has been presented with a list of items of a +/// certain category. Params: +/// +///
    +///
  • @c kFIRParameterItemCategory (NSString)
  • +///
+static NSString *const kFIREventViewItemList NS_SWIFT_NAME(AnalyticsEventViewItemList) = + @"view_item_list"; + +/// View Search Results event. Log this event when the user has been presented with the results of a +/// search. Params: +/// +///
    +///
  • @c kFIRParameterSearchTerm (NSString)
  • +///
+static NSString *const kFIREventViewSearchResults NS_SWIFT_NAME(AnalyticsEventViewSearchResults) = + @"view_search_results"; + +/// Level Start event. Log this event when the user starts a new level. Params: +/// +///
    +///
  • @c kFIRParameterLevelName (NSString)
  • +///
+static NSString *const kFIREventLevelStart NS_SWIFT_NAME(AnalyticsEventLevelStart) = + @"level_start"; + +/// Level End event. Log this event when the user finishes a level. Params: +/// +///
    +///
  • @c kFIRParameterLevelName (NSString)
  • +///
  • @c kFIRParameterSuccess (NSString)
  • +///
+static NSString *const kFIREventLevelEnd NS_SWIFT_NAME(AnalyticsEventLevelEnd) = @"level_end"; diff --git a/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIROptions.h b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIROptions.h new file mode 100755 index 0000000..126824b --- /dev/null +++ b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIROptions.h @@ -0,0 +1 @@ +#import diff --git a/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRParameterNames.h b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRParameterNames.h new file mode 100755 index 0000000..41a995a --- /dev/null +++ b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRParameterNames.h @@ -0,0 +1,505 @@ +/// @file FIRParameterNames.h +/// +/// Predefined event parameter names. +/// +/// Params supply information that contextualize Events. You can associate up to 25 unique Params +/// with each Event type. Some Params are suggested below for certain common Events, but you are +/// not limited to these. You may supply extra Params for suggested Events or custom Params for +/// Custom events. Param names can be up to 40 characters long, may only contain alphanumeric +/// characters and underscores ("_"), and must start with an alphabetic character. Param values can +/// be up to 100 characters long. The "firebase_", "google_", and "ga_" prefixes are reserved and +/// should not be used. + +/// Game achievement ID (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterAchievementID : @"10_matches_won",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterAchievementID NS_SWIFT_NAME(AnalyticsParameterAchievementID) = + @"achievement_id"; + +/// Ad Network Click ID (NSString). Used for network-specific click IDs which vary in format. +///
+///     NSDictionary *params = @{
+///       kFIRParameterAdNetworkClickID : @"1234567",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterAdNetworkClickID + NS_SWIFT_NAME(AnalyticsParameterAdNetworkClickID) = @"aclid"; + +/// The store or affiliation from which this transaction occurred (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterAffiliation : @"Google Store",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterAffiliation NS_SWIFT_NAME(AnalyticsParameterAffiliation) = + @"affiliation"; + +/// The individual campaign name, slogan, promo code, etc. Some networks have pre-defined macro to +/// capture campaign information, otherwise can be populated by developer. Highly Recommended +/// (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterCampaign : @"winter_promotion",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterCampaign NS_SWIFT_NAME(AnalyticsParameterCampaign) = + @"campaign"; + +/// Character used in game (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterCharacter : @"beat_boss",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterCharacter NS_SWIFT_NAME(AnalyticsParameterCharacter) = + @"character"; + +/// The checkout step (1..N) (unsigned 64-bit integer as NSNumber). +///
+///     NSDictionary *params = @{
+///       kFIRParameterCheckoutStep : @"1",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterCheckoutStep NS_SWIFT_NAME(AnalyticsParameterCheckoutStep) = + @"checkout_step"; + +/// Some option on a step in an ecommerce flow (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterCheckoutOption : @"Visa",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterCheckoutOption + NS_SWIFT_NAME(AnalyticsParameterCheckoutOption) = @"checkout_option"; + +/// Campaign content (NSString). +static NSString *const kFIRParameterContent NS_SWIFT_NAME(AnalyticsParameterContent) = @"content"; + +/// Type of content selected (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterContentType : @"news article",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterContentType NS_SWIFT_NAME(AnalyticsParameterContentType) = + @"content_type"; + +/// Coupon code for a purchasable item (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterCoupon : @"zz123",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterCoupon NS_SWIFT_NAME(AnalyticsParameterCoupon) = @"coupon"; + +/// Campaign custom parameter (NSString). Used as a method of capturing custom data in a campaign. +/// Use varies by network. +///
+///     NSDictionary *params = @{
+///       kFIRParameterCP1 : @"custom_data",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterCP1 NS_SWIFT_NAME(AnalyticsParameterCP1) = @"cp1"; + +/// The name of a creative used in a promotional spot (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterCreativeName : @"Summer Sale",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterCreativeName NS_SWIFT_NAME(AnalyticsParameterCreativeName) = + @"creative_name"; + +/// The name of a creative slot (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterCreativeSlot : @"summer_banner2",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterCreativeSlot NS_SWIFT_NAME(AnalyticsParameterCreativeSlot) = + @"creative_slot"; + +/// Purchase currency in 3-letter +/// ISO_4217 format (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterCurrency : @"USD",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterCurrency NS_SWIFT_NAME(AnalyticsParameterCurrency) = + @"currency"; + +/// Flight or Travel destination (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterDestination : @"Mountain View, CA",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterDestination NS_SWIFT_NAME(AnalyticsParameterDestination) = + @"destination"; + +/// The arrival date, check-out date or rental end date for the item. This should be in +/// YYYY-MM-DD format (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterEndDate : @"2015-09-14",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterEndDate NS_SWIFT_NAME(AnalyticsParameterEndDate) = @"end_date"; + +/// Flight number for travel events (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterFlightNumber : @"ZZ800",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterFlightNumber NS_SWIFT_NAME(AnalyticsParameterFlightNumber) = + @"flight_number"; + +/// Group/clan/guild ID (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterGroupID : @"g1",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterGroupID NS_SWIFT_NAME(AnalyticsParameterGroupID) = @"group_id"; + +/// Index of an item in a list (signed 64-bit integer as NSNumber). +///
+///     NSDictionary *params = @{
+///       kFIRParameterIndex : @(1),
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterIndex NS_SWIFT_NAME(AnalyticsParameterIndex) = @"index"; + +/// Item brand (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterItemBrand : @"Google",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterItemBrand NS_SWIFT_NAME(AnalyticsParameterItemBrand) = + @"item_brand"; + +/// Item category (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterItemCategory : @"t-shirts",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterItemCategory NS_SWIFT_NAME(AnalyticsParameterItemCategory) = + @"item_category"; + +/// Item ID (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterItemID : @"p7654",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterItemID NS_SWIFT_NAME(AnalyticsParameterItemID) = @"item_id"; + +/// The Google Place ID (NSString) that +/// corresponds to the associated item. Alternatively, you can supply your own custom Location ID. +///
+///     NSDictionary *params = @{
+///       kFIRParameterItemLocationID : @"ChIJiyj437sx3YAR9kUWC8QkLzQ",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterItemLocationID + NS_SWIFT_NAME(AnalyticsParameterItemLocationID) = @"item_location_id"; + +/// Item name (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterItemName : @"abc",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterItemName NS_SWIFT_NAME(AnalyticsParameterItemName) = + @"item_name"; + +/// The list in which the item was presented to the user (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterItemList : @"Search Results",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterItemList NS_SWIFT_NAME(AnalyticsParameterItemList) = + @"item_list"; + +/// Item variant (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterItemVariant : @"Red",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterItemVariant NS_SWIFT_NAME(AnalyticsParameterItemVariant) = + @"item_variant"; + +/// Level in game (signed 64-bit integer as NSNumber). +///
+///     NSDictionary *params = @{
+///       kFIRParameterLevel : @(42),
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterLevel NS_SWIFT_NAME(AnalyticsParameterLevel) = @"level"; + +/// Location (NSString). The Google Place ID +/// that corresponds to the associated event. Alternatively, you can supply your own custom +/// Location ID. +///
+///     NSDictionary *params = @{
+///       kFIRParameterLocation : @"ChIJiyj437sx3YAR9kUWC8QkLzQ",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterLocation NS_SWIFT_NAME(AnalyticsParameterLocation) = + @"location"; + +/// The advertising or marketing medium, for example: cpc, banner, email, push. Highly recommended +/// (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterMedium : @"email",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterMedium NS_SWIFT_NAME(AnalyticsParameterMedium) = @"medium"; + +/// Number of nights staying at hotel (signed 64-bit integer as NSNumber). +///
+///     NSDictionary *params = @{
+///       kFIRParameterNumberOfNights : @(3),
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterNumberOfNights + NS_SWIFT_NAME(AnalyticsParameterNumberOfNights) = @"number_of_nights"; + +/// Number of passengers traveling (signed 64-bit integer as NSNumber). +///
+///     NSDictionary *params = @{
+///       kFIRParameterNumberOfPassengers : @(11),
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterNumberOfPassengers + NS_SWIFT_NAME(AnalyticsParameterNumberOfPassengers) = @"number_of_passengers"; + +/// Number of rooms for travel events (signed 64-bit integer as NSNumber). +///
+///     NSDictionary *params = @{
+///       kFIRParameterNumberOfRooms : @(2),
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterNumberOfRooms NS_SWIFT_NAME(AnalyticsParameterNumberOfRooms) = + @"number_of_rooms"; + +/// Flight or Travel origin (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterOrigin : @"Mountain View, CA",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterOrigin NS_SWIFT_NAME(AnalyticsParameterOrigin) = @"origin"; + +/// Purchase price (double as NSNumber). +///
+///     NSDictionary *params = @{
+///       kFIRParameterPrice : @(1.0),
+///       kFIRParameterCurrency : @"USD",  // e.g. $1.00 USD
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterPrice NS_SWIFT_NAME(AnalyticsParameterPrice) = @"price"; + +/// Purchase quantity (signed 64-bit integer as NSNumber). +///
+///     NSDictionary *params = @{
+///       kFIRParameterQuantity : @(1),
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterQuantity NS_SWIFT_NAME(AnalyticsParameterQuantity) = + @"quantity"; + +/// Score in game (signed 64-bit integer as NSNumber). +///
+///     NSDictionary *params = @{
+///       kFIRParameterScore : @(4200),
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterScore NS_SWIFT_NAME(AnalyticsParameterScore) = @"score"; + +/// The search string/keywords used (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterSearchTerm : @"periodic table",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterSearchTerm NS_SWIFT_NAME(AnalyticsParameterSearchTerm) = + @"search_term"; + +/// Shipping cost (double as NSNumber). +///
+///     NSDictionary *params = @{
+///       kFIRParameterShipping : @(9.50),
+///       kFIRParameterCurrency : @"USD",  // e.g. $9.50 USD
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterShipping NS_SWIFT_NAME(AnalyticsParameterShipping) = + @"shipping"; + +/// Sign up method (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterSignUpMethod : @"google",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterSignUpMethod NS_SWIFT_NAME(AnalyticsParameterSignUpMethod) = + @"sign_up_method"; + +/// The origin of your traffic, such as an Ad network (for example, google) or partner (urban +/// airship). Identify the advertiser, site, publication, etc. that is sending traffic to your +/// property. Highly recommended (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterSource : @"InMobi",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterSource NS_SWIFT_NAME(AnalyticsParameterSource) = @"source"; + +/// The departure date, check-in date or rental start date for the item. This should be in +/// YYYY-MM-DD format (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterStartDate : @"2015-09-14",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterStartDate NS_SWIFT_NAME(AnalyticsParameterStartDate) = + @"start_date"; + +/// Tax amount (double as NSNumber). +///
+///     NSDictionary *params = @{
+///       kFIRParameterTax : @(1.0),
+///       kFIRParameterCurrency : @"USD",  // e.g. $1.00 USD
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterTax NS_SWIFT_NAME(AnalyticsParameterTax) = @"tax"; + +/// If you're manually tagging keyword campaigns, you should use utm_term to specify the keyword +/// (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterTerm : @"game",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterTerm NS_SWIFT_NAME(AnalyticsParameterTerm) = @"term"; + +/// A single ID for a ecommerce group transaction (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterTransactionID : @"ab7236dd9823",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterTransactionID NS_SWIFT_NAME(AnalyticsParameterTransactionID) = + @"transaction_id"; + +/// Travel class (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterTravelClass : @"business",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterTravelClass NS_SWIFT_NAME(AnalyticsParameterTravelClass) = + @"travel_class"; + +/// A context-specific numeric value which is accumulated automatically for each event type. This is +/// a general purpose parameter that is useful for accumulating a key metric that pertains to an +/// event. Examples include revenue, distance, time and points. Value should be specified as signed +/// 64-bit integer or double as NSNumber. Notes: Values for pre-defined currency-related events +/// (such as @c kFIREventAddToCart) should be supplied using double as NSNumber and must be +/// accompanied by a @c kFIRParameterCurrency parameter. The valid range of accumulated values is +/// [-9,223,372,036,854.77, 9,223,372,036,854.77]. Supplying a non-numeric value, omitting the +/// corresponding @c kFIRParameterCurrency parameter, or supplying an invalid +/// currency code for conversion events will cause that +/// conversion to be omitted from reporting. +///
+///     NSDictionary *params = @{
+///       kFIRParameterValue : @(3.99),
+///       kFIRParameterCurrency : @"USD",  // e.g. $3.99 USD
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterValue NS_SWIFT_NAME(AnalyticsParameterValue) = @"value"; + +/// Name of virtual currency type (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterVirtualCurrencyName : @"virtual_currency_name",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterVirtualCurrencyName + NS_SWIFT_NAME(AnalyticsParameterVirtualCurrencyName) = @"virtual_currency_name"; + +/// The name of a level in a game (NSString). +///
+///     NSDictionary *params = @{
+///       kFIRParameterLevelName : @"room_1",
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterLevelName NS_SWIFT_NAME(AnalyticsParameterLevelName) = + @"level_name"; + +/// The result of an operation. Specify 1 to indicate success and 0 to indicate failure (unsigned +/// integer as NSNumber). +///
+///     NSDictionary *params = @{
+///       kFIRParameterSuccess : @(1),
+///       // ...
+///     };
+/// 
+static NSString *const kFIRParameterSuccess NS_SWIFT_NAME(AnalyticsParameterSuccess) = @"success"; diff --git a/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRUserPropertyNames.h b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRUserPropertyNames.h new file mode 100755 index 0000000..b984aa8 --- /dev/null +++ b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRUserPropertyNames.h @@ -0,0 +1,15 @@ +/// @file FIRUserPropertyNames.h +/// +/// Predefined user property names. +/// +/// A UserProperty is an attribute that describes the app-user. By supplying UserProperties, you can +/// later analyze different behaviors of various segments of your userbase. You may supply up to 25 +/// unique UserProperties per app, and you can use the name and value of your choosing for each one. +/// UserProperty names can be up to 24 characters long, may only contain alphanumeric characters and +/// underscores ("_"), and must start with an alphabetic character. UserProperty values can be up to +/// 36 characters long. The "firebase_", "google_", and "ga_" prefixes are reserved and should not +/// be used. + +/// The method used to sign in. For example, "google", "facebook" or "twitter". +static NSString *const kFIRUserPropertySignUpMethod + NS_SWIFT_NAME(AnalyticsUserPropertySignUpMethod) = @"sign_up_method"; diff --git a/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FirebaseAnalytics.h b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FirebaseAnalytics.h new file mode 100755 index 0000000..e1e96f6 --- /dev/null +++ b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FirebaseAnalytics.h @@ -0,0 +1,10 @@ +#import "FIRAnalyticsConfiguration.h" +#import "FIRApp.h" +#import "FIRConfiguration.h" +#import "FIROptions.h" +#import "FIRAnalytics+AppDelegate.h" +#import "FIRAnalytics.h" +#import "FIRAnalyticsSwiftNameSupport.h" +#import "FIREventNames.h" +#import "FIRParameterNames.h" +#import "FIRUserPropertyNames.h" diff --git a/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Modules/module.modulemap b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Modules/module.modulemap new file mode 100755 index 0000000..ef80595 --- /dev/null +++ b/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Modules/module.modulemap @@ -0,0 +1,10 @@ +framework module FirebaseAnalytics { + umbrella header "FirebaseAnalytics.h" + export * + module * { export *} + link "sqlite3" + link "z" + link framework "Security" + link framework "StoreKit" + link framework "SystemConfiguration" + link framework "UIKit"} diff --git a/Pods/FirebaseAnalytics/Frameworks/FirebaseCoreDiagnostics.framework/FirebaseCoreDiagnostics b/Pods/FirebaseAnalytics/Frameworks/FirebaseCoreDiagnostics.framework/FirebaseCoreDiagnostics new file mode 100755 index 0000000..22c3d9e Binary files /dev/null and b/Pods/FirebaseAnalytics/Frameworks/FirebaseCoreDiagnostics.framework/FirebaseCoreDiagnostics differ diff --git a/Pods/FirebaseAnalytics/Frameworks/FirebaseCoreDiagnostics.framework/Modules/module.modulemap b/Pods/FirebaseAnalytics/Frameworks/FirebaseCoreDiagnostics.framework/Modules/module.modulemap new file mode 100755 index 0000000..bbcb94e --- /dev/null +++ b/Pods/FirebaseAnalytics/Frameworks/FirebaseCoreDiagnostics.framework/Modules/module.modulemap @@ -0,0 +1,6 @@ +framework module FirebaseCoreDiagnostics { + export * + module * { export *} + link "z" + link framework "Security" + link framework "SystemConfiguration"} diff --git a/Pods/FirebaseAnalytics/Frameworks/FirebaseNanoPB.framework/FirebaseNanoPB b/Pods/FirebaseAnalytics/Frameworks/FirebaseNanoPB.framework/FirebaseNanoPB new file mode 100755 index 0000000..6f22b02 Binary files /dev/null and b/Pods/FirebaseAnalytics/Frameworks/FirebaseNanoPB.framework/FirebaseNanoPB differ diff --git a/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/FirebaseCore b/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/FirebaseCore new file mode 100755 index 0000000..2ba5cc9 Binary files /dev/null and b/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/FirebaseCore differ diff --git a/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/Headers/FIRAnalyticsConfiguration.h b/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/Headers/FIRAnalyticsConfiguration.h new file mode 100755 index 0000000..ca1d32c --- /dev/null +++ b/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/Headers/FIRAnalyticsConfiguration.h @@ -0,0 +1,52 @@ +/* + * Copyright 2017 Google + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + * This class provides configuration fields for Firebase Analytics. + */ +NS_SWIFT_NAME(AnalyticsConfiguration) +@interface FIRAnalyticsConfiguration : NSObject + +/** + * Returns the shared instance of FIRAnalyticsConfiguration. + */ ++ (FIRAnalyticsConfiguration *)sharedInstance NS_SWIFT_NAME(shared()); + +/** + * Sets the minimum engagement time in seconds required to start a new session. The default value + * is 10 seconds. + */ +- (void)setMinimumSessionInterval:(NSTimeInterval)minimumSessionInterval; + +/** + * Sets the interval of inactivity in seconds that terminates the current session. The default + * value is 1800 seconds (30 minutes). + */ +- (void)setSessionTimeoutInterval:(NSTimeInterval)sessionTimeoutInterval; + +/** + * Sets whether analytics collection is enabled for this app on this device. This setting is + * persisted across app sessions. By default it is enabled. + */ +- (void)setAnalyticsCollectionEnabled:(BOOL)analyticsCollectionEnabled; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/Headers/FIRApp.h b/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/Headers/FIRApp.h new file mode 100755 index 0000000..e0d852b --- /dev/null +++ b/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/Headers/FIRApp.h @@ -0,0 +1,130 @@ +/* + * Copyright 2017 Google + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + +#if TARGET_OS_IOS +// TODO: Remove UIKit import on next breaking change release +#import +#endif + +@class FIROptions; + +NS_ASSUME_NONNULL_BEGIN + +/** A block that takes a BOOL and has no return value. */ +typedef void (^FIRAppVoidBoolCallback)(BOOL success) NS_SWIFT_NAME(FirebaseAppVoidBoolCallback); + +/** + * The entry point of Firebase SDKs. + * + * Initialize and configure FIRApp using +[FIRApp configure] + * or other customized ways as shown below. + * + * The logging system has two modes: default mode and debug mode. In default mode, only logs with + * log level Notice, Warning and Error will be sent to device. In debug mode, all logs will be sent + * to device. The log levels that Firebase uses are consistent with the ASL log levels. + * + * Enable debug mode by passing the -FIRDebugEnabled argument to the application. You can add this + * argument in the application's Xcode scheme. When debug mode is enabled via -FIRDebugEnabled, + * further executions of the application will also be in debug mode. In order to return to default + * mode, you must explicitly disable the debug mode with the application argument -FIRDebugDisabled. + * + * It is also possible to change the default logging level in code by calling setLoggerLevel: on + * the FIRConfiguration interface. + */ +NS_SWIFT_NAME(FirebaseApp) +@interface FIRApp : NSObject + +/** + * Configures a default Firebase app. Raises an exception if any configuration step fails. The + * default app is named "__FIRAPP_DEFAULT". This method should be called after the app is launched + * and before using Firebase services. This method is thread safe. + */ ++ (void)configure; + +/** + * Configures the default Firebase app with the provided options. The default app is named + * "__FIRAPP_DEFAULT". Raises an exception if any configuration step fails. This method is thread + * safe. + * + * @param options The Firebase application options used to configure the service. + */ ++ (void)configureWithOptions:(FIROptions *)options NS_SWIFT_NAME(configure(options:)); + +/** + * Configures a Firebase app with the given name and options. Raises an exception if any + * configuration step fails. This method is thread safe. + * + * @param name The application's name given by the developer. The name should should only contain + Letters, Numbers and Underscore. + * @param options The Firebase application options used to configure the services. + */ +// clang-format off ++ (void)configureWithName:(NSString *)name + options:(FIROptions *)options NS_SWIFT_NAME(configure(name:options:)); +// clang-format on + +/** + * Returns the default app, or nil if the default app does not exist. + */ ++ (nullable FIRApp *)defaultApp NS_SWIFT_NAME(app()); + +/** + * Returns a previously created FIRApp instance with the given name, or nil if no such app exists. + * This method is thread safe. + */ ++ (nullable FIRApp *)appNamed:(NSString *)name NS_SWIFT_NAME(app(name:)); + +#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 +/** + * Returns the set of all extant FIRApp instances, or nil if there are no FIRApp instances. This + * method is thread safe. + */ +@property(class, readonly, nullable) NSDictionary *allApps; +#else +/** + * Returns the set of all extant FIRApp instances, or nil if there are no FIRApp instances. This + * method is thread safe. + */ ++ (nullable NSDictionary *)allApps NS_SWIFT_NAME(allApps()); +#endif // defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 + +/** + * Cleans up the current FIRApp, freeing associated data and returning its name to the pool for + * future use. This method is thread safe. + */ +- (void)deleteApp:(FIRAppVoidBoolCallback)completion; + +/** + * FIRApp instances should not be initialized directly. Call +[FIRApp configure], + * +[FIRApp configureWithOptions:], or +[FIRApp configureWithNames:options:] directly. + */ +- (instancetype)init NS_UNAVAILABLE; + +/** + * Gets the name of this app. + */ +@property(nonatomic, copy, readonly) NSString *name; + +/** + * Gets a copy of the options for this app. These are non-modifiable. + */ +@property(nonatomic, copy, readonly) FIROptions *options; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/Headers/FIRConfiguration.h b/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/Headers/FIRConfiguration.h new file mode 100755 index 0000000..05bd261 --- /dev/null +++ b/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/Headers/FIRConfiguration.h @@ -0,0 +1,78 @@ +/* + * Copyright 2017 Google + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + +#import "FIRAnalyticsConfiguration.h" +#import "FIRLoggerLevel.h" + +/** + * The log levels used by FIRConfiguration. + */ +typedef NS_ENUM(NSInteger, FIRLogLevel) { + /** Error */ + kFIRLogLevelError __deprecated = 0, + /** Warning */ + kFIRLogLevelWarning __deprecated, + /** Info */ + kFIRLogLevelInfo __deprecated, + /** Debug */ + kFIRLogLevelDebug __deprecated, + /** Assert */ + kFIRLogLevelAssert __deprecated, + /** Max */ + kFIRLogLevelMax __deprecated = kFIRLogLevelAssert +} DEPRECATED_MSG_ATTRIBUTE( + "Use -FIRDebugEnabled and -FIRDebugDisabled or setLoggerLevel. See FIRApp.h for more details."); + +NS_ASSUME_NONNULL_BEGIN + +/** + * This interface provides global level properties that the developer can tweak, and the singleton + * of the Firebase Analytics configuration class. + */ +NS_SWIFT_NAME(FirebaseConfiguration) +@interface FIRConfiguration : NSObject + +#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 +/** Returns the shared configuration object. */ +@property(class, nonatomic, readonly) FIRConfiguration *sharedInstance NS_SWIFT_NAME(shared); +#else +/** Returns the shared configuration object. */ ++ (FIRConfiguration *)sharedInstance NS_SWIFT_NAME(shared()); +#endif // defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 + +/** The configuration class for Firebase Analytics. */ +@property(nonatomic, readwrite) FIRAnalyticsConfiguration *analyticsConfiguration; + +/** Global log level. Defaults to kFIRLogLevelError. */ +@property(nonatomic, readwrite, assign) FIRLogLevel logLevel DEPRECATED_MSG_ATTRIBUTE( + "Use -FIRDebugEnabled and -FIRDebugDisabled or setLoggerLevel. See FIRApp.h for more details."); + +/** + * Sets the logging level for internal Firebase logging. Firebase will only log messages + * that are logged at or below loggerLevel. The messages are logged both to the Xcode + * console and to the device's log. Note that if an app is running from AppStore, it will + * never log above FIRLoggerLevelNotice even if loggerLevel is set to a higher (more verbose) + * setting. + * + * @param loggerLevel The maximum logging level. The default level is set to FIRLoggerLevelNotice. + */ +- (void)setLoggerLevel:(FIRLoggerLevel)loggerLevel; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/Headers/FIRLoggerLevel.h b/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/Headers/FIRLoggerLevel.h new file mode 100755 index 0000000..8b6579f --- /dev/null +++ b/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/Headers/FIRLoggerLevel.h @@ -0,0 +1,35 @@ +/* + * Copyright 2017 Google + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * The log levels used by internal logging. + */ +typedef NS_ENUM(NSInteger, FIRLoggerLevel) { + /** Error level, matches ASL_LEVEL_ERR. */ + FIRLoggerLevelError = 3, + /** Warning level, matches ASL_LEVEL_WARNING. */ + FIRLoggerLevelWarning = 4, + /** Notice level, matches ASL_LEVEL_NOTICE. */ + FIRLoggerLevelNotice = 5, + /** Info level, matches ASL_LEVEL_NOTICE. */ + FIRLoggerLevelInfo = 6, + /** Debug level, matches ASL_LEVEL_DEBUG. */ + FIRLoggerLevelDebug = 7, + /** Minimum log level. */ + FIRLoggerLevelMin = FIRLoggerLevelError, + /** Maximum log level. */ + FIRLoggerLevelMax = FIRLoggerLevelDebug +} NS_SWIFT_NAME(FirebaseLoggerLevel); diff --git a/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/Headers/FIROptions.h b/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/Headers/FIROptions.h new file mode 100755 index 0000000..eba0657 --- /dev/null +++ b/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/Headers/FIROptions.h @@ -0,0 +1,133 @@ +/* + * Copyright 2017 Google + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + * This class provides constant fields of Google APIs. + */ +NS_SWIFT_NAME(FirebaseOptions) +@interface FIROptions : NSObject + +/** + * Returns the default options. + */ ++ (nullable FIROptions *)defaultOptions NS_SWIFT_NAME(defaultOptions()); + +/** + * An iOS API key used for authenticating requests from your app, e.g. + * @"AIzaSyDdVgKwhZl0sTTTLZ7iTmt1r3N2cJLnaDk", used to identify your app to Google servers. + */ +@property(nonatomic, copy, nullable) NSString *APIKey NS_SWIFT_NAME(apiKey); + +/** + * The bundle ID for the application. Defaults to `[[NSBundle mainBundle] bundleID]` when not set + * manually or in a plist. + */ +@property(nonatomic, copy) NSString *bundleID; + +/** + * The OAuth2 client ID for iOS application used to authenticate Google users, for example + * @"12345.apps.googleusercontent.com", used for signing in with Google. + */ +@property(nonatomic, copy, nullable) NSString *clientID; + +/** + * The tracking ID for Google Analytics, e.g. @"UA-12345678-1", used to configure Google Analytics. + */ +@property(nonatomic, copy, nullable) NSString *trackingID; + +/** + * The Project Number from the Google Developer's console, for example @"012345678901", used to + * configure Google Cloud Messaging. + */ +@property(nonatomic, copy) NSString *GCMSenderID NS_SWIFT_NAME(gcmSenderID); + +/** + * The Project ID from the Firebase console, for example @"abc-xyz-123". + */ +@property(nonatomic, copy, nullable) NSString *projectID; + +/** + * The Android client ID used in Google AppInvite when an iOS app has its Android version, for + * example @"12345.apps.googleusercontent.com". + */ +@property(nonatomic, copy, nullable) NSString *androidClientID; + +/** + * The Google App ID that is used to uniquely identify an instance of an app. + */ +@property(nonatomic, copy) NSString *googleAppID; + +/** + * The database root URL, e.g. @"http://abc-xyz-123.firebaseio.com". + */ +@property(nonatomic, copy, nullable) NSString *databaseURL; + +/** + * The URL scheme used to set up Durable Deep Link service. + */ +@property(nonatomic, copy, nullable) NSString *deepLinkURLScheme; + +/** + * The Google Cloud Storage bucket name, e.g. @"abc-xyz-123.storage.firebase.com". + */ +@property(nonatomic, copy, nullable) NSString *storageBucket; + +/** + * Initializes a customized instance of FIROptions with keys. googleAppID, bundleID and GCMSenderID + * are required. Other keys may required for configuring specific services. + */ +- (instancetype)initWithGoogleAppID:(NSString *)googleAppID + bundleID:(NSString *)bundleID + GCMSenderID:(NSString *)GCMSenderID + APIKey:(NSString *)APIKey + clientID:(NSString *)clientID + trackingID:(NSString *)trackingID + androidClientID:(NSString *)androidClientID + databaseURL:(NSString *)databaseURL + storageBucket:(NSString *)storageBucket + deepLinkURLScheme:(NSString *)deepLinkURLScheme + DEPRECATED_MSG_ATTRIBUTE( + "Use `-[[FIROptions alloc] initWithGoogleAppID:GCMSenderID:]` " + "(`FirebaseOptions(googleAppID:gcmSenderID:)` in Swift)` and property " + "setters instead."); + +/** + * Initializes a customized instance of FIROptions from the file at the given plist file path. + * For example, + * NSString *filePath = + * [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"]; + * FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:filePath]; + * Returns nil if the plist file does not exist or is invalid. + */ +- (nullable instancetype)initWithContentsOfFile:(NSString *)plistPath; + +/** + * Initializes a customized instance of FIROptions with required fields. Use the mutable properties + * to modify fields for configuring specific services. + */ +// clang-format off +- (instancetype)initWithGoogleAppID:(NSString *)googleAppID + GCMSenderID:(NSString *)GCMSenderID + NS_SWIFT_NAME(init(googleAppID:gcmSenderID:)); +// clang-format on + +@end + +NS_ASSUME_NONNULL_END diff --git a/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/Headers/FirebaseCore.h b/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/Headers/FirebaseCore.h new file mode 100755 index 0000000..52a222f --- /dev/null +++ b/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/Headers/FirebaseCore.h @@ -0,0 +1,5 @@ +#import "FIRAnalyticsConfiguration.h" +#import "FIRApp.h" +#import "FIRConfiguration.h" +#import "FIRLoggerLevel.h" +#import "FIROptions.h" diff --git a/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/Modules/module.modulemap b/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/Modules/module.modulemap new file mode 100755 index 0000000..4865717 --- /dev/null +++ b/Pods/FirebaseCore/Frameworks/FirebaseCore.framework/Modules/module.modulemap @@ -0,0 +1,7 @@ +framework module FirebaseCore { + umbrella header "FirebaseCore.h" + export * + module * { export *} + link "z" + link framework "Security" + link framework "SystemConfiguration"} diff --git a/Pods/FirebaseInstanceID/CHANGELOG.md b/Pods/FirebaseInstanceID/CHANGELOG.md new file mode 100755 index 0000000..323a8e0 --- /dev/null +++ b/Pods/FirebaseInstanceID/CHANGELOG.md @@ -0,0 +1,98 @@ +# 2018-02-06 -- v2.0.9 +- Improved support for language targeting for FCM service. Server updates happen more efficiently when language changes. +- Improved support for FCM token auto generation enable/disable functions. + +# 2017-12-11 -- v2.0.8 +- Fixed a crash caused by a reflection call during logging. +- Updating server with the latest parameters and deprecating old ones. + +# 2017-11-27 -- v2.0.7 +- Improve identity reset process, ensuring all information is reset during Identity deletion. + +# 2017-11-06 -- v2.0.6 +- Make token refresh weekly. +- Fixed a crash when performing token operation. + +# 2017-10-11 -- v2.0.5 +- Improved support for working in shared Keychain environments. + +# 2017-09-26 -- v2.0.4 +- Fixed an issue where the FCM token was not associating correctly with an APNs + device token, depending on when the APNs device token was made available. +- Fixed an issue where FCM tokens for different Sender IDs were not associating + correctly with an APNs device token. +- Fixed an issue that was preventing the FCM direct channel from being + established on the first start after 24 hours of being opened. + +# 2017-09-13 -- v2.0.3 +- Fixed a race condition where a token was not being generated on first start, + if Firebase Messaging was included and the app did not register for remote + notifications. + +# 2017-08-25 -- v2.0.2 +- Fixed a startup performance regression, removing a call which was blocking the + main thread. + +# 2017-08-07 -- v2.0.1 +- Fixed issues with token and app identifier being inaccessible when the device + is locked. +- Fixed a crash if bundle identifier is nil, which is possible in some testing + environments. +- Fixed a small memory leak fetching a new token. +- Moved to a new and simplified token storage system. +- Moved to a new queuing system for token fetches and deletes. +- Simplified logic and code around configuration and logging. +- Added clarification about the 'apns_sandbox' parameter, in header comments. + +# 2017-05-08 -- v2.0.0 +- Introduced an improved interface for Swift 3 developers +- Deprecated some methods and properties after moving their logic to the + Firebase Cloud Messaging SDK +- Fixed an intermittent stability issue when a debug build of an app was + replaced with a release build of the same version +- Removed swizzling logic that was sometimes resulting in developers receiving + a validation notice about enabling push notification capabilities, even though + they weren't using push notifications +- Fixed a notification that would sometimes fire twice in quick succession + during the first run of an app + +# 2017-03-31 -- v1.0.10 + +- Improvements to token-fetching logic +- Fixed some warnings in Instance ID +- Improved error messages if Instance ID couldn't be initialized properly +- Improvements to console logging + +# 2017-01-31 -- v1.0.9 + +- Removed an error being mistakenly logged to the console. + +# 2016-07-06 -- v1.0.8 + +- Don't store InstanceID plists in Documents folder. + +# 2016-06-19 -- v1.0.7 + +- Fix remote-notifications warning on app submission. + +# 2016-05-16 -- v1.0.6 + +- Fix CocoaPod linter issues for InstanceID pod. + +# 2016-05-13 -- v1.0.5 + +- Fix Authorization errors for InstanceID tokens. + +# 2016-05-11 -- v1.0.4 + +- Reduce wait for InstanceID token during parallel requests. + +# 2016-04-18 -- v1.0.3 + +- Change flag to disable swizzling to *FirebaseAppDelegateProxyEnabled*. +- Fix incessant Keychain errors while accessing InstanceID. +- Fix max retries for fetching IID token. + +# 2016-04-18 -- v1.0.2 + +- Register for remote notifications on iOS8+ in the SDK itself. diff --git a/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/FirebaseInstanceID b/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/FirebaseInstanceID new file mode 100755 index 0000000..3110a9f Binary files /dev/null and b/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/FirebaseInstanceID differ diff --git a/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/Headers/FIRInstanceID.h b/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/Headers/FIRInstanceID.h new file mode 100755 index 0000000..1268c13 --- /dev/null +++ b/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/Headers/FIRInstanceID.h @@ -0,0 +1,276 @@ +#import + +/** + * @memberof FIRInstanceID + * + * The scope to be used when fetching/deleting a token for Firebase Messaging. + */ +FOUNDATION_EXPORT NSString * __nonnull const kFIRInstanceIDScopeFirebaseMessaging + NS_SWIFT_NAME(InstanceIDScopeFirebaseMessaging); + +#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 +/** + * Called when the system determines that tokens need to be refreshed. + * This method is also called if Instance ID has been reset in which + * case, tokens and FCM topic subscriptions also need to be refreshed. + * + * Instance ID service will throttle the refresh event across all devices + * to control the rate of token updates on application servers. + */ +FOUNDATION_EXPORT const NSNotificationName __nonnull kFIRInstanceIDTokenRefreshNotification + NS_SWIFT_NAME(InstanceIDTokenRefresh); +#else +/** + * Called when the system determines that tokens need to be refreshed. + * This method is also called if Instance ID has been reset in which + * case, tokens and FCM topic subscriptions also need to be refreshed. + * + * Instance ID service will throttle the refresh event across all devices + * to control the rate of token updates on application servers. + */ +FOUNDATION_EXPORT NSString * __nonnull const kFIRInstanceIDTokenRefreshNotification + NS_SWIFT_NAME(InstanceIDTokenRefreshNotification); +#endif // defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 + +/** + * @related FIRInstanceID + * + * The completion handler invoked when the InstanceID token returns. If + * the call fails we return the appropriate `error code` as described below. + * + * @param token The valid token as returned by InstanceID backend. + * + * @param error The error describing why generating a new token + * failed. See the error codes below for a more detailed + * description. + */ +typedef void(^FIRInstanceIDTokenHandler)( NSString * __nullable token, NSError * __nullable error) + NS_SWIFT_NAME(InstanceIDTokenHandler); + + +/** + * @related FIRInstanceID + * + * The completion handler invoked when the InstanceID `deleteToken` returns. If + * the call fails we return the appropriate `error code` as described below + * + * @param error The error describing why deleting the token failed. + * See the error codes below for a more detailed description. + */ +typedef void(^FIRInstanceIDDeleteTokenHandler)(NSError * __nullable error) + NS_SWIFT_NAME(InstanceIDDeleteTokenHandler); + +/** + * @related FIRInstanceID + * + * The completion handler invoked when the app identity is created. If the + * identity wasn't created for some reason we return the appropriate error code. + * + * @param identity A valid identity for the app instance, nil if there was an error + * while creating an identity. + * @param error The error if fetching the identity fails else nil. + */ +typedef void(^FIRInstanceIDHandler)(NSString * __nullable identity, NSError * __nullable error) + NS_SWIFT_NAME(InstanceIDHandler); + +/** + * @related FIRInstanceID + * + * The completion handler invoked when the app identity and all the tokens associated + * with it are deleted. Returns a valid error object in case of failure else nil. + * + * @param error The error if deleting the identity and all the tokens associated with + * it fails else nil. + */ +typedef void(^FIRInstanceIDDeleteHandler)(NSError * __nullable error) + NS_SWIFT_NAME(InstanceIDDeleteHandler); + +/** + * Public errors produced by InstanceID. + */ +typedef NS_ENUM(NSUInteger, FIRInstanceIDError) { + // Http related errors. + + /// Unknown error. + FIRInstanceIDErrorUnknown = 0, + + /// Auth Error -- GCM couldn't validate request from this client. + FIRInstanceIDErrorAuthentication = 1, + + /// NoAccess -- InstanceID service cannot be accessed. + FIRInstanceIDErrorNoAccess = 2, + + /// Timeout -- Request to InstanceID backend timed out. + FIRInstanceIDErrorTimeout = 3, + + /// Network -- No network available to reach the servers. + FIRInstanceIDErrorNetwork = 4, + + /// OperationInProgress -- Another similar operation in progress, + /// bailing this one. + FIRInstanceIDErrorOperationInProgress = 5, + + /// InvalidRequest -- Some parameters of the request were invalid. + FIRInstanceIDErrorInvalidRequest = 7, +} NS_SWIFT_NAME(InstanceIDError); + +/** + * The APNS token type for the app. If the token type is set to `UNKNOWN` + * InstanceID will implicitly try to figure out what the actual token type + * is from the provisioning profile. + */ +typedef NS_ENUM(NSInteger, FIRInstanceIDAPNSTokenType) { + /// Unknown token type. + FIRInstanceIDAPNSTokenTypeUnknown, + /// Sandbox token type. + FIRInstanceIDAPNSTokenTypeSandbox, + /// Production token type. + FIRInstanceIDAPNSTokenTypeProd, +} NS_SWIFT_NAME(InstanceIDAPNSTokenType) + __deprecated_enum_msg("Use FIRMessaging's APNSToken property instead."); + +/** + * Instance ID provides a unique identifier for each app instance and a mechanism + * to authenticate and authorize actions (for example, sending an FCM message). + * + * Instance ID is long lived but, may be reset if the device is not used for + * a long time or the Instance ID service detects a problem. + * If Instance ID is reset, the app will be notified via + * `kFIRInstanceIDTokenRefreshNotification`. + * + * If the Instance ID has become invalid, the app can request a new one and + * send it to the app server. + * To prove ownership of Instance ID and to allow servers to access data or + * services associated with the app, call + * `[FIRInstanceID tokenWithAuthorizedEntity:scope:options:handler]`. + */ +NS_SWIFT_NAME(InstanceID) +@interface FIRInstanceID : NSObject + +/** + * FIRInstanceID. + * + * @return A shared instance of FIRInstanceID. + */ ++ (nonnull instancetype)instanceID NS_SWIFT_NAME(instanceID()); + +/** + * Unavailable. Use +instanceID instead. + */ +- (nonnull instancetype)init __attribute__((unavailable("Use +instanceID instead."))); + +/** + * Set APNS token for the application. This APNS token will be used to register + * with Firebase Messaging using `token` or + * `tokenWithAuthorizedEntity:scope:options:handler`. If the token type is set to + * `FIRInstanceIDAPNSTokenTypeUnknown` InstanceID will read the provisioning profile + * to find out the token type. + * + * @param token The APNS token for the application. + * @param type The APNS token type for the above token. + */ +- (void)setAPNSToken:(nonnull NSData *)token + type:(FIRInstanceIDAPNSTokenType)type + __deprecated_msg("Use FIRMessaging's APNSToken property instead."); + +#pragma mark - Tokens + +/** + * Returns a Firebase Messaging scoped token for the firebase app. + * + * @return Null Returns null if the device has not yet been registerd with + * Firebase Message else returns a valid token. + */ +- (nullable NSString *)token; + +/** + * Returns a token that authorizes an Entity (example: cloud service) to perform + * an action on behalf of the application identified by Instance ID. + * + * This is similar to an OAuth2 token except, it applies to the + * application instance instead of a user. + * + * This is an asynchronous call. If the token fetching fails for some reason + * we invoke the completion callback with nil `token` and the appropriate + * error. + * + * Note, you can only have one `token` or `deleteToken` call for a given + * authorizedEntity and scope at any point of time. Making another such call with the + * same authorizedEntity and scope before the last one finishes will result in an + * error with code `OperationInProgress`. + * + * @see FIRInstanceID deleteTokenWithAuthorizedEntity:scope:handler: + * + * @param authorizedEntity Entity authorized by the token. + * @param scope Action authorized for authorizedEntity. + * @param options The extra options to be sent with your token request. The + * value for the `apns_token` should be the NSData object + * passed to the UIApplicationDelegate's + * `didRegisterForRemoteNotificationsWithDeviceToken` method. + * The value for `apns_sandbox` should be a boolean (or an + * NSNumber representing a BOOL in Objective C) set to true if + * your app is a debug build, which means that the APNs + * device token is for the sandbox environment. It should be + * set to false otherwise. If the `apns_sandbox` key is not + * provided, an automatically-detected value shall be used. + * @param handler The callback handler which is invoked when the token is + * successfully fetched. In case of success a valid `token` and + * `nil` error are returned. In case of any error the `token` + * is nil and a valid `error` is returned. The valid error + * codes have been documented above. + */ +- (void)tokenWithAuthorizedEntity:(nonnull NSString *)authorizedEntity + scope:(nonnull NSString *)scope + options:(nullable NSDictionary *)options + handler:(nonnull FIRInstanceIDTokenHandler)handler; + +/** + * Revokes access to a scope (action) for an entity previously + * authorized by `[FIRInstanceID tokenWithAuthorizedEntity:scope:options:handler]`. + * + * This is an asynchronous call. Call this on the main thread since InstanceID lib + * is not thread safe. In case token deletion fails for some reason we invoke the + * `handler` callback passed in with the appropriate error code. + * + * Note, you can only have one `token` or `deleteToken` call for a given + * authorizedEntity and scope at a point of time. Making another such call with the + * same authorizedEntity and scope before the last one finishes will result in an error + * with code `OperationInProgress`. + * + * @param authorizedEntity Entity that must no longer have access. + * @param scope Action that entity is no longer authorized to perform. + * @param handler The handler that is invoked once the unsubscribe call ends. + * In case of error an appropriate error object is returned + * else error is nil. + */ +- (void)deleteTokenWithAuthorizedEntity:(nonnull NSString *)authorizedEntity + scope:(nonnull NSString *)scope + handler:(nonnull FIRInstanceIDDeleteTokenHandler)handler; + +#pragma mark - Identity + +/** + * Asynchronously fetch a stable identifier that uniquely identifies the app + * instance. If the identifier has been revoked or has expired, this method will + * return a new identifier. + * + * + * @param handler The handler to invoke once the identifier has been fetched. + * In case of error an appropriate error object is returned else + * a valid identifier is returned and a valid identifier for the + * application instance. + */ +- (void)getIDWithHandler:(nonnull FIRInstanceIDHandler)handler + NS_SWIFT_NAME(getID(handler:)); + +/** + * Resets Instance ID and revokes all tokens. + * + * This method also triggers a request to fetch a new Instance ID and Firebase Messaging scope + * token. Please listen to kFIRInstanceIDTokenRefreshNotification when the new ID and token are + * ready. + */ +- (void)deleteIDWithHandler:(nonnull FIRInstanceIDDeleteHandler)handler + NS_SWIFT_NAME(deleteID(handler:)); + +@end diff --git a/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/Headers/FirebaseInstanceID.h b/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/Headers/FirebaseInstanceID.h new file mode 100755 index 0000000..053ec2b --- /dev/null +++ b/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/Headers/FirebaseInstanceID.h @@ -0,0 +1 @@ +#import "FIRInstanceID.h" diff --git a/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/Modules/module.modulemap b/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/Modules/module.modulemap new file mode 100755 index 0000000..6ab7f1b --- /dev/null +++ b/Pods/FirebaseInstanceID/Frameworks/FirebaseInstanceID.framework/Modules/module.modulemap @@ -0,0 +1,7 @@ +framework module FirebaseInstanceID { + umbrella header "FirebaseInstanceID.h" + export * + module * { export *} + link "z" + link framework "Security" + link framework "SystemConfiguration"} diff --git a/Pods/FirebaseInstanceID/README.md b/Pods/FirebaseInstanceID/README.md new file mode 100755 index 0000000..25fe219 --- /dev/null +++ b/Pods/FirebaseInstanceID/README.md @@ -0,0 +1,10 @@ +# InstanceID SDK for iOS + +Instance ID provides a unique ID per instance of your apps and also provides a +mechanism to authenticate and authorize actions, like sending messages via +Firebase Cloud Messaging (FCM). + + +Please visit [our developer +site](https://developers.google.com/instance-id/) for integration instructions, +documentation, support information, and terms of service. diff --git a/Pods/FirebaseMessaging/Frameworks/FirebaseMessaging.framework/FirebaseMessaging b/Pods/FirebaseMessaging/Frameworks/FirebaseMessaging.framework/FirebaseMessaging new file mode 100755 index 0000000..96ca0fc Binary files /dev/null and b/Pods/FirebaseMessaging/Frameworks/FirebaseMessaging.framework/FirebaseMessaging differ diff --git a/Pods/FirebaseMessaging/Frameworks/FirebaseMessaging.framework/Headers/FIRMessaging.h b/Pods/FirebaseMessaging/Frameworks/FirebaseMessaging.framework/Headers/FIRMessaging.h new file mode 100755 index 0000000..31e8625 --- /dev/null +++ b/Pods/FirebaseMessaging/Frameworks/FirebaseMessaging.framework/Headers/FIRMessaging.h @@ -0,0 +1,513 @@ +/* + * Copyright 2017 Google + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + +/** + * @related FIRMessaging + * + * The completion handler invoked when the registration token returns. + * If the call fails we return the appropriate `error code`, described by + * `FIRMessagingError`. + * + * @param FCMToken The valid registration token returned by FCM. + * @param error The error describing why a token request failed. The error code + * will match a value from the FIRMessagingError enumeration. + */ +typedef void(^FIRMessagingFCMTokenFetchCompletion)(NSString * _Nullable FCMToken, + NSError * _Nullable error) + NS_SWIFT_NAME(MessagingFCMTokenFetchCompletion); + + +/** + * @related FIRMessaging + * + * The completion handler invoked when the registration token deletion request is + * completed. If the call fails we return the appropriate `error code`, described + * by `FIRMessagingError`. + * + * @param error The error describing why a token deletion failed. The error code + * will match a value from the FIRMessagingError enumeration. + */ +typedef void(^FIRMessagingDeleteFCMTokenCompletion)(NSError * _Nullable error) + NS_SWIFT_NAME(MessagingDeleteFCMTokenCompletion); + +/** + * The completion handler invoked once the data connection with FIRMessaging is + * established. The data connection is used to send a continous stream of + * data and all the FIRMessaging data notifications arrive through this connection. + * Once the connection is established we invoke the callback with `nil` error. + * Correspondingly if we get an error while trying to establish a connection + * we invoke the handler with an appropriate error object and do an + * exponential backoff to try and connect again unless successful. + * + * @param error The error object if any describing why the data connection + * to FIRMessaging failed. + */ +typedef void(^FIRMessagingConnectCompletion)(NSError * __nullable error) + NS_SWIFT_NAME(MessagingConnectCompletion) + __deprecated_msg("Please listen for the FIRMessagingConnectionStateChangedNotification " + "NSNotification instead."); + +#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 +/** + * Notification sent when the upstream message has been delivered + * successfully to the server. The notification object will be the messageID + * of the successfully delivered message. + */ +FOUNDATION_EXPORT const NSNotificationName __nonnull FIRMessagingSendSuccessNotification + NS_SWIFT_NAME(MessagingSendSuccess); + +/** + * Notification sent when the upstream message was failed to be sent to the + * server. The notification object will be the messageID of the failed + * message. The userInfo dictionary will contain the relevant error + * information for the failure. + */ +FOUNDATION_EXPORT const NSNotificationName __nonnull FIRMessagingSendErrorNotification + NS_SWIFT_NAME(MessagingSendError); + +/** + * Notification sent when the Firebase messaging server deletes pending + * messages due to exceeded storage limits. This may occur, for example, when + * the device cannot be reached for an extended period of time. + * + * It is recommended to retrieve any missing messages directly from the + * server. + */ +FOUNDATION_EXPORT const NSNotificationName __nonnull FIRMessagingMessagesDeletedNotification + NS_SWIFT_NAME(MessagingMessagesDeleted); + +/** + * Notification sent when Firebase Messaging establishes or disconnects from + * an FCM socket connection. You can query the connection state in this + * notification by checking the `isDirectChannelEstablished` property of FIRMessaging. + */ +FOUNDATION_EXPORT const NSNotificationName __nonnull FIRMessagingConnectionStateChangedNotification + NS_SWIFT_NAME(MessagingConnectionStateChanged); + +/** + * Notification sent when the FCM registration token has been refreshed. Please use the + * FIRMessaging delegate method `messaging:didReceiveRegistrationToken:` to receive current and + * updated tokens. + */ +FOUNDATION_EXPORT const NSNotificationName __nonnull + FIRMessagingRegistrationTokenRefreshedNotification + NS_SWIFT_NAME(MessagingRegistrationTokenRefreshed); +#else +/** + * Notification sent when the upstream message has been delivered + * successfully to the server. The notification object will be the messageID + * of the successfully delivered message. + */ +FOUNDATION_EXPORT NSString * __nonnull const FIRMessagingSendSuccessNotification + NS_SWIFT_NAME(MessagingSendSuccessNotification); + +/** + * Notification sent when the upstream message was failed to be sent to the + * server. The notification object will be the messageID of the failed + * message. The userInfo dictionary will contain the relevant error + * information for the failure. + */ +FOUNDATION_EXPORT NSString * __nonnull const FIRMessagingSendErrorNotification + NS_SWIFT_NAME(MessagingSendErrorNotification); + +/** + * Notification sent when the Firebase messaging server deletes pending + * messages due to exceeded storage limits. This may occur, for example, when + * the device cannot be reached for an extended period of time. + * + * It is recommended to retrieve any missing messages directly from the + * server. + */ +FOUNDATION_EXPORT NSString * __nonnull const FIRMessagingMessagesDeletedNotification + NS_SWIFT_NAME(MessagingMessagesDeletedNotification); + +/** + * Notification sent when Firebase Messaging establishes or disconnects from + * an FCM socket connection. You can query the connection state in this + * notification by checking the `isDirectChannelEstablished` property of FIRMessaging. + */ +FOUNDATION_EXPORT NSString * __nonnull const FIRMessagingConnectionStateChangedNotification + NS_SWIFT_NAME(MessagingConnectionStateChangedNotification); + +/** + * Notification sent when the FCM registration token has been refreshed. Please use the + * FIRMessaging delegate method `messaging:didReceiveRegistrationToken:` to receive current and + * updated tokens. + */ +FOUNDATION_EXPORT NSString * __nonnull const FIRMessagingRegistrationTokenRefreshedNotification + NS_SWIFT_NAME(MessagingRegistrationTokenRefreshedNotification); +#endif // defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 + +/** + * @enum FIRMessagingError + */ +typedef NS_ENUM(NSUInteger, FIRMessagingError) { + /// Unknown error. + FIRMessagingErrorUnknown = 0, + + /// FIRMessaging couldn't validate request from this client. + FIRMessagingErrorAuthentication = 1, + + /// InstanceID service cannot be accessed. + FIRMessagingErrorNoAccess = 2, + + /// Request to InstanceID backend timed out. + FIRMessagingErrorTimeout = 3, + + /// No network available to reach the servers. + FIRMessagingErrorNetwork = 4, + + /// Another similar operation in progress, bailing this one. + FIRMessagingErrorOperationInProgress = 5, + + /// Some parameters of the request were invalid. + FIRMessagingErrorInvalidRequest = 7, +} NS_SWIFT_NAME(MessagingError); + +/// Status for the downstream message received by the app. +typedef NS_ENUM(NSInteger, FIRMessagingMessageStatus) { + /// Unknown status. + FIRMessagingMessageStatusUnknown, + /// New downstream message received by the app. + FIRMessagingMessageStatusNew, +} NS_SWIFT_NAME(MessagingMessageStatus); + +/** + * The APNS token type for the app. If the token type is set to `UNKNOWN` + * Firebase Messaging will implicitly try to figure out what the actual token type + * is from the provisioning profile. + * Unless you really need to specify the type, you should use the `APNSToken` + * property instead. + */ +typedef NS_ENUM(NSInteger, FIRMessagingAPNSTokenType) { + /// Unknown token type. + FIRMessagingAPNSTokenTypeUnknown, + /// Sandbox token type. + FIRMessagingAPNSTokenTypeSandbox, + /// Production token type. + FIRMessagingAPNSTokenTypeProd, +} NS_SWIFT_NAME(MessagingAPNSTokenType); + +/// Information about a downstream message received by the app. +NS_SWIFT_NAME(MessagingMessageInfo) +@interface FIRMessagingMessageInfo : NSObject + +/// The status of the downstream message +@property(nonatomic, readonly, assign) FIRMessagingMessageStatus status; + +@end + +/** + * A remote data message received by the app via FCM (not just the APNs interface). + * + * This is only for devices running iOS 10 or above. To support devices running iOS 9 or below, use + * the local and remote notifications handlers defined in UIApplicationDelegate protocol. + */ +NS_SWIFT_NAME(MessagingRemoteMessage) +@interface FIRMessagingRemoteMessage : NSObject + +/// The downstream message received by the application. +@property(nonatomic, readonly, strong, nonnull) NSDictionary *appData; +@end + +@class FIRMessaging; +/** + * A protocol to handle events from FCM for devices running iOS 10 or above. + * + * To support devices running iOS 9 or below, use the local and remote notifications handlers + * defined in UIApplicationDelegate protocol. + */ +NS_SWIFT_NAME(MessagingDelegate) +@protocol FIRMessagingDelegate + +@optional +/// This method will be called once a token is available, or has been refreshed. Typically it +/// will be called once per app start, but may be called more often, if token is invalidated or +/// updated. In this method, you should perform operations such as: +/// +/// * Uploading the FCM token to your application server, so targeted notifications can be sent. +/// +/// * Subscribing to any topics. +- (void)messaging:(nonnull FIRMessaging *)messaging + didReceiveRegistrationToken:(nonnull NSString *)fcmToken + NS_SWIFT_NAME(messaging(_:didReceiveRegistrationToken:)); + +/// This method will be called whenever FCM receives a new, default FCM token for your +/// Firebase project's Sender ID. This method is deprecated. Please use +/// `messaging:didReceiveRegistrationToken:`. +- (void)messaging:(nonnull FIRMessaging *)messaging + didRefreshRegistrationToken:(nonnull NSString *)fcmToken + NS_SWIFT_NAME(messaging(_:didRefreshRegistrationToken:)) + __deprecated_msg("Please use messaging:didReceiveRegistrationToken:, which is called for both \ + current and refreshed tokens."); + +/// This method is called on iOS 10 devices to handle data messages received via FCM through its +/// direct channel (not via APNS). For iOS 9 and below, the FCM data message is delivered via the +/// UIApplicationDelegate's -application:didReceiveRemoteNotification: method. +- (void)messaging:(nonnull FIRMessaging *)messaging + didReceiveMessage:(nonnull FIRMessagingRemoteMessage *)remoteMessage + NS_SWIFT_NAME(messaging(_:didReceive:)) + __IOS_AVAILABLE(10.0); + +/// The callback to handle data message received via FCM for devices running iOS 10 or above. +- (void)applicationReceivedRemoteMessage:(nonnull FIRMessagingRemoteMessage *)remoteMessage + NS_SWIFT_NAME(application(received:)) + __deprecated_msg("Use FIRMessagingDelegate’s -messaging:didReceiveMessage:"); + +@end + +/** + * Firebase Messaging lets you reliably deliver messages at no cost. + * + * To send or receive messages, the app must get a + * registration token from FIRInstanceID. This token authorizes an + * app server to send messages to an app instance. + * + * In order to receive FIRMessaging messages, declare `application:didReceiveRemoteNotification:`. + */ +NS_SWIFT_NAME(Messaging) +@interface FIRMessaging : NSObject + +/** + * Delegate to handle FCM token refreshes, and remote data messages received via FCM for devices + * running iOS 10 or above. + */ +@property(nonatomic, weak, nullable) id delegate; + +/** + * Delegate to handle remote data messages received via FCM for devices running iOS 10 or above. + */ +@property(nonatomic, weak, nullable) id remoteMessageDelegate + __deprecated_msg("Use 'delegate' property"); + +/** + * When set to `YES`, Firebase Messaging will automatically establish a socket-based, direct + * channel to the FCM server. Enable this only if you are sending upstream messages or + * receiving non-APNS, data-only messages in foregrounded apps. + * Default is `NO`. + */ +@property(nonatomic) BOOL shouldEstablishDirectChannel; + +/** + * Returns `YES` if the direct channel to the FCM server is active, and `NO` otherwise. + */ +@property(nonatomic, readonly) BOOL isDirectChannelEstablished; + +/** + * FIRMessaging + * + * @return An instance of FIRMessaging. + */ ++ (nonnull instancetype)messaging NS_SWIFT_NAME(messaging()); + +/** + * Unavailable. Use +messaging instead. + */ +- (nonnull instancetype)init __attribute__((unavailable("Use +messaging instead."))); + +#pragma mark - APNS + +/** + * This property is used to set the APNS Token received by the application delegate. + * + * FIRMessaging uses method swizzling to ensure that the APNS token is set + * automatically. However, if you have disabled swizzling by setting + * `FirebaseAppDelegateProxyEnabled` to `NO` in your app's + * Info.plist, you should manually set the APNS token in your application + * delegate's `-application:didRegisterForRemoteNotificationsWithDeviceToken:` + * method. + * + * If you would like to set the type of the APNS token, rather than relying on + * automatic detection, see: `-setAPNSToken:type:`. + */ +@property(nonatomic, copy, nullable) NSData *APNSToken NS_SWIFT_NAME(apnsToken); + +/** + * Set APNS token for the application. This APNS token will be used to register + * with Firebase Messaging using `FCMToken` or + * `tokenWithAuthorizedEntity:scope:options:handler`. + * + * @param apnsToken The APNS token for the application. + * @param type The type of APNS token. Debug builds should use + * FIRMessagingAPNSTokenTypeSandbox. Alternatively, you can supply + * FIRMessagingAPNSTokenTypeUnknown to have the type automatically + * detected based on your provisioning profile. + */ +- (void)setAPNSToken:(nonnull NSData *)apnsToken type:(FIRMessagingAPNSTokenType)type; + +#pragma mark - FCM Tokens + +/** + * Is Firebase Messaging token auto generation enabled? If this flag is disabled, + * Firebase Messaging will not generate token automatically for message delivery. + * + * If this flag is disabled, Firebase Messaging does not generate new tokens automatically for + * message delivery. If this flag is enabled, FCM generates a registration token on application + * start when there is no existing valid token. FCM also generates a new token when an existing + * token is deleted. + * + * This setting is persisted, and is applied on future + * invocations of your application. Once explicitly set, it overrides any + * settings in your Info.plist. + * + * By default, FCM automatic initialization is enabled. If you need to change the + * default (for example, because you want to prompt the user before getting token) + * set FirebaseMessagingAutoInitEnabled to false in your application's Info.plist. + */ +@property(nonatomic, assign, getter=isAutoInitEnabled) BOOL autoInitEnabled; + +/** + * The FCM token is used to identify this device so that FCM can send notifications to it. + * It is associated with your APNS token when the APNS token is supplied, so that sending + * messages to the FCM token will be delivered over APNS. + * + * The FCM token is sometimes refreshed automatically. In your FIRMessaging delegate, the + * delegate method `messaging:didReceiveRegistrationToken:` will be called once a token is + * available, or has been refreshed. Typically it should be called once per app start, but + * may be called more often, if token is invalidated or updated. + * + * Once you have an FCM token, you should send it to your application server, so it can use + * the FCM token to send notifications to your device. + */ +@property(nonatomic, readonly, nullable) NSString *FCMToken NS_SWIFT_NAME(fcmToken); + + +/** + * Retrieves an FCM registration token for a particular Sender ID. This can be used to allow + * multiple senders to send notifications to the same device. By providing a different Sender + * ID than your default when fetching a token, you can create a new FCM token which you can + * give to a different sender. Both tokens will deliver notifications to your device, and you + * can revoke a token when you need to. + * + * This registration token is not cached by FIRMessaging. FIRMessaging should have an APNS + * token set before calling this to ensure that notifications can be delivered via APNS using + * this FCM token. You may re-retrieve the FCM token once you have the APNS token set, to + * associate it with the FCM token. The default FCM token is automatically associated with + * the APNS token, if the APNS token data is available. + * + * @param senderID The Sender ID for a particular Firebase project. + * @param completion The completion handler to handle the token request. + */ +- (void)retrieveFCMTokenForSenderID:(nonnull NSString *)senderID + completion:(nonnull FIRMessagingFCMTokenFetchCompletion)completion + NS_SWIFT_NAME(retrieveFCMToken(forSenderID:completion:)); + + +/** + * Invalidates an FCM token for a particular Sender ID. That Sender ID cannot no longer send + * notifications to that FCM token. + * + * @param senderID The senderID for a particular Firebase project. + * @param completion The completion handler to handle the token deletion. + */ +- (void)deleteFCMTokenForSenderID:(nonnull NSString *)senderID + completion:(nonnull FIRMessagingDeleteFCMTokenCompletion)completion + NS_SWIFT_NAME(deleteFCMToken(forSenderID:completion:)); + + +#pragma mark - Connect + +/** + * Create a FIRMessaging data connection which will be used to send the data notifications + * sent by your server. It will also be used to send ACKS and other messages based + * on the FIRMessaging ACKS and other messages based on the FIRMessaging protocol. + * + * + * @param handler The handler to be invoked once the connection is established. + * If the connection fails we invoke the handler with an + * appropriate error code letting you know why it failed. At + * the same time, FIRMessaging performs exponential backoff to retry + * establishing a connection and invoke the handler when successful. + */ +- (void)connectWithCompletion:(nonnull FIRMessagingConnectCompletion)handler + NS_SWIFT_NAME(connect(handler:)) + __deprecated_msg("Please use the shouldEstablishDirectChannel property instead."); + +/** + * Disconnect the current FIRMessaging data connection. This stops any attempts to + * connect to FIRMessaging. Calling this on an already disconnected client is a no-op. + * + * Call this before `teardown` when your app is going to the background. + * Since the FIRMessaging connection won't be allowed to live when in the background, it is + * prudent to close the connection. + */ +- (void)disconnect + __deprecated_msg("Please use the shouldEstablishDirectChannel property instead."); + +#pragma mark - Topics + +/** + * Asynchronously subscribes to a topic. + * + * @param topic The name of the topic, for example, @"sports". + */ +- (void)subscribeToTopic:(nonnull NSString *)topic NS_SWIFT_NAME(subscribe(toTopic:)); + +/** + * Asynchronously unsubscribe from a topic. + * + * @param topic The name of the topic, for example @"sports". + */ +- (void)unsubscribeFromTopic:(nonnull NSString *)topic NS_SWIFT_NAME(unsubscribe(fromTopic:)); + +#pragma mark - Upstream + +/** + * Sends an upstream ("device to cloud") message. + * + * The message is queued if we don't have an active connection. + * You can only use the upstream feature if your FCM implementation + * uses the XMPP server protocol. + * + * @param message Key/Value pairs to be sent. Values must be String, any + * other type will be ignored. + * @param receiver A string identifying the receiver of the message. For FCM + * project IDs the value is `SENDER_ID@gcm.googleapis.com`. + * @param messageID The ID of the message. This is generated by the application. It + * must be unique for each message generated by this application. + * It allows error callbacks and debugging, to uniquely identify + * each message. + * @param ttl The time to live for the message. In case we aren't able to + * send the message before the TTL expires we will send you a + * callback. If 0, we'll attempt to send immediately and return + * an error if we're not connected. Otherwise, the message will + * be queued. As for server-side messages, we don't return an error + * if the message has been dropped because of TTL; this can happen + * on the server side, and it would require extra communication. + */ +- (void)sendMessage:(nonnull NSDictionary *)message + to:(nonnull NSString *)receiver + withMessageID:(nonnull NSString *)messageID + timeToLive:(int64_t)ttl; + +#pragma mark - Analytics + +/** + * Use this to track message delivery and analytics for messages, typically + * when you receive a notification in `application:didReceiveRemoteNotification:`. + * However, you only need to call this if you set the `FirebaseAppDelegateProxyEnabled` + * flag to `NO` in your Info.plist. If `FirebaseAppDelegateProxyEnabled` is either missing + * or set to `YES` in your Info.plist, the library will call this automatically. + * + * @param message The downstream message received by the application. + * + * @return Information about the downstream message. + */ +- (nonnull FIRMessagingMessageInfo *)appDidReceiveMessage:(nonnull NSDictionary *)message; + +@end diff --git a/Pods/FirebaseMessaging/Frameworks/FirebaseMessaging.framework/Headers/FirebaseMessaging.h b/Pods/FirebaseMessaging/Frameworks/FirebaseMessaging.framework/Headers/FirebaseMessaging.h new file mode 100755 index 0000000..ef49e7f --- /dev/null +++ b/Pods/FirebaseMessaging/Frameworks/FirebaseMessaging.framework/Headers/FirebaseMessaging.h @@ -0,0 +1 @@ +#import "FIRMessaging.h" diff --git a/Pods/FirebaseMessaging/Frameworks/FirebaseMessaging.framework/Modules/module.modulemap b/Pods/FirebaseMessaging/Frameworks/FirebaseMessaging.framework/Modules/module.modulemap new file mode 100755 index 0000000..408605e --- /dev/null +++ b/Pods/FirebaseMessaging/Frameworks/FirebaseMessaging.framework/Modules/module.modulemap @@ -0,0 +1,8 @@ +framework module FirebaseMessaging { + umbrella header "FirebaseMessaging.h" + export * + module * { export *} + link "sqlite3" + link "z" + link framework "Security" + link framework "SystemConfiguration"} diff --git a/Pods/GoogleToolboxForMac/Foundation/GTMLogger.h b/Pods/GoogleToolboxForMac/Foundation/GTMLogger.h new file mode 100644 index 0000000..16f0eaf --- /dev/null +++ b/Pods/GoogleToolboxForMac/Foundation/GTMLogger.h @@ -0,0 +1,508 @@ +// +// GTMLogger.h +// +// Copyright 2007-2008 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy +// of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. +// + +// Key Abstractions +// ---------------- +// +// This file declares multiple classes and protocols that are used by the +// GTMLogger logging system. The 4 main abstractions used in this file are the +// following: +// +// * logger (GTMLogger) - The main logging class that users interact with. It +// has methods for logging at different levels and uses a log writer, a log +// formatter, and a log filter to get the job done. +// +// * log writer (GTMLogWriter) - Writes a given string to some log file, where +// a "log file" can be a physical file on disk, a POST over HTTP to some URL, +// or even some in-memory structure (e.g., a ring buffer). +// +// * log formatter (GTMLogFormatter) - Given a format string and arguments as +// a va_list, returns a single formatted NSString. A "formatted string" could +// be a string with the date prepended, a string with values in a CSV format, +// or even a string of XML. +// +// * log filter (GTMLogFilter) - Given a formatted log message as an NSString +// and the level at which the message is to be logged, this class will decide +// whether the given message should be logged or not. This is a flexible way +// to filter out messages logged at a certain level, messages that contain +// certain text, or filter nothing out at all. This gives the caller the +// flexibility to dynamically enable debug logging in Release builds. +// +// This file also declares some classes to handle the common log writer, log +// formatter, and log filter cases. Callers can also create their own writers, +// formatters, and filters and they can even build them on top of the ones +// declared here. Keep in mind that your custom writer/formatter/filter may be +// called from multiple threads, so it must be thread-safe. + +#import +#import "GTMDefines.h" + +// Predeclaration of used protocols that are declared later in this file. +@protocol GTMLogWriter, GTMLogFormatter, GTMLogFilter; + +// GTMLogger +// +// GTMLogger is the primary user-facing class for an object-oriented logging +// system. It is built on the concept of log formatters (GTMLogFormatter), log +// writers (GTMLogWriter), and log filters (GTMLogFilter). When a message is +// sent to a GTMLogger to log a message, the message is formatted using the log +// formatter, then the log filter is consulted to see if the message should be +// logged, and if so, the message is sent to the log writer to be written out. +// +// GTMLogger is intended to be a flexible and thread-safe logging solution. Its +// flexibility comes from the fact that GTMLogger instances can be customized +// with user defined formatters, filters, and writers. And these writers, +// filters, and formatters can be combined, stacked, and customized in arbitrary +// ways to suit the needs at hand. For example, multiple writers can be used at +// the same time, and a GTMLogger instance can even be used as another +// GTMLogger's writer. This allows for arbitrarily deep logging trees. +// +// A standard GTMLogger uses a writer that sends messages to standard out, a +// formatter that smacks a timestamp and a few other bits of interesting +// information on the message, and a filter that filters out debug messages from +// release builds. Using the standard log settings, a log message will look like +// the following: +// +// 2007-12-30 10:29:24.177 myapp[4588/0xa07d0f60] [lvl=1] foo= +// +// The output contains the date and time of the log message, the name of the +// process followed by its process ID/thread ID, the log level at which the +// message was logged (in the previous example the level was 1: +// kGTMLoggerLevelDebug), and finally, the user-specified log message itself (in +// this case, the log message was @"foo=%@", foo). +// +// Multiple instances of GTMLogger can be created, each configured their own +// way. Though GTMLogger is not a singleton (in the GoF sense), it does provide +// access to a shared (i.e., globally accessible) GTMLogger instance. This makes +// it convenient for all code in a process to use the same GTMLogger instance. +// The shared GTMLogger instance can also be configured in an arbitrary, and +// these configuration changes will affect all code that logs through the shared +// instance. + +// +// Log Levels +// ---------- +// GTMLogger has 3 different log levels: Debug, Info, and Error. GTMLogger +// doesn't take any special action based on the log level; it simply forwards +// this information on to formatters, filters, and writers, each of which may +// optionally take action based on the level. Since log level filtering is +// performed at runtime, log messages are typically not filtered out at compile +// time. The exception to this rule is that calls to the GTMLoggerDebug() macro +// *ARE* filtered out of non-DEBUG builds. This is to be backwards compatible +// with behavior that many developers are currently used to. Note that this +// means that GTMLoggerDebug(@"hi") will be compiled out of Release builds, but +// [[GTMLogger sharedLogger] logDebug:@"hi"] will NOT be compiled out. +// +// Standard loggers are created with the GTMLogLevelFilter log filter, which +// filters out certain log messages based on log level, and some other settings. +// +// In addition to the -logDebug:, -logInfo:, and -logError: methods defined on +// GTMLogger itself, there are also C macros that make usage of the shared +// GTMLogger instance very convenient. These macros are: +// +// GTMLoggerDebug(...) +// GTMLoggerInfo(...) +// GTMLoggerError(...) +// +// Again, a notable feature of these macros is that GTMLogDebug() calls *will be +// compiled out of non-DEBUG builds*. +// +// Standard Loggers +// ---------------- +// GTMLogger has the concept of "standard loggers". A standard logger is simply +// a logger that is pre-configured with some standard/common writer, formatter, +// and filter combination. Standard loggers are created using the creation +// methods beginning with "standard". The alternative to a standard logger is a +// regular logger, which will send messages to stdout, with no special +// formatting, and no filtering. +// +// How do I use GTMLogger? +// ---------------------- +// The typical way you will want to use GTMLogger is to simply use the +// GTMLogger*() macros for logging from code. That way we can easily make +// changes to the GTMLogger class and simply update the macros accordingly. Only +// your application startup code (perhaps, somewhere in main()) should use the +// GTMLogger class directly in order to configure the shared logger, which all +// of the code using the macros will be using. Again, this is just the typical +// situation. +// +// To be complete, there are cases where you may want to use GTMLogger directly, +// or even create separate GTMLogger instances for some reason. That's fine, +// too. +// +// Examples +// -------- +// The following show some common GTMLogger use cases. +// +// 1. You want to log something as simply as possible. Also, this call will only +// appear in debug builds. In non-DEBUG builds it will be completely removed. +// +// GTMLoggerDebug(@"foo = %@", foo); +// +// 2. The previous example is similar to the following. The major difference is +// that the previous call (example 1) will be compiled out of Release builds +// but this statement will not be compiled out. +// +// [[GTMLogger sharedLogger] logDebug:@"foo = %@", foo]; +// +// 3. Send all logging output from the shared logger to a file. We do this by +// creating an NSFileHandle for writing associated with a file, and setting +// that file handle as the logger's writer. +// +// NSFileHandle *f = [NSFileHandle fileHandleForWritingAtPath:@"/tmp/f.log" +// create:YES]; +// [[GTMLogger sharedLogger] setWriter:f]; +// GTMLoggerError(@"hi"); // This will be sent to /tmp/f.log +// +// 4. Create a new GTMLogger that will log to a file. This example differs from +// the previous one because here we create a new GTMLogger that is different +// from the shared logger. +// +// GTMLogger *logger = [GTMLogger standardLoggerWithPath:@"/tmp/temp.log"]; +// [logger logInfo:@"hi temp log file"]; +// +// 5. Create a logger that writes to stdout and does NOT do any formatting to +// the log message. This might be useful, for example, when writing a help +// screen for a command-line tool to standard output. +// +// GTMLogger *logger = [GTMLogger logger]; +// [logger logInfo:@"%@ version 0.1 usage", progName]; +// +// 6. Send log output to stdout AND to a log file. The trick here is that +// NSArrays function as composite log writers, which means when an array is +// set as the log writer, it forwards all logging messages to all of its +// contained GTMLogWriters. +// +// // Create array of GTMLogWriters +// NSArray *writers = [NSArray arrayWithObjects: +// [NSFileHandle fileHandleForWritingAtPath:@"/tmp/f.log" create:YES], +// [NSFileHandle fileHandleWithStandardOutput], nil]; +// +// GTMLogger *logger = [GTMLogger standardLogger]; +// [logger setWriter:writers]; +// [logger logInfo:@"hi"]; // Output goes to stdout and /tmp/f.log +// +// For futher details on log writers, formatters, and filters, see the +// documentation below. +// +// NOTE: GTMLogger is application level logging. By default it does nothing +// with _GTMDevLog/_GTMDevAssert (see GTMDefines.h). An application can choose +// to bridge _GTMDevLog/_GTMDevAssert to GTMLogger by providing macro +// definitions in its prefix header (see GTMDefines.h for how one would do +// that). +// +@interface GTMLogger : NSObject { + @private + id writer_; + id formatter_; + id filter_; +} + +// +// Accessors for the shared logger instance +// + +// Returns a shared/global standard GTMLogger instance. Callers should typically +// use this method to get a GTMLogger instance, unless they explicitly want +// their own instance to configure for their own needs. This is the only method +// that returns a shared instance; all the rest return new GTMLogger instances. ++ (id)sharedLogger; + +// Sets the shared logger instance to |logger|. Future calls to +sharedLogger +// will return |logger| instead. ++ (void)setSharedLogger:(GTMLogger *)logger; + +// +// Creation methods +// + +// Returns a new autoreleased GTMLogger instance that will log to stdout, using +// the GTMLogStandardFormatter, and the GTMLogLevelFilter filter. ++ (id)standardLogger; + +// Same as +standardLogger, but logs to stderr. ++ (id)standardLoggerWithStderr; + +// Same as +standardLogger but levels >= kGTMLoggerLevelError are routed to +// stderr, everything else goes to stdout. ++ (id)standardLoggerWithStdoutAndStderr; + +// Returns a new standard GTMLogger instance with a log writer that will +// write to the file at |path|, and will use the GTMLogStandardFormatter and +// GTMLogLevelFilter classes. If |path| does not exist, it will be created. ++ (id)standardLoggerWithPath:(NSString *)path; + +// Returns an autoreleased GTMLogger instance that will use the specified +// |writer|, |formatter|, and |filter|. ++ (id)loggerWithWriter:(id)writer + formatter:(id)formatter + filter:(id)filter; + +// Returns an autoreleased GTMLogger instance that logs to stdout, with the +// basic formatter, and no filter. The returned logger differs from the logger +// returned by +standardLogger because this one does not do any filtering and +// does not do any special log formatting; this is the difference between a +// "regular" logger and a "standard" logger. ++ (id)logger; + +// Designated initializer. This method returns a GTMLogger initialized with the +// specified |writer|, |formatter|, and |filter|. See the setter methods below +// for what values will be used if nil is passed for a parameter. +- (id)initWithWriter:(id)writer + formatter:(id)formatter + filter:(id)filter; + +// +// Logging methods +// + +// Logs a message at the debug level (kGTMLoggerLevelDebug). +- (void)logDebug:(NSString *)fmt, ... NS_FORMAT_FUNCTION(1, 2); +// Logs a message at the info level (kGTMLoggerLevelInfo). +- (void)logInfo:(NSString *)fmt, ... NS_FORMAT_FUNCTION(1, 2); +// Logs a message at the error level (kGTMLoggerLevelError). +- (void)logError:(NSString *)fmt, ... NS_FORMAT_FUNCTION(1, 2); +// Logs a message at the assert level (kGTMLoggerLevelAssert). +- (void)logAssert:(NSString *)fmt, ... NS_FORMAT_FUNCTION(1, 2); + + +// +// Accessors +// + +// Accessor methods for the log writer. If the log writer is set to nil, +// [NSFileHandle fileHandleWithStandardOutput] is used. +- (id)writer; +- (void)setWriter:(id)writer; + +// Accessor methods for the log formatter. If the log formatter is set to nil, +// GTMLogBasicFormatter is used. This formatter will format log messages in a +// plain printf style. +- (id)formatter; +- (void)setFormatter:(id)formatter; + +// Accessor methods for the log filter. If the log filter is set to nil, +// GTMLogNoFilter is used, which allows all log messages through. +- (id)filter; +- (void)setFilter:(id)filter; + +@end // GTMLogger + + +// Helper functions that are used by the convenience GTMLogger*() macros that +// enable the logging of function names. +@interface GTMLogger (GTMLoggerMacroHelpers) +- (void)logFuncDebug:(const char *)func msg:(NSString *)fmt, ... + NS_FORMAT_FUNCTION(2, 3); +- (void)logFuncInfo:(const char *)func msg:(NSString *)fmt, ... + NS_FORMAT_FUNCTION(2, 3); +- (void)logFuncError:(const char *)func msg:(NSString *)fmt, ... + NS_FORMAT_FUNCTION(2, 3); +- (void)logFuncAssert:(const char *)func msg:(NSString *)fmt, ... + NS_FORMAT_FUNCTION(2, 3); +@end // GTMLoggerMacroHelpers + + +// The convenience macros are only defined if they haven't already been defined. +#ifndef GTMLoggerInfo + +// Convenience macros that log to the shared GTMLogger instance. These macros +// are how users should typically log to GTMLogger. Notice that GTMLoggerDebug() +// calls will be compiled out of non-Debug builds. +#define GTMLoggerDebug(...) \ + [[GTMLogger sharedLogger] logFuncDebug:__func__ msg:__VA_ARGS__] +#define GTMLoggerInfo(...) \ + [[GTMLogger sharedLogger] logFuncInfo:__func__ msg:__VA_ARGS__] +#define GTMLoggerError(...) \ + [[GTMLogger sharedLogger] logFuncError:__func__ msg:__VA_ARGS__] +#define GTMLoggerAssert(...) \ + [[GTMLogger sharedLogger] logFuncAssert:__func__ msg:__VA_ARGS__] + +// If we're not in a debug build, remove the GTMLoggerDebug statements. This +// makes calls to GTMLoggerDebug "compile out" of Release builds +#ifndef DEBUG +#undef GTMLoggerDebug +#define GTMLoggerDebug(...) do {} while(0) +#endif + +#endif // !defined(GTMLoggerInfo) + +// Log levels. +typedef enum { + kGTMLoggerLevelUnknown, + kGTMLoggerLevelDebug, + kGTMLoggerLevelInfo, + kGTMLoggerLevelError, + kGTMLoggerLevelAssert, +} GTMLoggerLevel; + + +// +// Log Writers +// + +// Protocol to be implemented by a GTMLogWriter instance. +@protocol GTMLogWriter +// Writes the given log message to where the log writer is configured to write. +- (void)logMessage:(NSString *)msg level:(GTMLoggerLevel)level; +@end // GTMLogWriter + + +// Simple category on NSFileHandle that makes NSFileHandles valid log writers. +// This is convenient because something like, say, +fileHandleWithStandardError +// now becomes a valid log writer. Log messages are written to the file handle +// with a newline appended. +@interface NSFileHandle (GTMFileHandleLogWriter) +// Opens the file at |path| in append mode, and creates the file with |mode| +// if it didn't previously exist. ++ (id)fileHandleForLoggingAtPath:(NSString *)path mode:(mode_t)mode; +@end // NSFileHandle + + +// This category makes NSArray a GTMLogWriter that can be composed of other +// GTMLogWriters. This is the classic Composite GoF design pattern. When the +// GTMLogWriter -logMessage:level: message is sent to the array, the array +// forwards the message to all of its elements that implement the GTMLogWriter +// protocol. +// +// This is useful in situations where you would like to send log output to +// multiple log writers at the same time. Simply create an NSArray of the log +// writers you wish to use, then set the array as the "writer" for your +// GTMLogger instance. +@interface NSArray (GTMArrayCompositeLogWriter) +@end // GTMArrayCompositeLogWriter + + +// This category adapts the GTMLogger interface so that it can be used as a log +// writer; it's an "adapter" in the GoF Adapter pattern sense. +// +// This is useful when you want to configure a logger to log to a specific +// writer with a specific formatter and/or filter. But you want to also compose +// that with a different log writer that may have its own formatter and/or +// filter. +@interface GTMLogger (GTMLoggerLogWriter) +@end // GTMLoggerLogWriter + + +// +// Log Formatters +// + +// Protocol to be implemented by a GTMLogFormatter instance. +@protocol GTMLogFormatter +// Returns a formatted string using the format specified in |fmt| and the va +// args specified in |args|. +- (NSString *)stringForFunc:(NSString *)func + withFormat:(NSString *)fmt + valist:(va_list)args + level:(GTMLoggerLevel)level NS_FORMAT_FUNCTION(2, 0); +@end // GTMLogFormatter + + +// A basic log formatter that formats a string the same way that NSLog (or +// printf) would. It does not do anything fancy, nor does it add any data of its +// own. +@interface GTMLogBasicFormatter : NSObject + +// Helper method for prettying C99 __func__ and GCC __PRETTY_FUNCTION__ +- (NSString *)prettyNameForFunc:(NSString *)func; + +@end // GTMLogBasicFormatter + + +// A log formatter that formats the log string like the basic formatter, but +// also prepends a timestamp and some basic process info to the message, as +// shown in the following sample output. +// 2007-12-30 10:29:24.177 myapp[4588/0xa07d0f60] [lvl=1] log mesage here +@interface GTMLogStandardFormatter : GTMLogBasicFormatter { + @private + NSDateFormatter *dateFormatter_; // yyyy-MM-dd HH:mm:ss.SSS + NSString *pname_; + pid_t pid_; +} +@end // GTMLogStandardFormatter + + +// +// Log Filters +// + +// Protocol to be implemented by a GTMLogFilter instance. +@protocol GTMLogFilter +// Returns YES if |msg| at |level| should be logged; NO otherwise. +- (BOOL)filterAllowsMessage:(NSString *)msg level:(GTMLoggerLevel)level; +@end // GTMLogFilter + + +// A log filter that filters messages at the kGTMLoggerLevelDebug level out of +// non-debug builds. Messages at the kGTMLoggerLevelInfo level are also filtered +// out of non-debug builds unless GTMVerboseLogging is set in the environment or +// the processes's defaults. Messages at the kGTMLoggerLevelError level are +// never filtered. +@interface GTMLogLevelFilter : NSObject { + @private + BOOL verboseLoggingEnabled_; + NSUserDefaults *userDefaults_; +} +@end // GTMLogLevelFilter + +// A simple log filter that does NOT filter anything out; +// -filterAllowsMessage:level will always return YES. This can be a convenient +// way to enable debug-level logging in release builds (if you so desire). +@interface GTMLogNoFilter : NSObject +@end // GTMLogNoFilter + + +// Base class for custom level filters. Not for direct use, use the minimum +// or maximum level subclasses below. +@interface GTMLogAllowedLevelFilter : NSObject { + @private + NSIndexSet *allowedLevels_; +} +@end + +// A log filter that allows you to set a minimum log level. Messages below this +// level will be filtered. +@interface GTMLogMininumLevelFilter : GTMLogAllowedLevelFilter + +// Designated initializer, logs at levels < |level| will be filtered. +- (id)initWithMinimumLevel:(GTMLoggerLevel)level; + +@end + +// A log filter that allows you to set a maximum log level. Messages whose level +// exceeds this level will be filtered. This is really only useful if you have +// a composite GTMLogger that is sending the other messages elsewhere. +@interface GTMLogMaximumLevelFilter : GTMLogAllowedLevelFilter + +// Designated initializer, logs at levels > |level| will be filtered. +- (id)initWithMaximumLevel:(GTMLoggerLevel)level; + +@end + + +// For subclasses only +@interface GTMLogger (PrivateMethods) + +- (void)logInternalFunc:(const char *)func + format:(NSString *)fmt + valist:(va_list)args + level:(GTMLoggerLevel)level NS_FORMAT_FUNCTION(2, 0); + +@end + diff --git a/Pods/GoogleToolboxForMac/Foundation/GTMLogger.m b/Pods/GoogleToolboxForMac/Foundation/GTMLogger.m new file mode 100644 index 0000000..e6b2ba1 --- /dev/null +++ b/Pods/GoogleToolboxForMac/Foundation/GTMLogger.m @@ -0,0 +1,648 @@ +// +// GTMLogger.m +// +// Copyright 2007-2008 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy +// of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. +// + +#import "GTMLogger.h" +#import +#import +#import +#import + + +#if !defined(__clang__) && (__GNUC__*10+__GNUC_MINOR__ >= 42) +// Some versions of GCC (4.2 and below AFAIK) aren't great about supporting +// -Wmissing-format-attribute +// when the function is anything more complex than foo(NSString *fmt, ...). +// You see the error inside the function when you turn ... into va_args and +// attempt to call another function (like vsprintf for example). +// So we just shut off the warning for this file. We reenable it at the end. +#pragma GCC diagnostic ignored "-Wmissing-format-attribute" +#endif // !__clang__ + +// Reference to the shared GTMLogger instance. This is not a singleton, it's +// just an easy reference to one shared instance. +static GTMLogger *gSharedLogger = nil; + + +@implementation GTMLogger + +// Returns a pointer to the shared logger instance. If none exists, a standard +// logger is created and returned. ++ (id)sharedLogger { + @synchronized(self) { + if (gSharedLogger == nil) { + gSharedLogger = [[self standardLogger] retain]; + } + } + return [[gSharedLogger retain] autorelease]; +} + ++ (void)setSharedLogger:(GTMLogger *)logger { + @synchronized(self) { + [gSharedLogger autorelease]; + gSharedLogger = [logger retain]; + } +} + ++ (id)standardLogger { + // Don't trust NSFileHandle not to throw + @try { + id writer = [NSFileHandle fileHandleWithStandardOutput]; + id fr = [[[GTMLogStandardFormatter alloc] init] + autorelease]; + id filter = [[[GTMLogLevelFilter alloc] init] autorelease]; + return [[[self alloc] initWithWriter:writer + formatter:fr + filter:filter] autorelease]; + } + @catch (id e) { + // Ignored + } + return nil; +} + ++ (id)standardLoggerWithStderr { + // Don't trust NSFileHandle not to throw + @try { + id me = [self standardLogger]; + [me setWriter:[NSFileHandle fileHandleWithStandardError]]; + return me; + } + @catch (id e) { + // Ignored + } + return nil; +} + ++ (id)standardLoggerWithStdoutAndStderr { + // We're going to take advantage of the GTMLogger to GTMLogWriter adaptor + // and create a composite logger that an outer "standard" logger can use + // as a writer. Our inner loggers should apply no formatting since the main + // logger does that and we want the caller to be able to change formatters + // or add writers without knowing the inner structure of our composite. + + // Don't trust NSFileHandle not to throw + @try { + GTMLogBasicFormatter *formatter = [[[GTMLogBasicFormatter alloc] init] + autorelease]; + GTMLogger *stdoutLogger = + [self loggerWithWriter:[NSFileHandle fileHandleWithStandardOutput] + formatter:formatter + filter:[[[GTMLogMaximumLevelFilter alloc] + initWithMaximumLevel:kGTMLoggerLevelInfo] + autorelease]]; + GTMLogger *stderrLogger = + [self loggerWithWriter:[NSFileHandle fileHandleWithStandardError] + formatter:formatter + filter:[[[GTMLogMininumLevelFilter alloc] + initWithMinimumLevel:kGTMLoggerLevelError] + autorelease]]; + GTMLogger *compositeWriter = + [self loggerWithWriter:[NSArray arrayWithObjects: + stdoutLogger, stderrLogger, nil] + formatter:formatter + filter:[[[GTMLogNoFilter alloc] init] autorelease]]; + GTMLogger *outerLogger = [self standardLogger]; + [outerLogger setWriter:compositeWriter]; + return outerLogger; + } + @catch (id e) { + // Ignored + } + return nil; +} + ++ (id)standardLoggerWithPath:(NSString *)path { + @try { + NSFileHandle *fh = [NSFileHandle fileHandleForLoggingAtPath:path mode:0644]; + if (fh == nil) return nil; + id me = [self standardLogger]; + [me setWriter:fh]; + return me; + } + @catch (id e) { + // Ignored + } + return nil; +} + ++ (id)loggerWithWriter:(id)writer + formatter:(id)formatter + filter:(id)filter { + return [[[self alloc] initWithWriter:writer + formatter:formatter + filter:filter] autorelease]; +} + ++ (id)logger { + return [[[self alloc] init] autorelease]; +} + +- (id)init { + return [self initWithWriter:nil formatter:nil filter:nil]; +} + +- (id)initWithWriter:(id)writer + formatter:(id)formatter + filter:(id)filter { + if ((self = [super init])) { + [self setWriter:writer]; + [self setFormatter:formatter]; + [self setFilter:filter]; + } + return self; +} + +- (void)dealloc { + // Unlikely, but |writer_| may be an NSFileHandle, which can throw + @try { + [formatter_ release]; + [filter_ release]; + [writer_ release]; + } + @catch (id e) { + // Ignored + } + [super dealloc]; +} + +- (id)writer { + return [[writer_ retain] autorelease]; +} + +- (void)setWriter:(id)writer { + @synchronized(self) { + [writer_ autorelease]; + writer_ = nil; + if (writer == nil) { + // Try to use stdout, but don't trust NSFileHandle + @try { + writer_ = [[NSFileHandle fileHandleWithStandardOutput] retain]; + } + @catch (id e) { + // Leave |writer_| nil + } + } else { + writer_ = [writer retain]; + } + } +} + +- (id)formatter { + return [[formatter_ retain] autorelease]; +} + +- (void)setFormatter:(id)formatter { + @synchronized(self) { + [formatter_ autorelease]; + formatter_ = nil; + if (formatter == nil) { + @try { + formatter_ = [[GTMLogBasicFormatter alloc] init]; + } + @catch (id e) { + // Leave |formatter_| nil + } + } else { + formatter_ = [formatter retain]; + } + } +} + +- (id)filter { + return [[filter_ retain] autorelease]; +} + +- (void)setFilter:(id)filter { + @synchronized(self) { + [filter_ autorelease]; + filter_ = nil; + if (filter == nil) { + @try { + filter_ = [[GTMLogNoFilter alloc] init]; + } + @catch (id e) { + // Leave |filter_| nil + } + } else { + filter_ = [filter retain]; + } + } +} + +- (void)logDebug:(NSString *)fmt, ... { + va_list args; + va_start(args, fmt); + [self logInternalFunc:NULL format:fmt valist:args level:kGTMLoggerLevelDebug]; + va_end(args); +} + +- (void)logInfo:(NSString *)fmt, ... { + va_list args; + va_start(args, fmt); + [self logInternalFunc:NULL format:fmt valist:args level:kGTMLoggerLevelInfo]; + va_end(args); +} + +- (void)logError:(NSString *)fmt, ... { + va_list args; + va_start(args, fmt); + [self logInternalFunc:NULL format:fmt valist:args level:kGTMLoggerLevelError]; + va_end(args); +} + +- (void)logAssert:(NSString *)fmt, ... { + va_list args; + va_start(args, fmt); + [self logInternalFunc:NULL format:fmt valist:args level:kGTMLoggerLevelAssert]; + va_end(args); +} + +@end // GTMLogger + +@implementation GTMLogger (GTMLoggerMacroHelpers) + +- (void)logFuncDebug:(const char *)func msg:(NSString *)fmt, ... { + va_list args; + va_start(args, fmt); + [self logInternalFunc:func format:fmt valist:args level:kGTMLoggerLevelDebug]; + va_end(args); +} + +- (void)logFuncInfo:(const char *)func msg:(NSString *)fmt, ... { + va_list args; + va_start(args, fmt); + [self logInternalFunc:func format:fmt valist:args level:kGTMLoggerLevelInfo]; + va_end(args); +} + +- (void)logFuncError:(const char *)func msg:(NSString *)fmt, ... { + va_list args; + va_start(args, fmt); + [self logInternalFunc:func format:fmt valist:args level:kGTMLoggerLevelError]; + va_end(args); +} + +- (void)logFuncAssert:(const char *)func msg:(NSString *)fmt, ... { + va_list args; + va_start(args, fmt); + [self logInternalFunc:func format:fmt valist:args level:kGTMLoggerLevelAssert]; + va_end(args); +} + +@end // GTMLoggerMacroHelpers + +@implementation GTMLogger (PrivateMethods) + +- (void)logInternalFunc:(const char *)func + format:(NSString *)fmt + valist:(va_list)args + level:(GTMLoggerLevel)level { + // Primary point where logging happens, logging should never throw, catch + // everything. + @try { + NSString *fname = func ? [NSString stringWithUTF8String:func] : nil; + NSString *msg = [formatter_ stringForFunc:fname + withFormat:fmt + valist:args + level:level]; + if (msg && [filter_ filterAllowsMessage:msg level:level]) + [writer_ logMessage:msg level:level]; + } + @catch (id e) { + // Ignored + } +} + +@end // PrivateMethods + + +@implementation NSFileHandle (GTMFileHandleLogWriter) + ++ (id)fileHandleForLoggingAtPath:(NSString *)path mode:(mode_t)mode { + int fd = -1; + if (path) { + int flags = O_WRONLY | O_APPEND | O_CREAT; + fd = open([path fileSystemRepresentation], flags, mode); + } + if (fd == -1) return nil; + return [[[self alloc] initWithFileDescriptor:fd + closeOnDealloc:YES] autorelease]; +} + +- (void)logMessage:(NSString *)msg level:(GTMLoggerLevel)level { + @synchronized(self) { + // Closed pipes should not generate exceptions in our caller. Catch here + // as well [GTMLogger logInternalFunc:...] so that an exception in this + // writer does not prevent other writers from having a chance. + @try { + NSString *line = [NSString stringWithFormat:@"%@\n", msg]; + [self writeData:[line dataUsingEncoding:NSUTF8StringEncoding]]; + } + @catch (id e) { + // Ignored + } + } +} + +@end // GTMFileHandleLogWriter + + +@implementation NSArray (GTMArrayCompositeLogWriter) + +- (void)logMessage:(NSString *)msg level:(GTMLoggerLevel)level { + @synchronized(self) { + id child = nil; + for (child in self) { + if ([child conformsToProtocol:@protocol(GTMLogWriter)]) + [child logMessage:msg level:level]; + } + } +} + +@end // GTMArrayCompositeLogWriter + + +@implementation GTMLogger (GTMLoggerLogWriter) + +- (void)logMessage:(NSString *)msg level:(GTMLoggerLevel)level { + switch (level) { + case kGTMLoggerLevelDebug: + [self logDebug:@"%@", msg]; + break; + case kGTMLoggerLevelInfo: + [self logInfo:@"%@", msg]; + break; + case kGTMLoggerLevelError: + [self logError:@"%@", msg]; + break; + case kGTMLoggerLevelAssert: + [self logAssert:@"%@", msg]; + break; + default: + // Ignore the message. + break; + } +} + +@end // GTMLoggerLogWriter + + +@implementation GTMLogBasicFormatter + +- (NSString *)prettyNameForFunc:(NSString *)func { + NSString *name = [func stringByTrimmingCharactersInSet: + [NSCharacterSet whitespaceAndNewlineCharacterSet]]; + NSString *function = @"(unknown)"; + if ([name length]) { + if (// Objective C __func__ and __PRETTY_FUNCTION__ + [name hasPrefix:@"-["] || [name hasPrefix:@"+["] || + // C++ __PRETTY_FUNCTION__ and other preadorned formats + [name hasSuffix:@")"]) { + function = name; + } else { + // Assume C99 __func__ + function = [NSString stringWithFormat:@"%@()", name]; + } + } + return function; +} + +- (NSString *)stringForFunc:(NSString *)func + withFormat:(NSString *)fmt + valist:(va_list)args + level:(GTMLoggerLevel)level { + // Performance note: We may want to do a quick check here to see if |fmt| + // contains a '%', and if not, simply return 'fmt'. + if (!(fmt && args)) return nil; + return [[[NSString alloc] initWithFormat:fmt arguments:args] autorelease]; +} + +@end // GTMLogBasicFormatter + + +@implementation GTMLogStandardFormatter + +- (id)init { + if ((self = [super init])) { + dateFormatter_ = [[NSDateFormatter alloc] init]; + [dateFormatter_ setFormatterBehavior:NSDateFormatterBehavior10_4]; + [dateFormatter_ setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS"]; + pname_ = [[[NSProcessInfo processInfo] processName] copy]; + pid_ = [[NSProcessInfo processInfo] processIdentifier]; + if (!(dateFormatter_ && pname_)) { + [self release]; + return nil; + } + } + return self; +} + +- (void)dealloc { + [dateFormatter_ release]; + [pname_ release]; + [super dealloc]; +} + +- (NSString *)stringForFunc:(NSString *)func + withFormat:(NSString *)fmt + valist:(va_list)args + level:(GTMLoggerLevel)level { + NSString *tstamp = nil; + @synchronized (dateFormatter_) { + tstamp = [dateFormatter_ stringFromDate:[NSDate date]]; + } + return [NSString stringWithFormat:@"%@ %@[%d/%p] [lvl=%d] %@ %@", + tstamp, pname_, pid_, pthread_self(), + level, [self prettyNameForFunc:func], + // |super| has guard for nil |fmt| and |args| + [super stringForFunc:func withFormat:fmt valist:args level:level]]; +} + +@end // GTMLogStandardFormatter + +static NSString *const kVerboseLoggingKey = @"GTMVerboseLogging"; + +// Check the environment and the user preferences for the GTMVerboseLogging key +// to see if verbose logging has been enabled. The environment variable will +// override the defaults setting, so check the environment first. +// COV_NF_START +static BOOL IsVerboseLoggingEnabled(NSUserDefaults *userDefaults) { + NSString *value = [[[NSProcessInfo processInfo] environment] + objectForKey:kVerboseLoggingKey]; + if (value) { + // Emulate [NSString boolValue] for pre-10.5 + value = [value stringByTrimmingCharactersInSet: + [NSCharacterSet whitespaceAndNewlineCharacterSet]]; + if ([[value uppercaseString] hasPrefix:@"Y"] || + [[value uppercaseString] hasPrefix:@"T"] || + [value intValue]) { + return YES; + } else { + return NO; + } + } + return [userDefaults boolForKey:kVerboseLoggingKey]; +} +// COV_NF_END + +@implementation GTMLogLevelFilter + +- (id)init { + self = [super init]; + if (self) { + // Keep a reference to standardUserDefaults, avoiding a crash if client code calls + // "NSUserDefaults resetStandardUserDefaults" which releases it from memory. We are still + // notified of changes through our instance. Note: resetStandardUserDefaults does not actually + // clear settings: + // https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/index.html#//apple_ref/occ/clm/NSUserDefaults/resetStandardUserDefaults + // and so should only be called in test code if necessary. + userDefaults_ = [[NSUserDefaults standardUserDefaults] retain]; + [userDefaults_ addObserver:self + forKeyPath:kVerboseLoggingKey + options:NSKeyValueObservingOptionNew + context:nil]; + + verboseLoggingEnabled_ = IsVerboseLoggingEnabled(userDefaults_); + } + + return self; +} + +- (void)dealloc { + [userDefaults_ removeObserver:self forKeyPath:kVerboseLoggingKey]; + [userDefaults_ release]; + + [super dealloc]; +} + +// In DEBUG builds, log everything. If we're not in a debug build we'll assume +// that we're in a Release build. +- (BOOL)filterAllowsMessage:(NSString *)msg level:(GTMLoggerLevel)level { +#if defined(DEBUG) && DEBUG + return YES; +#endif + + BOOL allow = YES; + + switch (level) { + case kGTMLoggerLevelDebug: + allow = NO; + break; + case kGTMLoggerLevelInfo: + allow = verboseLoggingEnabled_; + break; + case kGTMLoggerLevelError: + allow = YES; + break; + case kGTMLoggerLevelAssert: + allow = YES; + break; + default: + allow = YES; + break; + } + + return allow; +} + +- (void)observeValueForKeyPath:(NSString *)keyPath + ofObject:(id)object + change:(NSDictionary *)change + context:(void *)context +{ + if([keyPath isEqual:kVerboseLoggingKey]) { + verboseLoggingEnabled_ = IsVerboseLoggingEnabled(userDefaults_); + } +} + +@end // GTMLogLevelFilter + + +@implementation GTMLogNoFilter + +- (BOOL)filterAllowsMessage:(NSString *)msg level:(GTMLoggerLevel)level { + return YES; // Allow everything through +} + +@end // GTMLogNoFilter + + +@implementation GTMLogAllowedLevelFilter + +// Private designated initializer +- (id)initWithAllowedLevels:(NSIndexSet *)levels { + self = [super init]; + if (self != nil) { + allowedLevels_ = [levels retain]; + // Cap min/max level + if (!allowedLevels_ || + // NSIndexSet is unsigned so only check the high bound, but need to + // check both first and last index because NSIndexSet appears to allow + // wraparound. + ([allowedLevels_ firstIndex] > kGTMLoggerLevelAssert) || + ([allowedLevels_ lastIndex] > kGTMLoggerLevelAssert)) { + [self release]; + return nil; + } + } + return self; +} + +- (id)init { + // Allow all levels in default init + return [self initWithAllowedLevels:[NSIndexSet indexSetWithIndexesInRange: + NSMakeRange(kGTMLoggerLevelUnknown, + (kGTMLoggerLevelAssert - kGTMLoggerLevelUnknown + 1))]]; +} + +- (void)dealloc { + [allowedLevels_ release]; + [super dealloc]; +} + +- (BOOL)filterAllowsMessage:(NSString *)msg level:(GTMLoggerLevel)level { + return [allowedLevels_ containsIndex:level]; +} + +@end // GTMLogAllowedLevelFilter + + +@implementation GTMLogMininumLevelFilter + +- (id)initWithMinimumLevel:(GTMLoggerLevel)level { + return [super initWithAllowedLevels:[NSIndexSet indexSetWithIndexesInRange: + NSMakeRange(level, + (kGTMLoggerLevelAssert - level + 1))]]; +} + +@end // GTMLogMininumLevelFilter + + +@implementation GTMLogMaximumLevelFilter + +- (id)initWithMaximumLevel:(GTMLoggerLevel)level { + return [super initWithAllowedLevels:[NSIndexSet indexSetWithIndexesInRange: + NSMakeRange(kGTMLoggerLevelUnknown, level + 1)]]; +} + +@end // GTMLogMaximumLevelFilter + +#if !defined(__clang__) && (__GNUC__*10+__GNUC_MINOR__ >= 42) +// See comment at top of file. +#pragma GCC diagnostic error "-Wmissing-format-attribute" +#endif // !__clang__ diff --git a/Pods/GoogleToolboxForMac/Foundation/GTMNSData+zlib.h b/Pods/GoogleToolboxForMac/Foundation/GTMNSData+zlib.h new file mode 100644 index 0000000..dceadc4 --- /dev/null +++ b/Pods/GoogleToolboxForMac/Foundation/GTMNSData+zlib.h @@ -0,0 +1,199 @@ +// +// GTMNSData+zlib.h +// +// Copyright 2007-2008 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy +// of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. +// + +#import +#import "GTMDefines.h" + +/// Helpers for dealing w/ zlib inflate/deflate calls. +@interface NSData (GTMZLibAdditions) + +// NOTE: For 64bit, none of these apis handle input sizes >32bits, they will +// return nil when given such data. To handle data of that size you really +// should be streaming it rather then doing it all in memory. + +#pragma mark Gzip Compression + +/// Return an autoreleased NSData w/ the result of gzipping the bytes. +// +// Uses the default compression level. ++ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes + length:(NSUInteger)length; ++ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes + length:(NSUInteger)length + error:(NSError **)error; + +/// Return an autoreleased NSData w/ the result of gzipping the payload of |data|. +// +// Uses the default compression level. ++ (NSData *)gtm_dataByGzippingData:(NSData *)data __attribute__((deprecated("Use error variant"))); ++ (NSData *)gtm_dataByGzippingData:(NSData *)data + error:(NSError **)error; + +/// Return an autoreleased NSData w/ the result of gzipping the bytes using |level| compression level. +// +// |level| can be 1-9, any other values will be clipped to that range. ++ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes + length:(NSUInteger)length + compressionLevel:(int)level __attribute__((deprecated("Use error variant"))); ++ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes + length:(NSUInteger)length + compressionLevel:(int)level + error:(NSError **)error; + +/// Return an autoreleased NSData w/ the result of gzipping the payload of |data| using |level| compression level. ++ (NSData *)gtm_dataByGzippingData:(NSData *)data + compressionLevel:(int)level __attribute__((deprecated("Use error variant"))); ++ (NSData *)gtm_dataByGzippingData:(NSData *)data + compressionLevel:(int)level + error:(NSError **)error; + +#pragma mark Zlib "Stream" Compression + +// NOTE: deflate is *NOT* gzip. deflate is a "zlib" stream. pick which one +// you really want to create. (the inflate api will handle either) + +/// Return an autoreleased NSData w/ the result of deflating the bytes. +// +// Uses the default compression level. ++ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes + length:(NSUInteger)length __attribute__((deprecated("Use error variant"))); ++ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes + length:(NSUInteger)length + error:(NSError **)error; + +/// Return an autoreleased NSData w/ the result of deflating the payload of |data|. +// +// Uses the default compression level. ++ (NSData *)gtm_dataByDeflatingData:(NSData *)data __attribute__((deprecated("Use error variant"))); ++ (NSData *)gtm_dataByDeflatingData:(NSData *)data + error:(NSError **)error; + +/// Return an autoreleased NSData w/ the result of deflating the bytes using |level| compression level. +// +// |level| can be 1-9, any other values will be clipped to that range. ++ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes + length:(NSUInteger)length + compressionLevel:(int)level __attribute__((deprecated("Use error variant"))); ++ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes + length:(NSUInteger)length + compressionLevel:(int)level + error:(NSError **)error; + +/// Return an autoreleased NSData w/ the result of deflating the payload of |data| using |level| compression level. ++ (NSData *)gtm_dataByDeflatingData:(NSData *)data + compressionLevel:(int)level __attribute__((deprecated("Use error variant"))); ++ (NSData *)gtm_dataByDeflatingData:(NSData *)data + compressionLevel:(int)level + error:(NSError **)error; + +#pragma mark Uncompress of Gzip or Zlib + +/// Return an autoreleased NSData w/ the result of decompressing the bytes. +// +// The bytes to decompress can be zlib or gzip payloads. ++ (NSData *)gtm_dataByInflatingBytes:(const void *)bytes + length:(NSUInteger)length __attribute__((deprecated("Use error variant"))); ++ (NSData *)gtm_dataByInflatingBytes:(const void *)bytes + length:(NSUInteger)length + error:(NSError **)error; + +/// Return an autoreleased NSData w/ the result of decompressing the payload of |data|. +// +// The data to decompress can be zlib or gzip payloads. ++ (NSData *)gtm_dataByInflatingData:(NSData *)data __attribute__((deprecated("Use error variant"))); ++ (NSData *)gtm_dataByInflatingData:(NSData *)data + error:(NSError **)error; + +#pragma mark "Raw" Compression Support + +// NOTE: raw deflate is *NOT* gzip or deflate. it does not include a header +// of any form and should only be used within streams here an external crc/etc. +// is done to validate the data. The RawInflate apis can be used on data +// processed like this. + +/// Return an autoreleased NSData w/ the result of *raw* deflating the bytes. +// +// Uses the default compression level. +// *No* header is added to the resulting data. ++ (NSData *)gtm_dataByRawDeflatingBytes:(const void *)bytes + length:(NSUInteger)length __attribute__((deprecated("Use error variant"))); ++ (NSData *)gtm_dataByRawDeflatingBytes:(const void *)bytes + length:(NSUInteger)length + error:(NSError **)error; + +/// Return an autoreleased NSData w/ the result of *raw* deflating the payload of |data|. +// +// Uses the default compression level. +// *No* header is added to the resulting data. ++ (NSData *)gtm_dataByRawDeflatingData:(NSData *)data __attribute__((deprecated("Use error variant"))); ++ (NSData *)gtm_dataByRawDeflatingData:(NSData *)data + error:(NSError **)error; + +/// Return an autoreleased NSData w/ the result of *raw* deflating the bytes using |level| compression level. +// +// |level| can be 1-9, any other values will be clipped to that range. +// *No* header is added to the resulting data. ++ (NSData *)gtm_dataByRawDeflatingBytes:(const void *)bytes + length:(NSUInteger)length + compressionLevel:(int)level __attribute__((deprecated("Use error variant"))); ++ (NSData *)gtm_dataByRawDeflatingBytes:(const void *)bytes + length:(NSUInteger)length + compressionLevel:(int)level + error:(NSError **)error; + +/// Return an autoreleased NSData w/ the result of *raw* deflating the payload of |data| using |level| compression level. +// *No* header is added to the resulting data. ++ (NSData *)gtm_dataByRawDeflatingData:(NSData *)data + compressionLevel:(int)level __attribute__((deprecated("Use error variant"))); ++ (NSData *)gtm_dataByRawDeflatingData:(NSData *)data + compressionLevel:(int)level + error:(NSError **)error; + +/// Return an autoreleased NSData w/ the result of *raw* decompressing the bytes. +// +// The data to decompress, it should *not* have any header (zlib nor gzip). ++ (NSData *)gtm_dataByRawInflatingBytes:(const void *)bytes + length:(NSUInteger)length __attribute__((deprecated("Use error variant"))); ++ (NSData *)gtm_dataByRawInflatingBytes:(const void *)bytes + length:(NSUInteger)length + error:(NSError **)error; + +/// Return an autoreleased NSData w/ the result of *raw* decompressing the payload of |data|. +// +// The data to decompress, it should *not* have any header (zlib nor gzip). ++ (NSData *)gtm_dataByRawInflatingData:(NSData *)data __attribute__((deprecated("Use error variant"))); ++ (NSData *)gtm_dataByRawInflatingData:(NSData *)data + error:(NSError **)error; + +@end + +FOUNDATION_EXPORT NSString *const GTMNSDataZlibErrorDomain; +FOUNDATION_EXPORT NSString *const GTMNSDataZlibErrorKey; // NSNumber +FOUNDATION_EXPORT NSString *const GTMNSDataZlibRemainingBytesKey; // NSNumber + +typedef NS_ENUM(NSInteger, GTMNSDataZlibError) { + GTMNSDataZlibErrorGreaterThan32BitsToCompress = 1024, + // An internal zlib error. + // GTMNSDataZlibErrorKey will contain the error value. + // NSLocalizedDescriptionKey may contain an error string from zlib. + // Look in zlib.h for list of errors. + GTMNSDataZlibErrorInternal, + // There was left over data in the buffer that was not used. + // GTMNSDataZlibRemainingBytesKey will contain number of remaining bytes. + GTMNSDataZlibErrorDataRemaining +}; diff --git a/Pods/GoogleToolboxForMac/Foundation/GTMNSData+zlib.m b/Pods/GoogleToolboxForMac/Foundation/GTMNSData+zlib.m new file mode 100644 index 0000000..bf74b2d --- /dev/null +++ b/Pods/GoogleToolboxForMac/Foundation/GTMNSData+zlib.m @@ -0,0 +1,531 @@ +// +// GTMNSData+zlib.m +// +// Copyright 2007-2008 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy +// of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. +// + +#import "GTMNSData+zlib.h" +#import +#import "GTMDefines.h" + +#define kChunkSize 1024 + +NSString *const GTMNSDataZlibErrorDomain = @"com.google.GTMNSDataZlibErrorDomain"; +NSString *const GTMNSDataZlibErrorKey = @"GTMNSDataZlibErrorKey"; +NSString *const GTMNSDataZlibRemainingBytesKey = @"GTMNSDataZlibRemainingBytesKey"; + +typedef enum { + CompressionModeZlib, + CompressionModeGzip, + CompressionModeRaw, +} CompressionMode; + +@interface NSData (GTMZlibAdditionsPrivate) ++ (NSData *)gtm_dataByCompressingBytes:(const void *)bytes + length:(NSUInteger)length + compressionLevel:(int)level + mode:(CompressionMode)mode + error:(NSError **)error; ++ (NSData *)gtm_dataByInflatingBytes:(const void *)bytes + length:(NSUInteger)length + isRawData:(BOOL)isRawData + error:(NSError **)error; +@end + +@implementation NSData (GTMZlibAdditionsPrivate) + ++ (NSData *)gtm_dataByCompressingBytes:(const void *)bytes + length:(NSUInteger)length + compressionLevel:(int)level + mode:(CompressionMode)mode + error:(NSError **)error { + if (!bytes || !length) { + return nil; + } + +#if defined(__LP64__) && __LP64__ + // Don't support > 32bit length for 64 bit, see note in header. + if (length > UINT_MAX) { + if (error) { + *error = [NSError errorWithDomain:GTMNSDataZlibErrorDomain + code:GTMNSDataZlibErrorGreaterThan32BitsToCompress + userInfo:nil]; + } + return nil; + } +#endif + + if (level == Z_DEFAULT_COMPRESSION) { + // the default value is actually outside the range, so we have to let it + // through specifically. + } else if (level < Z_BEST_SPEED) { + level = Z_BEST_SPEED; + } else if (level > Z_BEST_COMPRESSION) { + level = Z_BEST_COMPRESSION; + } + + z_stream strm; + bzero(&strm, sizeof(z_stream)); + + int memLevel = 8; // the default + int windowBits = 15; // the default + switch (mode) { + case CompressionModeZlib: + // nothing to do + break; + + case CompressionModeGzip: + windowBits += 16; // enable gzip header instead of zlib header + break; + + case CompressionModeRaw: + windowBits *= -1; // Negative to mean no header. + break; + } + int retCode; + if ((retCode = deflateInit2(&strm, level, Z_DEFLATED, windowBits, + memLevel, Z_DEFAULT_STRATEGY)) != Z_OK) { + // COV_NF_START - no real way to force this in a unittest (we guard all args) + if (error) { + NSDictionary *userInfo = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:retCode] + forKey:GTMNSDataZlibErrorKey]; + *error = [NSError errorWithDomain:GTMNSDataZlibErrorDomain + code:GTMNSDataZlibErrorInternal + userInfo:userInfo]; + } + return nil; + // COV_NF_END + } + + // hint the size at 1/4 the input size + NSMutableData *result = [NSMutableData dataWithCapacity:(length/4)]; + unsigned char output[kChunkSize]; + + // setup the input + strm.avail_in = (unsigned int)length; + strm.next_in = (unsigned char*)bytes; + + // loop to collect the data + do { + // update what we're passing in + strm.avail_out = kChunkSize; + strm.next_out = output; + retCode = deflate(&strm, Z_FINISH); + if ((retCode != Z_OK) && (retCode != Z_STREAM_END)) { + // COV_NF_START - no real way to force this in a unittest + // (in inflate, we can feed bogus/truncated data to test, but an error + // here would be some internal issue w/in zlib, and there isn't any real + // way to test it) + if (error) { + NSDictionary *userInfo = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:retCode] + forKey:GTMNSDataZlibErrorKey]; + *error = [NSError errorWithDomain:GTMNSDataZlibErrorDomain + code:GTMNSDataZlibErrorInternal + userInfo:userInfo]; + } + deflateEnd(&strm); + return nil; + // COV_NF_END + } + // collect what we got + unsigned gotBack = kChunkSize - strm.avail_out; + if (gotBack > 0) { + [result appendBytes:output length:gotBack]; + } + + } while (retCode == Z_OK); + + // if the loop exits, we used all input and the stream ended + _GTMDevAssert(strm.avail_in == 0, + @"thought we finished deflate w/o using all input, %u bytes left", + strm.avail_in); + _GTMDevAssert(retCode == Z_STREAM_END, + @"thought we finished deflate w/o getting a result of stream end, code %d", + retCode); + + // clean up + deflateEnd(&strm); + + return result; +} // gtm_dataByCompressingBytes:length:compressionLevel:useGzip: + ++ (NSData *)gtm_dataByInflatingBytes:(const void *)bytes + length:(NSUInteger)length + isRawData:(BOOL)isRawData + error:(NSError **)error { + if (!bytes || !length) { + return nil; + } + +#if defined(__LP64__) && __LP64__ + // Don't support > 32bit length for 64 bit, see note in header. + if (length > UINT_MAX) { + return nil; + } +#endif + + z_stream strm; + bzero(&strm, sizeof(z_stream)); + + // setup the input + strm.avail_in = (unsigned int)length; + strm.next_in = (unsigned char*)bytes; + + int windowBits = 15; // 15 to enable any window size + if (isRawData) { + windowBits *= -1; // make it negative to signal no header. + } else { + windowBits += 32; // and +32 to enable zlib or gzip header detection. + } + + int retCode; + if ((retCode = inflateInit2(&strm, windowBits)) != Z_OK) { + // COV_NF_START - no real way to force this in a unittest (we guard all args) + if (error) { + NSDictionary *userInfo = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:retCode] + forKey:GTMNSDataZlibErrorKey]; + *error = [NSError errorWithDomain:GTMNSDataZlibErrorDomain + code:GTMNSDataZlibErrorInternal + userInfo:userInfo]; + } + return nil; + // COV_NF_END + } + + // hint the size at 4x the input size + NSMutableData *result = [NSMutableData dataWithCapacity:(length*4)]; + unsigned char output[kChunkSize]; + + // loop to collect the data + do { + // update what we're passing in + strm.avail_out = kChunkSize; + strm.next_out = output; + retCode = inflate(&strm, Z_NO_FLUSH); + if ((retCode != Z_OK) && (retCode != Z_STREAM_END)) { + if (error) { + NSMutableDictionary *userInfo = + [NSMutableDictionary dictionaryWithObject:[NSNumber numberWithInt:retCode] + forKey:GTMNSDataZlibErrorKey]; + if (strm.msg) { + NSString *message = [NSString stringWithUTF8String:strm.msg]; + if (message) { + [userInfo setObject:message forKey:NSLocalizedDescriptionKey]; + } + } + *error = [NSError errorWithDomain:GTMNSDataZlibErrorDomain + code:GTMNSDataZlibErrorInternal + userInfo:userInfo]; + } + inflateEnd(&strm); + return nil; + } + // collect what we got + unsigned gotBack = kChunkSize - strm.avail_out; + if (gotBack > 0) { + [result appendBytes:output length:gotBack]; + } + + } while (retCode == Z_OK); + + // make sure there wasn't more data tacked onto the end of a valid compressed + // stream. + if (strm.avail_in != 0) { + if (error) { + NSDictionary *userInfo = + [NSDictionary dictionaryWithObject:[NSNumber numberWithUnsignedInt:strm.avail_in] + forKey:GTMNSDataZlibRemainingBytesKey]; + *error = [NSError errorWithDomain:GTMNSDataZlibErrorDomain + code:GTMNSDataZlibErrorDataRemaining + userInfo:userInfo]; + } + result = nil; + } + // the only way out of the loop was by hitting the end of the stream + _GTMDevAssert(retCode == Z_STREAM_END, + @"thought we finished inflate w/o getting a result of stream end, code %d", + retCode); + + // clean up + inflateEnd(&strm); + + return result; +} // gtm_dataByInflatingBytes:length:windowBits: + +@end + + +@implementation NSData (GTMZLibAdditions) + ++ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes + length:(NSUInteger)length { + return [self gtm_dataByGzippingBytes:bytes length:length error:NULL]; +} // gtm_dataByGzippingBytes:length: + ++ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes + length:(NSUInteger)length + error:(NSError **)error { + return [self gtm_dataByCompressingBytes:bytes + length:length + compressionLevel:Z_DEFAULT_COMPRESSION + mode:CompressionModeGzip + error:error]; +} // gtm_dataByGzippingBytes:length:error: + ++ (NSData *)gtm_dataByGzippingData:(NSData *)data { + return [self gtm_dataByGzippingData:data error:NULL]; +} // gtm_dataByGzippingData: + ++ (NSData *)gtm_dataByGzippingData:(NSData *)data error:(NSError **)error { + return [self gtm_dataByCompressingBytes:[data bytes] + length:[data length] + compressionLevel:Z_DEFAULT_COMPRESSION + mode:CompressionModeGzip + error:error]; +} // gtm_dataByGzippingData:error: + ++ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes + length:(NSUInteger)length + compressionLevel:(int)level { + return [self gtm_dataByGzippingBytes:bytes + length:length + compressionLevel:level + error:NULL]; +} // gtm_dataByGzippingBytes:length:level: + ++ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes + length:(NSUInteger)length + compressionLevel:(int)level + error:(NSError **)error{ + return [self gtm_dataByCompressingBytes:bytes + length:length + compressionLevel:level + mode:CompressionModeGzip + error:error]; +} // gtm_dataByGzippingBytes:length:level:error + ++ (NSData *)gtm_dataByGzippingData:(NSData *)data + compressionLevel:(int)level { + return [self gtm_dataByGzippingData:data + compressionLevel:level + error:NULL]; +} // gtm_dataByGzippingData:level: + ++ (NSData *)gtm_dataByGzippingData:(NSData *)data + compressionLevel:(int)level + error:(NSError **)error{ + return [self gtm_dataByCompressingBytes:[data bytes] + length:[data length] + compressionLevel:level + mode:CompressionModeGzip + error:error]; +} // gtm_dataByGzippingData:level:error + +#pragma mark - + ++ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes + length:(NSUInteger)length { + return [self gtm_dataByDeflatingBytes:bytes + length:length + error:NULL]; +} // gtm_dataByDeflatingBytes:length: + ++ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes + length:(NSUInteger)length + error:(NSError **)error{ + return [self gtm_dataByCompressingBytes:bytes + length:length + compressionLevel:Z_DEFAULT_COMPRESSION + mode:CompressionModeZlib + error:error]; +} // gtm_dataByDeflatingBytes:length:error + ++ (NSData *)gtm_dataByDeflatingData:(NSData *)data { + return [self gtm_dataByDeflatingData:data error:NULL]; +} // gtm_dataByDeflatingData: + ++ (NSData *)gtm_dataByDeflatingData:(NSData *)data error:(NSError **)error { + return [self gtm_dataByCompressingBytes:[data bytes] + length:[data length] + compressionLevel:Z_DEFAULT_COMPRESSION + mode:CompressionModeZlib + error:error]; +} // gtm_dataByDeflatingData: + ++ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes + length:(NSUInteger)length + compressionLevel:(int)level { + return [self gtm_dataByDeflatingBytes:bytes + length:length + compressionLevel:level + error:NULL]; +} // gtm_dataByDeflatingBytes:length:level: + ++ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes + length:(NSUInteger)length + compressionLevel:(int)level + error:(NSError **)error { + return [self gtm_dataByCompressingBytes:bytes + length:length + compressionLevel:level + mode:CompressionModeZlib + error:error]; +} // gtm_dataByDeflatingBytes:length:level:error: + ++ (NSData *)gtm_dataByDeflatingData:(NSData *)data + compressionLevel:(int)level { + return [self gtm_dataByDeflatingData:data + compressionLevel:level + error:NULL]; +} // gtm_dataByDeflatingData:level: + ++ (NSData *)gtm_dataByDeflatingData:(NSData *)data + compressionLevel:(int)level + error:(NSError **)error { + return [self gtm_dataByCompressingBytes:[data bytes] + length:[data length] + compressionLevel:level + mode:CompressionModeZlib + error:error]; +} // gtm_dataByDeflatingData:level:error: + +#pragma mark - + ++ (NSData *)gtm_dataByInflatingBytes:(const void *)bytes + length:(NSUInteger)length { + return [self gtm_dataByInflatingBytes:bytes + length:length + error:NULL]; +} // gtm_dataByInflatingBytes:length: + ++ (NSData *)gtm_dataByInflatingBytes:(const void *)bytes + length:(NSUInteger)length + error:(NSError **)error { + return [self gtm_dataByInflatingBytes:bytes + length:length + isRawData:NO + error:error]; +} // gtm_dataByInflatingBytes:length:error: + ++ (NSData *)gtm_dataByInflatingData:(NSData *)data { + return [self gtm_dataByInflatingData:data error:NULL]; +} // gtm_dataByInflatingData: + ++ (NSData *)gtm_dataByInflatingData:(NSData *)data + error:(NSError **)error { + return [self gtm_dataByInflatingBytes:[data bytes] + length:[data length] + isRawData:NO + error:error]; +} // gtm_dataByInflatingData: + +#pragma mark - + ++ (NSData *)gtm_dataByRawDeflatingBytes:(const void *)bytes + length:(NSUInteger)length { + return [self gtm_dataByRawDeflatingBytes:(const void *)bytes + length:(NSUInteger)length + error:NULL]; +} // gtm_dataByRawDeflatingBytes:length: + ++ (NSData *)gtm_dataByRawDeflatingBytes:(const void *)bytes + length:(NSUInteger)length + error:(NSError **)error { + return [self gtm_dataByCompressingBytes:bytes + length:length + compressionLevel:Z_DEFAULT_COMPRESSION + mode:CompressionModeRaw + error:error]; +} // gtm_dataByRawDeflatingBytes:length:error: + ++ (NSData *)gtm_dataByRawDeflatingData:(NSData *)data { + return [self gtm_dataByRawDeflatingData:data error:NULL]; +} // gtm_dataByRawDeflatingData: + ++ (NSData *)gtm_dataByRawDeflatingData:(NSData *)data error:(NSError **)error { + return [self gtm_dataByCompressingBytes:[data bytes] + length:[data length] + compressionLevel:Z_DEFAULT_COMPRESSION + mode:CompressionModeRaw + error:error]; +} // gtm_dataByRawDeflatingData:error: + ++ (NSData *)gtm_dataByRawDeflatingBytes:(const void *)bytes + length:(NSUInteger)length + compressionLevel:(int)level { + return [self gtm_dataByRawDeflatingBytes:bytes + length:length + compressionLevel:level + error:NULL]; +} // gtm_dataByRawDeflatingBytes:length:compressionLevel: + ++ (NSData *)gtm_dataByRawDeflatingBytes:(const void *)bytes + length:(NSUInteger)length + compressionLevel:(int)level + error:(NSError **)error{ + return [self gtm_dataByCompressingBytes:bytes + length:length + compressionLevel:level + mode:CompressionModeRaw + error:error]; +} // gtm_dataByRawDeflatingBytes:length:compressionLevel:error: + ++ (NSData *)gtm_dataByRawDeflatingData:(NSData *)data + compressionLevel:(int)level { + return [self gtm_dataByRawDeflatingData:data + compressionLevel:level + error:NULL]; +} // gtm_dataByRawDeflatingData:compressionLevel: + ++ (NSData *)gtm_dataByRawDeflatingData:(NSData *)data + compressionLevel:(int)level + error:(NSError **)error { + return [self gtm_dataByCompressingBytes:[data bytes] + length:[data length] + compressionLevel:level + mode:CompressionModeRaw + error:error]; +} // gtm_dataByRawDeflatingData:compressionLevel:error: + ++ (NSData *)gtm_dataByRawInflatingBytes:(const void *)bytes + length:(NSUInteger)length { + return [self gtm_dataByInflatingBytes:bytes + length:length + error:NULL]; +} // gtm_dataByRawInflatingBytes:length: + ++ (NSData *)gtm_dataByRawInflatingBytes:(const void *)bytes + length:(NSUInteger)length + error:(NSError **)error{ + return [self gtm_dataByInflatingBytes:bytes + length:length + isRawData:YES + error:error]; +} // gtm_dataByRawInflatingBytes:length:error: + ++ (NSData *)gtm_dataByRawInflatingData:(NSData *)data { + return [self gtm_dataByRawInflatingData:data + error:NULL]; +} // gtm_dataByRawInflatingData: + ++ (NSData *)gtm_dataByRawInflatingData:(NSData *)data + error:(NSError **)error { + return [self gtm_dataByInflatingBytes:[data bytes] + length:[data length] + isRawData:YES + error:error]; +} // gtm_dataByRawInflatingData:error: + +@end diff --git a/Pods/GoogleToolboxForMac/GTMDefines.h b/Pods/GoogleToolboxForMac/GTMDefines.h new file mode 100644 index 0000000..7feb1cb --- /dev/null +++ b/Pods/GoogleToolboxForMac/GTMDefines.h @@ -0,0 +1,398 @@ +// +// GTMDefines.h +// +// Copyright 2008 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy +// of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. +// + +// ============================================================================ + +#include +#include + +#ifdef __OBJC__ +#include +#endif // __OBJC__ + +#if TARGET_OS_IPHONE +#include +#endif // TARGET_OS_IPHONE + +// ---------------------------------------------------------------------------- +// CPP symbols that can be overridden in a prefix to control how the toolbox +// is compiled. +// ---------------------------------------------------------------------------- + + +// By setting the GTM_CONTAINERS_VALIDATION_FAILED_LOG and +// GTM_CONTAINERS_VALIDATION_FAILED_ASSERT macros you can control what happens +// when a validation fails. If you implement your own validators, you may want +// to control their internals using the same macros for consistency. +#ifndef GTM_CONTAINERS_VALIDATION_FAILED_ASSERT + #define GTM_CONTAINERS_VALIDATION_FAILED_ASSERT 0 +#endif + +// Ensure __has_feature and __has_extension are safe to use. +// See http://clang-analyzer.llvm.org/annotations.html +#ifndef __has_feature // Optional. + #define __has_feature(x) 0 // Compatibility with non-clang compilers. +#endif + +#ifndef __has_extension + #define __has_extension __has_feature // Compatibility with pre-3.0 compilers. +#endif + +// Give ourselves a consistent way to do inlines. Apple's macros even use +// a few different actual definitions, so we're based off of the foundation +// one. +#if !defined(GTM_INLINE) + #if (defined (__GNUC__) && (__GNUC__ == 4)) || defined (__clang__) + #define GTM_INLINE static __inline__ __attribute__((always_inline)) + #else + #define GTM_INLINE static __inline__ + #endif +#endif + +// Give ourselves a consistent way of doing externs that links up nicely +// when mixing objc and objc++ +#if !defined (GTM_EXTERN) + #if defined __cplusplus + #define GTM_EXTERN extern "C" + #define GTM_EXTERN_C_BEGIN extern "C" { + #define GTM_EXTERN_C_END } + #else + #define GTM_EXTERN extern + #define GTM_EXTERN_C_BEGIN + #define GTM_EXTERN_C_END + #endif +#endif + +// Give ourselves a consistent way of exporting things if we have visibility +// set to hidden. +#if !defined (GTM_EXPORT) + #define GTM_EXPORT __attribute__((visibility("default"))) +#endif + +// Give ourselves a consistent way of declaring something as unused. This +// doesn't use __unused because that is only supported in gcc 4.2 and greater. +#if !defined (GTM_UNUSED) +#define GTM_UNUSED(x) ((void)(x)) +#endif + +// _GTMDevLog & _GTMDevAssert +// +// _GTMDevLog & _GTMDevAssert are meant to be a very lightweight shell for +// developer level errors. This implementation simply macros to NSLog/NSAssert. +// It is not intended to be a general logging/reporting system. +// +// Please see http://code.google.com/p/google-toolbox-for-mac/wiki/DevLogNAssert +// for a little more background on the usage of these macros. +// +// _GTMDevLog log some error/problem in debug builds +// _GTMDevAssert assert if condition isn't met w/in a method/function +// in all builds. +// +// To replace this system, just provide different macro definitions in your +// prefix header. Remember, any implementation you provide *must* be thread +// safe since this could be called by anything in what ever situtation it has +// been placed in. +// + +// Ignore the "Macro name is a reserved identifier" warning in this section +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreserved-id-macro" + +// We only define the simple macros if nothing else has defined this. +#ifndef _GTMDevLog + +#ifdef DEBUG + #define _GTMDevLog(...) NSLog(__VA_ARGS__) +#else + #define _GTMDevLog(...) do { } while (0) +#endif + +#endif // _GTMDevLog + +#ifndef _GTMDevAssert +// we directly invoke the NSAssert handler so we can pass on the varargs +// (NSAssert doesn't have a macro we can use that takes varargs) +#if !defined(NS_BLOCK_ASSERTIONS) + #define _GTMDevAssert(condition, ...) \ + do { \ + if (!(condition)) { \ + [[NSAssertionHandler currentHandler] \ + handleFailureInFunction:(NSString *) \ + [NSString stringWithUTF8String:__PRETTY_FUNCTION__] \ + file:(NSString *)[NSString stringWithUTF8String:__FILE__] \ + lineNumber:__LINE__ \ + description:__VA_ARGS__]; \ + } \ + } while(0) +#else // !defined(NS_BLOCK_ASSERTIONS) + #define _GTMDevAssert(condition, ...) do { } while (0) +#endif // !defined(NS_BLOCK_ASSERTIONS) + +#endif // _GTMDevAssert + +// _GTMCompileAssert +// +// Note: Software for current compilers should just use _Static_assert directly +// instead of this macro. +// +// _GTMCompileAssert is an assert that is meant to fire at compile time if you +// want to check things at compile instead of runtime. For example if you +// want to check that a wchar is 4 bytes instead of 2 you would use +// _GTMCompileAssert(sizeof(wchar_t) == 4, wchar_t_is_4_bytes_on_OS_X) +// Note that the second "arg" is not in quotes, and must be a valid processor +// symbol in it's own right (no spaces, punctuation etc). + +// Wrapping this in an #ifndef allows external groups to define their own +// compile time assert scheme. +#ifndef _GTMCompileAssert + #if __has_feature(c_static_assert) || __has_extension(c_static_assert) + #define _GTMCompileAssert(test, msg) _Static_assert((test), #msg) + #else + // Pre-Xcode 7 support. + // + // We got this technique from here: + // http://unixjunkie.blogspot.com/2007/10/better-compile-time-asserts_29.html + #define _GTMCompileAssertSymbolInner(line, msg) _GTMCOMPILEASSERT ## line ## __ ## msg + #define _GTMCompileAssertSymbol(line, msg) _GTMCompileAssertSymbolInner(line, msg) + #define _GTMCompileAssert(test, msg) \ + typedef char _GTMCompileAssertSymbol(__LINE__, msg) [ ((test) ? 1 : -1) ] + #endif // __has_feature(c_static_assert) || __has_extension(c_static_assert) +#endif // _GTMCompileAssert + +#pragma clang diagnostic pop + +// ---------------------------------------------------------------------------- +// CPP symbols defined based on the project settings so the GTM code has +// simple things to test against w/o scattering the knowledge of project +// setting through all the code. +// ---------------------------------------------------------------------------- + +// Provide a single constant CPP symbol that all of GTM uses for ifdefing +// iPhone code. +#if TARGET_OS_IPHONE // iPhone SDK + // For iPhone specific stuff + #define GTM_IPHONE_SDK 1 + #if TARGET_IPHONE_SIMULATOR + #define GTM_IPHONE_DEVICE 0 + #define GTM_IPHONE_SIMULATOR 1 + #else + #define GTM_IPHONE_DEVICE 1 + #define GTM_IPHONE_SIMULATOR 0 + #endif // TARGET_IPHONE_SIMULATOR + // By default, GTM has provided it's own unittesting support, define this + // to use the support provided by Xcode, especially for the Xcode4 support + // for unittesting. + #ifndef GTM_USING_XCTEST + #define GTM_USING_XCTEST 0 + #endif + #define GTM_MACOS_SDK 0 +#else + // For MacOS specific stuff + #define GTM_MACOS_SDK 1 + #define GTM_IPHONE_SDK 0 + #define GTM_IPHONE_SIMULATOR 0 + #define GTM_IPHONE_DEVICE 0 + #ifndef GTM_USING_XCTEST + #define GTM_USING_XCTEST 0 + #endif +#endif + +// Some of our own availability macros +#if GTM_MACOS_SDK +#define GTM_AVAILABLE_ONLY_ON_IPHONE UNAVAILABLE_ATTRIBUTE +#define GTM_AVAILABLE_ONLY_ON_MACOS +#else +#define GTM_AVAILABLE_ONLY_ON_IPHONE +#define GTM_AVAILABLE_ONLY_ON_MACOS UNAVAILABLE_ATTRIBUTE +#endif + +// GC was dropped by Apple, define the old constant incase anyone still keys +// off of it. +#ifndef GTM_SUPPORT_GC + #define GTM_SUPPORT_GC 0 +#endif + +// Some support for advanced clang static analysis functionality +#ifndef NS_RETURNS_RETAINED + #if __has_feature(attribute_ns_returns_retained) + #define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) + #else + #define NS_RETURNS_RETAINED + #endif +#endif + +#ifndef NS_RETURNS_NOT_RETAINED + #if __has_feature(attribute_ns_returns_not_retained) + #define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained)) + #else + #define NS_RETURNS_NOT_RETAINED + #endif +#endif + +#ifndef CF_RETURNS_RETAINED + #if __has_feature(attribute_cf_returns_retained) + #define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) + #else + #define CF_RETURNS_RETAINED + #endif +#endif + +#ifndef CF_RETURNS_NOT_RETAINED + #if __has_feature(attribute_cf_returns_not_retained) + #define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained)) + #else + #define CF_RETURNS_NOT_RETAINED + #endif +#endif + +#ifndef NS_CONSUMED + #if __has_feature(attribute_ns_consumed) + #define NS_CONSUMED __attribute__((ns_consumed)) + #else + #define NS_CONSUMED + #endif +#endif + +#ifndef CF_CONSUMED + #if __has_feature(attribute_cf_consumed) + #define CF_CONSUMED __attribute__((cf_consumed)) + #else + #define CF_CONSUMED + #endif +#endif + +#ifndef NS_CONSUMES_SELF + #if __has_feature(attribute_ns_consumes_self) + #define NS_CONSUMES_SELF __attribute__((ns_consumes_self)) + #else + #define NS_CONSUMES_SELF + #endif +#endif + +#ifndef GTM_NONNULL + #if defined(__has_attribute) + #if __has_attribute(nonnull) + #define GTM_NONNULL(x) __attribute__((nonnull x)) + #else + #define GTM_NONNULL(x) + #endif + #else + #define GTM_NONNULL(x) + #endif +#endif + +// Invalidates the initializer from which it's called. +#ifndef GTMInvalidateInitializer + #if __has_feature(objc_arc) + #define GTMInvalidateInitializer() \ + do { \ + [self class]; /* Avoid warning of dead store to |self|. */ \ + _GTMDevAssert(NO, @"Invalid initializer."); \ + return nil; \ + } while (0) + #else + #define GTMInvalidateInitializer() \ + do { \ + [self release]; \ + _GTMDevAssert(NO, @"Invalid initializer."); \ + return nil; \ + } while (0) + #endif +#endif + +#ifndef GTMCFAutorelease + // GTMCFAutorelease returns an id. In contrast, Apple's CFAutorelease returns + // a CFTypeRef. + #if __has_feature(objc_arc) + #define GTMCFAutorelease(x) CFBridgingRelease(x) + #else + #define GTMCFAutorelease(x) ([(id)x autorelease]) + #endif +#endif + +#ifdef __OBJC__ + + +// Macro to allow you to create NSStrings out of other macros. +// #define FOO foo +// NSString *fooString = GTM_NSSTRINGIFY(FOO); +#if !defined (GTM_NSSTRINGIFY) + #define GTM_NSSTRINGIFY_INNER(x) @#x + #define GTM_NSSTRINGIFY(x) GTM_NSSTRINGIFY_INNER(x) +#endif + +// Macro to allow fast enumeration when building for 10.5 or later, and +// reliance on NSEnumerator for 10.4. Remember, NSDictionary w/ FastEnumeration +// does keys, so pick the right thing, nothing is done on the FastEnumeration +// side to be sure you're getting what you wanted. +#ifndef GTM_FOREACH_OBJECT + #if TARGET_OS_IPHONE || !(MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) + #define GTM_FOREACH_ENUMEREE(element, enumeration) \ + for (element in enumeration) + #define GTM_FOREACH_OBJECT(element, collection) \ + for (element in collection) + #define GTM_FOREACH_KEY(element, collection) \ + for (element in collection) + #else + #define GTM_FOREACH_ENUMEREE(element, enumeration) \ + for (NSEnumerator *_ ## element ## _enum = enumeration; \ + (element = [_ ## element ## _enum nextObject]) != nil; ) + #define GTM_FOREACH_OBJECT(element, collection) \ + GTM_FOREACH_ENUMEREE(element, [collection objectEnumerator]) + #define GTM_FOREACH_KEY(element, collection) \ + GTM_FOREACH_ENUMEREE(element, [collection keyEnumerator]) + #endif +#endif + +// ============================================================================ + +// GTM_SEL_STRING is for specifying selector (usually property) names to KVC +// or KVO methods. +// In debug it will generate warnings for undeclared selectors if +// -Wunknown-selector is turned on. +// In release it will have no runtime overhead. +#ifndef GTM_SEL_STRING + #ifdef DEBUG + #define GTM_SEL_STRING(selName) NSStringFromSelector(@selector(selName)) + #else + #define GTM_SEL_STRING(selName) @#selName + #endif // DEBUG +#endif // GTM_SEL_STRING + +#ifndef GTM_WEAK +#if __has_feature(objc_arc_weak) + // With ARC enabled, __weak means a reference that isn't implicitly + // retained. __weak objects are accessed through runtime functions, so + // they are zeroed out, but this requires OS X 10.7+. + // At clang r251041+, ARC-style zeroing weak references even work in + // non-ARC mode. + #define GTM_WEAK __weak + #elif __has_feature(objc_arc) + // ARC, but targeting 10.6 or older, where zeroing weak references don't + // exist. + #define GTM_WEAK __unsafe_unretained + #else + // With manual reference counting, __weak used to be silently ignored. + // clang r251041 gives it the ARC semantics instead. This means they + // now require a deployment target of 10.7, while some clients of GTM + // still target 10.6. In these cases, expand to __unsafe_unretained instead + #define GTM_WEAK + #endif +#endif + +#endif // __OBJC__ diff --git a/Pods/GoogleToolboxForMac/LICENSE b/Pods/GoogleToolboxForMac/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/Pods/GoogleToolboxForMac/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Pods/GoogleToolboxForMac/README.md b/Pods/GoogleToolboxForMac/README.md new file mode 100644 index 0000000..710560a --- /dev/null +++ b/Pods/GoogleToolboxForMac/README.md @@ -0,0 +1,15 @@ +# GTM: Google Toolbox for Mac # + +**Project site**
+**Discussion group** + +# Google Toolbox for Mac # + +A collection of source from different Google projects that may be of use to +developers working other iOS or OS X projects. + +If you find a problem/bug or want a new feature to be included in the Google +Toolbox for Mac, please join the +[discussion group](http://groups.google.com/group/google-toolbox-for-mac) +or submit an +[issue](https://github.com/google/google-toolbox-for-mac/issues). diff --git a/Pods/Headers/Private/Firebase/Firebase.h b/Pods/Headers/Private/Firebase/Firebase.h new file mode 120000 index 0000000..6d62033 --- /dev/null +++ b/Pods/Headers/Private/Firebase/Firebase.h @@ -0,0 +1 @@ +../../../Firebase/Core/Sources/Firebase.h \ No newline at end of file diff --git a/Pods/Headers/Public/Firebase/Firebase.h b/Pods/Headers/Public/Firebase/Firebase.h new file mode 120000 index 0000000..6d62033 --- /dev/null +++ b/Pods/Headers/Public/Firebase/Firebase.h @@ -0,0 +1 @@ +../../../Firebase/Core/Sources/Firebase.h \ No newline at end of file diff --git a/Pods/Manifest.lock b/Pods/Manifest.lock new file mode 100644 index 0000000..17a1c16 --- /dev/null +++ b/Pods/Manifest.lock @@ -0,0 +1,51 @@ +PODS: + - Firebase/Core (4.10.1): + - FirebaseAnalytics (= 4.1.0) + - FirebaseCore (= 4.0.17) + - Firebase/Messaging (4.10.1): + - Firebase/Core + - FirebaseMessaging (= 2.1.1) + - FirebaseAnalytics (4.1.0): + - FirebaseCore (~> 4.0) + - FirebaseInstanceID (~> 2.0) + - GoogleToolboxForMac/NSData+zlib (~> 2.1) + - nanopb (~> 0.3) + - FirebaseCore (4.0.17): + - GoogleToolboxForMac/NSData+zlib (~> 2.1) + - FirebaseInstanceID (2.0.9): + - FirebaseCore (~> 4.0) + - FirebaseMessaging (2.1.1): + - FirebaseAnalytics (~> 4.1) + - FirebaseCore (~> 4.0) + - FirebaseInstanceID (~> 2.0) + - GoogleToolboxForMac/Logger (~> 2.1) + - Protobuf (~> 3.5) + - GoogleToolboxForMac/Defines (2.1.3) + - GoogleToolboxForMac/Logger (2.1.3): + - GoogleToolboxForMac/Defines (= 2.1.3) + - GoogleToolboxForMac/NSData+zlib (2.1.3): + - GoogleToolboxForMac/Defines (= 2.1.3) + - nanopb (0.3.8): + - nanopb/decode (= 0.3.8) + - nanopb/encode (= 0.3.8) + - nanopb/decode (0.3.8) + - nanopb/encode (0.3.8) + - Protobuf (3.5.0) + +DEPENDENCIES: + - Firebase/Core + - Firebase/Messaging + +SPEC CHECKSUMS: + Firebase: 92c6ba593e32db0defde464a9adc981d5cb49f97 + FirebaseAnalytics: 3dfae28d4a5e06f86c4fae830efc2ad3fadb19bc + FirebaseCore: 872307b001bbefda1dfa0dbfffa50a6919023d4a + FirebaseInstanceID: d2058a35e9bebda1b6dd42486b84917bde552a9d + FirebaseMessaging: db0e01c52ef7e1f42846431273558107d084ede4 + GoogleToolboxForMac: 2501e2ad72a52eb3dfe7bd9aee7dad11b858bd20 + nanopb: 5601e6bca2dbf1ed831b519092ec110f66982ca3 + Protobuf: 8a9838fba8dae3389230e1b7f8c104aa32389c03 + +PODFILE CHECKSUM: 520344186de1f29c76e02112d62a271448eeb812 + +COCOAPODS: 1.4.0 diff --git a/Pods/Pods.xcodeproj/project.pbxproj b/Pods/Pods.xcodeproj/project.pbxproj new file mode 100644 index 0000000..3fe4d31 --- /dev/null +++ b/Pods/Pods.xcodeproj/project.pbxproj @@ -0,0 +1,1314 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 48; + objects = { + +/* Begin PBXBuildFile section */ + 005F122640E596BCF9FB2F69301A4A60 /* GPBArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EAA66A40D00BCDDAFA9980382C5EFE5 /* GPBArray.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 00C8CE9CC4B65A854791DA13EB48E36E /* Duration.pbobjc.h in Headers */ = {isa = PBXBuildFile; fileRef = 71A6141A265F1200FDB8C322ABDFCA68 /* Duration.pbobjc.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 024A1055AE4E24CC2DDD0CC837967F04 /* GPBUnknownFieldSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 43E593E914104CD3E053067B1846D1D6 /* GPBUnknownFieldSet.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 05B1F02560378D28FEBD4E8F6D293216 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6604A7D69453B4569E4E4827FB9155A9 /* Foundation.framework */; }; + 09CD20DE09A0C391E0758E63119C0EF2 /* GPBUnknownField_PackagePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 706067214A1D2C83160ECC67D7A81532 /* GPBUnknownField_PackagePrivate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 0EF7E91EDBD652DCA1F1EC8F3C05BA6A /* GPBDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = BD1A2BBAD2055349C4437BDC00A6CF8C /* GPBDictionary.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 0FF8F27F896850DB2973C4E26EC1F7EE /* GTMLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = C0D299A612F2D918CE551356F29ACE30 /* GTMLogger.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 10E51A61F26262D05DACFB163D3E29F0 /* GPBProtocolBuffers_RuntimeSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B5BAFA46BC181767A862E6938B99A34 /* GPBProtocolBuffers_RuntimeSupport.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 1859784693CCBF663C5FBA89F35E8C27 /* Timestamp.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = C776E3ABFC2BBFE5545FC0D9297965FD /* Timestamp.pbobjc.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + 1B557B3C2D08812052F12F7A5CE4D03E /* Protobuf-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F986C5684FCA499C9169BC3145E8020 /* Protobuf-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 1D8AFFE2FE9AA484D5834350A611666D /* GPBDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = CB1CD1E5B688F08EB41849E108B4FCC1 /* GPBDictionary.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + 1DC8E6457E99AD68C57172B12E1B9F97 /* Empty.pbobjc.h in Headers */ = {isa = PBXBuildFile; fileRef = 438EF475DB0778433B652BD0549C31BC /* Empty.pbobjc.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 20663455819141BE327880FE3C920E12 /* GPBUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 17370EC62F8E267340F264F1EEC678F4 /* GPBUtilities.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + 2158693325BF85C0ED7192EF99F5C221 /* Api.pbobjc.h in Headers */ = {isa = PBXBuildFile; fileRef = DB7E1E90DE520241ADA1A6C0B6113944 /* Api.pbobjc.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 22A8E87C6218934767B12E02EEAF6471 /* FieldMask.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 521BC722698B961EC91296CC2DAE0E7B /* FieldMask.pbobjc.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + 244EDBFE34EE389E15CF20677AFC9B44 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6604A7D69453B4569E4E4827FB9155A9 /* Foundation.framework */; }; + 2970006B18A8D60F33AC073823312B53 /* Any.pbobjc.h in Headers */ = {isa = PBXBuildFile; fileRef = A663BCCCCC8C10CD1D45CD87BF708E9D /* Any.pbobjc.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 298B5D53627833DA13D67DE7893106C1 /* Struct.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 583299AD2746D1A7CB87676206BA7869 /* Struct.pbobjc.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + 299C42158BACE311D1558C3322D7619D /* Empty.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 078C2456FCD47F0D5F451DB0451A5CD0 /* Empty.pbobjc.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + 29FEADDF2086FDEA7D5BA87DD23B08C6 /* pb_decode.h in Headers */ = {isa = PBXBuildFile; fileRef = DC80E859B98A9DA7B7271B94572C1998 /* pb_decode.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 2B989D21EF69C88123AC04EB3E996AFA /* GPBUnknownField.h in Headers */ = {isa = PBXBuildFile; fileRef = 8E23C54F83CF004274E96571BA64E535 /* GPBUnknownField.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 2D3FB6CFC1A410938494EAED75370AB0 /* GPBWellKnownTypes.m in Sources */ = {isa = PBXBuildFile; fileRef = 04F3C29B3DD07E8819E5F39B92CEABD5 /* GPBWellKnownTypes.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + 2F6E6BF4DE2493557030F5950D10DCD1 /* Wrappers.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = FB4A3DD045EEE6E7CD8C286A131C7840 /* Wrappers.pbobjc.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + 392F2CF142BAA751AC1BB61D8B757D98 /* pb.h in Headers */ = {isa = PBXBuildFile; fileRef = 93DA288616C1B9F6E4D4C77D659AE164 /* pb.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3A50F5C8ECED9627F2EBD97F61BD376D /* pb_common.c in Sources */ = {isa = PBXBuildFile; fileRef = 118009AA37FA4346270ACC42C9444F35 /* pb_common.c */; settings = {COMPILER_FLAGS = "-fno-objc-arc -fno-objc-arc -fno-objc-arc"; }; }; + 3A692A21E1F0F0E99606FA3C55B4A5ED /* GPBCodedOutputStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 150CB46C4295EF02B5708C8877460ED2 /* GPBCodedOutputStream.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3A6957F43DF00B4A2074ADB669E3A489 /* SourceContext.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = B546797C90A2C615CFCC2DF1C5A30668 /* SourceContext.pbobjc.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + 3E3B4CF239527A39CD308EBA9676FD8F /* GTMDefines.h in Headers */ = {isa = PBXBuildFile; fileRef = DABF35642DA97C73DF0196A6AE304131 /* GTMDefines.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 466CC6ADCC9A9BC12E7FE08BE123D395 /* Api.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = C3C2FD839C4EE12CB542AEEDF6A4E860 /* Api.pbobjc.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + 468DFD90B6C4DA2F7CFA0C1C89F1B615 /* nanopb-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 275D3BDF234DECB073B4090E8841201B /* nanopb-dummy.m */; }; + 481D8AF4ED895F0B4FCF134A763A7F04 /* GPBCodedInputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 78F40EF10B48E25F6E8DAC46B6A11075 /* GPBCodedInputStream.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + 4D90A812BD7E64537BC87CCFF0410008 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6604A7D69453B4569E4E4827FB9155A9 /* Foundation.framework */; }; + 54F580BF4588159D6A61F21D15591805 /* pb_decode.c in Sources */ = {isa = PBXBuildFile; fileRef = 5F4630967F9078CD627B1D99C1A10BE4 /* pb_decode.c */; settings = {COMPILER_FLAGS = "-fno-objc-arc -fno-objc-arc"; }; }; + 554FEFCBC7B4F81FA40B1CBE88760112 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6604A7D69453B4569E4E4827FB9155A9 /* Foundation.framework */; }; + 557F59E2029A338A443017E5A13026A4 /* Any.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 65775860CC7E4A14598465C220D69AD6 /* Any.pbobjc.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + 55A828B233D68FEAFF6A8C5764A1D679 /* GPBExtensionInternals.h in Headers */ = {isa = PBXBuildFile; fileRef = 0D53CD0966D446BB27A386ADE82F5986 /* GPBExtensionInternals.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 55D8D5D912CFD2F3584E4553C2EAD734 /* pb_encode.c in Sources */ = {isa = PBXBuildFile; fileRef = 5966CD35E8E1CA1370318AAF93CAA559 /* pb_encode.c */; settings = {COMPILER_FLAGS = "-fno-objc-arc -fno-objc-arc"; }; }; + 64418457D16D9A2F28F496AC75FC7DBD /* GoogleToolboxForMac-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 18D4918C3B7E0E773D49B9CC6FA05C08 /* GoogleToolboxForMac-dummy.m */; }; + 6901FD5494D2B83DB9733A4216B6DB89 /* Type.pbobjc.h in Headers */ = {isa = PBXBuildFile; fileRef = AAB904A66A97657A417858F629E4BDBB /* Type.pbobjc.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 6D9E3153A382215CA76B2F5E42A58F3D /* GPBDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 8101B3542E53B336F9F4400B26F420C4 /* GPBDescriptor.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 7046C0C5D91A2542B96DB8BACB02D1EE /* GPBDictionary_PackagePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 4275C1C5335CDDE1B258C5A079A5A80A /* GPBDictionary_PackagePrivate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 7178E85121EBD1B85098ACFDBC50AE14 /* GPBMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = DC0A29912E2160ABE67FD84CF71554F7 /* GPBMessage.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + 71B0CD9FA26C16BF2025DF8307753832 /* GPBMessage_PackagePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = E978C30D521776F749F32DBA8A32171E /* GPBMessage_PackagePrivate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 73DA46214E4239838DA3195AB0B31AEA /* FieldMask.pbobjc.h in Headers */ = {isa = PBXBuildFile; fileRef = D0E674497A291E43F5E9F55C2632494B /* FieldMask.pbobjc.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 755F55A7D577254B73EA7FEABA8E98E0 /* GTMNSData+zlib.h in Headers */ = {isa = PBXBuildFile; fileRef = A3EE3CEF83C7CA2113DD9AC2C729EFE8 /* GTMNSData+zlib.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 7877B41A017A28D30ACB5B91341E4431 /* GPBRuntimeTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 28EECC6BF40C5EA45BFF83FE5AF5F71D /* GPBRuntimeTypes.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 7990E263A60AFE85F85EDE5342E3A89B /* Wrappers.pbobjc.h in Headers */ = {isa = PBXBuildFile; fileRef = 560200B2128B8D052AF32F058B0F040C /* Wrappers.pbobjc.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 79EBBA7401842D8A29A8D4E6A3CFD683 /* GPBWireFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A5489280EF08E11BAF5B73674732D68 /* GPBWireFormat.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 7A51235C98D3B3FE0D7191935F138185 /* GPBDescriptor.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C638EBD5977EB01B99417235D03A50E /* GPBDescriptor.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + 806BAA4E00218D70995697C4400BE7A0 /* pb_common.h in Headers */ = {isa = PBXBuildFile; fileRef = C92B3AD174BFA16CEFBD14B1D4A69E1D /* pb_common.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9101CEA8562055177732244271008BBB /* GTMNSData+zlib.m in Sources */ = {isa = PBXBuildFile; fileRef = D6964F57B6D94F25DA10FF4503E85481 /* GTMNSData+zlib.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 973C7A5D628861BF9B19946F756D7569 /* GPBExtensionRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = BBECC2042DA3223E3CB65BA6BA633BD1 /* GPBExtensionRegistry.h */; settings = {ATTRIBUTES = (Public, ); }; }; + A4E9183C55E8AAC3C5907A6672D0DE4D /* Timestamp.pbobjc.h in Headers */ = {isa = PBXBuildFile; fileRef = F099D52BA60EA489DE895E5D72AA19A6 /* Timestamp.pbobjc.h */; settings = {ATTRIBUTES = (Public, ); }; }; + A793B4E7138EF931FE06731CFCB91D44 /* GPBCodedInputStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 525A1155D76DD372BF4D14A7C62EFE2B /* GPBCodedInputStream.h */; settings = {ATTRIBUTES = (Public, ); }; }; + A92E3880E04FEE3543BA49528ACAFD19 /* GPBBootstrap.h in Headers */ = {isa = PBXBuildFile; fileRef = 8AA8E7BCC056F17BBC59455F2B2AE698 /* GPBBootstrap.h */; settings = {ATTRIBUTES = (Public, ); }; }; + AA1C43C98991B8340DA1B5BB1AA08384 /* Protobuf-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 2F88A0DF907BBA0BE797159BD516BE9B /* Protobuf-dummy.m */; }; + AB4F0970071E34D0384341466E0468EF /* GTMLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = AD4DF62AE6E9D48CC565A462F3E7D6B8 /* GTMLogger.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + AF1438A8E738822AF659CCF1C67BA8F6 /* GPBDescriptor_PackagePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 6826DD97E13D633637D07F71E9D54149 /* GPBDescriptor_PackagePrivate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + B11C079EE8D1F033D6676D202194BB15 /* GPBRootObject_PackagePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5F39363075D40A959F49BF3F1DEAEAD9 /* GPBRootObject_PackagePrivate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + B30051007B4B3612DBE1267E684F22A8 /* GPBUnknownField.m in Sources */ = {isa = PBXBuildFile; fileRef = 19ED33F0E3F2BA72AAF13956DDD993D2 /* GPBUnknownField.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B3E44A13F7891D98191658404A5E1082 /* GPBArray.m in Sources */ = {isa = PBXBuildFile; fileRef = 10D791D354EEA6581EB63DB68BC4A2DC /* GPBArray.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B59397FE31968166B84D1CDFB72A278E /* GPBExtensionInternals.m in Sources */ = {isa = PBXBuildFile; fileRef = DE37671E3CE008D2C4F011CCAA537B94 /* GPBExtensionInternals.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B70F203762CB2D29EF9600BC81CC55AE /* Type.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = EB5E83FF21267268429230A4C0F31D55 /* Type.pbobjc.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + BCB54AA8CF9ED70872A297BA1072477D /* GPBRootObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 98F849B4AB7E52FFFA1C80B3F63D3D55 /* GPBRootObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; + BF7A350136A042ABC44DEFE8E0166CC6 /* Duration.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = AB2FC4B13DA3ED00D8E226FF12A2F049 /* Duration.pbobjc.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + C37587D9A8D8082A65E0AF46EF076C0C /* GPBUnknownFieldSet_PackagePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C09A14639AA0AA4621A68CD4A43EC7E /* GPBUnknownFieldSet_PackagePrivate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C6F1C82FF1FF4BC974A01A73581795C8 /* GPBArray_PackagePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = A601D5266CD3A602585428F47C4DEC47 /* GPBArray_PackagePrivate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C74203D65B261DFAEE019E63625BA83A /* GPBUtilities_PackagePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 009A0427C75AF5D23AFBC0E2827D044C /* GPBUtilities_PackagePrivate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C80E6B366AEAAAF7C631D8D5237AE674 /* Struct.pbobjc.h in Headers */ = {isa = PBXBuildFile; fileRef = 582254AC879DA04855DF9AFCCE8025C5 /* Struct.pbobjc.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CC2EBC559F108EC7A3FA6250621F1033 /* Pods-blista-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = CED16CD69EB751E5A41BB48C5B47E146 /* Pods-blista-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CE22A61ACE083D457A4D1383A6AB6420 /* GPBCodedOutputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = A5F61877B4545A262CF5085CBDD39415 /* GPBCodedOutputStream.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + D11C2923A287AFF21EEDC0503F4B69B9 /* GPBWellKnownTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 526F4C967930411842B1FFA671D0E137 /* GPBWellKnownTypes.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D2DA4A606F790F472F6D2FEB3F578365 /* Pods-blista-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 477CA59422C8A33AAF5782D746737ADD /* Pods-blista-dummy.m */; }; + D537D2EC858FEEF10CEA9849CDCC5876 /* GPBRootObject.m in Sources */ = {isa = PBXBuildFile; fileRef = B126EE8CE607140080ACD69440685729 /* GPBRootObject.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + DC8CBE8BF7A6B62FA70B94C96505FC10 /* GPBMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = FBD37FFAE7D4C5D20F561962012FBA1C /* GPBMessage.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DD44DB93CD656A9E416F06134146945C /* GPBCodedInputStream_PackagePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 88C5C98B2A20198E1A021A9B9E87AC93 /* GPBCodedInputStream_PackagePrivate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DF242C694455B99CCDF641A421770692 /* GPBWireFormat.m in Sources */ = {isa = PBXBuildFile; fileRef = 4804E7138784E758FD912EA5D97BBEBD /* GPBWireFormat.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + E162B50E1BA950D17D1C18AE93A4CBC3 /* GPBUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = A6BAADCDCED5F2D192A56B27A30E98E7 /* GPBUtilities.h */; settings = {ATTRIBUTES = (Public, ); }; }; + E181395E73163EB702FCE9A21403D67B /* pb_encode.h in Headers */ = {isa = PBXBuildFile; fileRef = B5C0A5327E2B8DF1ADAFCEFBC8B60FF9 /* pb_encode.h */; settings = {ATTRIBUTES = (Public, ); }; }; + ED66F8BD1D43065D931F2C8890806447 /* GoogleToolboxForMac-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 255AA68EA1A1FC9FC56FAA63D074B951 /* GoogleToolboxForMac-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + F0EB9B317AC7C42299372CB1770E6228 /* GPBCodedOutputStream_PackagePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F245333671E568786F9B4457145481 /* GPBCodedOutputStream_PackagePrivate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + F2FCB4AE76C0E26F8FB4379F15C65AB0 /* GPBExtensionRegistry.m in Sources */ = {isa = PBXBuildFile; fileRef = F3D833AF41A8B219394C6478DBA6C6A6 /* GPBExtensionRegistry.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + F6A9A77857DC54C33B4156A53D5092E0 /* GPBUnknownFieldSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 53B1495973908531CF1CB45182726F21 /* GPBUnknownFieldSet.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + F969FD29C03C52D226A05379E04538A7 /* SourceContext.pbobjc.h in Headers */ = {isa = PBXBuildFile; fileRef = 53491A5744D0D2B7C020BD94CAE19859 /* SourceContext.pbobjc.h */; settings = {ATTRIBUTES = (Public, ); }; }; + F9D92BA503505CB48EF4ECF0DDF57686 /* nanopb-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = EDB4CF9FB34DD0DD7B85005AEB39585B /* nanopb-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + FC05F14A2061FBCA8B9D73C4F535A41B /* GPBProtocolBuffers.h in Headers */ = {isa = PBXBuildFile; fileRef = 98CB3F3811553A7F960661239DC4CD50 /* GPBProtocolBuffers.h */; settings = {ATTRIBUTES = (Public, ); }; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 0CB1B932A732061694711658079D44F5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = C5B80060FE8C664DF08841000F41D515; + remoteInfo = GoogleToolboxForMac; + }; + EB1A3A836DC988E492CAD1ED1B9E571F /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 989C940C959E8F0FA69E534D266A74FA; + remoteInfo = Protobuf; + }; + EEAF7FB8643F05F2618791F00AD673F1 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = E4DD95323C54A78F879DAB0F1508B8E7; + remoteInfo = nanopb; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 009A0427C75AF5D23AFBC0E2827D044C /* GPBUtilities_PackagePrivate.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBUtilities_PackagePrivate.h; path = objectivec/GPBUtilities_PackagePrivate.h; sourceTree = ""; }; + 03A877C6F9A7643363DA488FB3166DEE /* GoogleToolboxForMac.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = GoogleToolboxForMac.framework; path = GoogleToolboxForMac.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 04F245333671E568786F9B4457145481 /* GPBCodedOutputStream_PackagePrivate.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBCodedOutputStream_PackagePrivate.h; path = objectivec/GPBCodedOutputStream_PackagePrivate.h; sourceTree = ""; }; + 04F3C29B3DD07E8819E5F39B92CEABD5 /* GPBWellKnownTypes.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = GPBWellKnownTypes.m; path = objectivec/GPBWellKnownTypes.m; sourceTree = ""; }; + 059AE92B7A25B96D00E022D5FDC830AB /* Pods-blista.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-blista.debug.xcconfig"; sourceTree = ""; }; + 078C2456FCD47F0D5F451DB0451A5CD0 /* Empty.pbobjc.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = Empty.pbobjc.m; path = objectivec/google/protobuf/Empty.pbobjc.m; sourceTree = ""; }; + 0D53CD0966D446BB27A386ADE82F5986 /* GPBExtensionInternals.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBExtensionInternals.h; path = objectivec/GPBExtensionInternals.h; sourceTree = ""; }; + 10B3E378AC648B4D56391259DB59BC36 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 10D791D354EEA6581EB63DB68BC4A2DC /* GPBArray.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = GPBArray.m; path = objectivec/GPBArray.m; sourceTree = ""; }; + 118009AA37FA4346270ACC42C9444F35 /* pb_common.c */ = {isa = PBXFileReference; includeInIndex = 1; path = pb_common.c; sourceTree = ""; }; + 150CB46C4295EF02B5708C8877460ED2 /* GPBCodedOutputStream.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBCodedOutputStream.h; path = objectivec/GPBCodedOutputStream.h; sourceTree = ""; }; + 1718449A5DBFDAF35B2DE024A5265616 /* GoogleToolboxForMac-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "GoogleToolboxForMac-prefix.pch"; sourceTree = ""; }; + 17370EC62F8E267340F264F1EEC678F4 /* GPBUtilities.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = GPBUtilities.m; path = objectivec/GPBUtilities.m; sourceTree = ""; }; + 18D4918C3B7E0E773D49B9CC6FA05C08 /* GoogleToolboxForMac-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "GoogleToolboxForMac-dummy.m"; sourceTree = ""; }; + 19ED33F0E3F2BA72AAF13956DDD993D2 /* GPBUnknownField.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = GPBUnknownField.m; path = objectivec/GPBUnknownField.m; sourceTree = ""; }; + 1C638EBD5977EB01B99417235D03A50E /* GPBDescriptor.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = GPBDescriptor.m; path = objectivec/GPBDescriptor.m; sourceTree = ""; }; + 255AA68EA1A1FC9FC56FAA63D074B951 /* GoogleToolboxForMac-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "GoogleToolboxForMac-umbrella.h"; sourceTree = ""; }; + 275D3BDF234DECB073B4090E8841201B /* nanopb-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "nanopb-dummy.m"; sourceTree = ""; }; + 27E70B8C269ABF68FF4FF52C7958629F /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 28EECC6BF40C5EA45BFF83FE5AF5F71D /* GPBRuntimeTypes.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBRuntimeTypes.h; path = objectivec/GPBRuntimeTypes.h; sourceTree = ""; }; + 2EAA66A40D00BCDDAFA9980382C5EFE5 /* GPBArray.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBArray.h; path = objectivec/GPBArray.h; sourceTree = ""; }; + 2F88A0DF907BBA0BE797159BD516BE9B /* Protobuf-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Protobuf-dummy.m"; sourceTree = ""; }; + 34F5B0E5E4634A77852A79FEA3A0CF7E /* Protobuf.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = Protobuf.modulemap; sourceTree = ""; }; + 35F1616642044C0B422A4495D8D16D35 /* GoogleToolboxForMac.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = GoogleToolboxForMac.xcconfig; sourceTree = ""; }; + 3BF6608EEF845F99E00B23B7D6CA8709 /* nanopb.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = nanopb.modulemap; sourceTree = ""; }; + 4275C1C5335CDDE1B258C5A079A5A80A /* GPBDictionary_PackagePrivate.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBDictionary_PackagePrivate.h; path = objectivec/GPBDictionary_PackagePrivate.h; sourceTree = ""; }; + 438EF475DB0778433B652BD0549C31BC /* Empty.pbobjc.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = Empty.pbobjc.h; path = objectivec/google/protobuf/Empty.pbobjc.h; sourceTree = ""; }; + 43E593E914104CD3E053067B1846D1D6 /* GPBUnknownFieldSet.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBUnknownFieldSet.h; path = objectivec/GPBUnknownFieldSet.h; sourceTree = ""; }; + 477CA59422C8A33AAF5782D746737ADD /* Pods-blista-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-blista-dummy.m"; sourceTree = ""; }; + 4804E7138784E758FD912EA5D97BBEBD /* GPBWireFormat.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = GPBWireFormat.m; path = objectivec/GPBWireFormat.m; sourceTree = ""; }; + 4A5489280EF08E11BAF5B73674732D68 /* GPBWireFormat.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBWireFormat.h; path = objectivec/GPBWireFormat.h; sourceTree = ""; }; + 4A6A87F0960C8A1AE2904490CFA1BE32 /* FirebaseCoreDiagnostics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FirebaseCoreDiagnostics.framework; path = Frameworks/FirebaseCoreDiagnostics.framework; sourceTree = ""; }; + 4C09A14639AA0AA4621A68CD4A43EC7E /* GPBUnknownFieldSet_PackagePrivate.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBUnknownFieldSet_PackagePrivate.h; path = objectivec/GPBUnknownFieldSet_PackagePrivate.h; sourceTree = ""; }; + 5214596CD4BA23B42F0B732B386D4F81 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 521BC722698B961EC91296CC2DAE0E7B /* FieldMask.pbobjc.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = FieldMask.pbobjc.m; path = objectivec/google/protobuf/FieldMask.pbobjc.m; sourceTree = ""; }; + 525A1155D76DD372BF4D14A7C62EFE2B /* GPBCodedInputStream.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBCodedInputStream.h; path = objectivec/GPBCodedInputStream.h; sourceTree = ""; }; + 526F4C967930411842B1FFA671D0E137 /* GPBWellKnownTypes.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBWellKnownTypes.h; path = objectivec/GPBWellKnownTypes.h; sourceTree = ""; }; + 53491A5744D0D2B7C020BD94CAE19859 /* SourceContext.pbobjc.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SourceContext.pbobjc.h; path = objectivec/google/protobuf/SourceContext.pbobjc.h; sourceTree = ""; }; + 53B1495973908531CF1CB45182726F21 /* GPBUnknownFieldSet.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = GPBUnknownFieldSet.m; path = objectivec/GPBUnknownFieldSet.m; sourceTree = ""; }; + 560200B2128B8D052AF32F058B0F040C /* Wrappers.pbobjc.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = Wrappers.pbobjc.h; path = objectivec/google/protobuf/Wrappers.pbobjc.h; sourceTree = ""; }; + 582254AC879DA04855DF9AFCCE8025C5 /* Struct.pbobjc.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = Struct.pbobjc.h; path = objectivec/google/protobuf/Struct.pbobjc.h; sourceTree = ""; }; + 583299AD2746D1A7CB87676206BA7869 /* Struct.pbobjc.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = Struct.pbobjc.m; path = objectivec/google/protobuf/Struct.pbobjc.m; sourceTree = ""; }; + 5966CD35E8E1CA1370318AAF93CAA559 /* pb_encode.c */ = {isa = PBXFileReference; includeInIndex = 1; path = pb_encode.c; sourceTree = ""; }; + 5DA9C0688ECC6AD8AFD02E88E49169BD /* Pods-blista-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-blista-acknowledgements.markdown"; sourceTree = ""; }; + 5EB5976B411EC5A085D396BA0D3EC840 /* Pods-blista-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-blista-frameworks.sh"; sourceTree = ""; }; + 5F39363075D40A959F49BF3F1DEAEAD9 /* GPBRootObject_PackagePrivate.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBRootObject_PackagePrivate.h; path = objectivec/GPBRootObject_PackagePrivate.h; sourceTree = ""; }; + 5F4630967F9078CD627B1D99C1A10BE4 /* pb_decode.c */ = {isa = PBXFileReference; includeInIndex = 1; path = pb_decode.c; sourceTree = ""; }; + 65775860CC7E4A14598465C220D69AD6 /* Any.pbobjc.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = Any.pbobjc.m; path = objectivec/google/protobuf/Any.pbobjc.m; sourceTree = ""; }; + 6604A7D69453B4569E4E4827FB9155A9 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; + 6826DD97E13D633637D07F71E9D54149 /* GPBDescriptor_PackagePrivate.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBDescriptor_PackagePrivate.h; path = objectivec/GPBDescriptor_PackagePrivate.h; sourceTree = ""; }; + 6FFC273E888F0E8EC0BA880316898998 /* Pods-blista.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = "Pods-blista.modulemap"; sourceTree = ""; }; + 706067214A1D2C83160ECC67D7A81532 /* GPBUnknownField_PackagePrivate.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBUnknownField_PackagePrivate.h; path = objectivec/GPBUnknownField_PackagePrivate.h; sourceTree = ""; }; + 71A6141A265F1200FDB8C322ABDFCA68 /* Duration.pbobjc.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = Duration.pbobjc.h; path = objectivec/google/protobuf/Duration.pbobjc.h; sourceTree = ""; }; + 78F40EF10B48E25F6E8DAC46B6A11075 /* GPBCodedInputStream.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = GPBCodedInputStream.m; path = objectivec/GPBCodedInputStream.m; sourceTree = ""; }; + 7E1F040B1AAEB5DB7BAC1434E7A0557C /* Protobuf.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Protobuf.xcconfig; sourceTree = ""; }; + 8101B3542E53B336F9F4400B26F420C4 /* GPBDescriptor.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBDescriptor.h; path = objectivec/GPBDescriptor.h; sourceTree = ""; }; + 810933C7850ACA946DD4CD41DF2E6760 /* Firebase.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = Firebase.h; path = Core/Sources/Firebase.h; sourceTree = ""; }; + 88C5C98B2A20198E1A021A9B9E87AC93 /* GPBCodedInputStream_PackagePrivate.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBCodedInputStream_PackagePrivate.h; path = objectivec/GPBCodedInputStream_PackagePrivate.h; sourceTree = ""; }; + 8AA8E7BCC056F17BBC59455F2B2AE698 /* GPBBootstrap.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBBootstrap.h; path = objectivec/GPBBootstrap.h; sourceTree = ""; }; + 8D9AB3207FA19BA926AEC7A9C19BA0A2 /* FirebaseNanoPB.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FirebaseNanoPB.framework; path = Frameworks/FirebaseNanoPB.framework; sourceTree = ""; }; + 8E23C54F83CF004274E96571BA64E535 /* GPBUnknownField.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBUnknownField.h; path = objectivec/GPBUnknownField.h; sourceTree = ""; }; + 917E5AE702B6E65DD89C7065A7174DEB /* FirebaseCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FirebaseCore.framework; path = Frameworks/FirebaseCore.framework; sourceTree = ""; }; + 923E38596D6A772561CB8C7808F79A90 /* Protobuf-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Protobuf-prefix.pch"; sourceTree = ""; }; + 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; + 93DA288616C1B9F6E4D4C77D659AE164 /* pb.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = pb.h; sourceTree = ""; }; + 98A2B87ED9DE3AA50282A9DBA93A9605 /* GoogleToolboxForMac.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = GoogleToolboxForMac.modulemap; sourceTree = ""; }; + 98CB3F3811553A7F960661239DC4CD50 /* GPBProtocolBuffers.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBProtocolBuffers.h; path = objectivec/GPBProtocolBuffers.h; sourceTree = ""; }; + 98F849B4AB7E52FFFA1C80B3F63D3D55 /* GPBRootObject.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBRootObject.h; path = objectivec/GPBRootObject.h; sourceTree = ""; }; + 99BDAEF4A037B782565F2F84207A3FF8 /* Pods_blista.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Pods_blista.framework; path = "Pods-blista.framework"; sourceTree = BUILT_PRODUCTS_DIR; }; + 9B5BAFA46BC181767A862E6938B99A34 /* GPBProtocolBuffers_RuntimeSupport.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBProtocolBuffers_RuntimeSupport.h; path = objectivec/GPBProtocolBuffers_RuntimeSupport.h; sourceTree = ""; }; + 9F986C5684FCA499C9169BC3145E8020 /* Protobuf-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Protobuf-umbrella.h"; sourceTree = ""; }; + A2078612D4DC50CA6B1DE98A4912FEDD /* FirebaseMessaging.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FirebaseMessaging.framework; path = Frameworks/FirebaseMessaging.framework; sourceTree = ""; }; + A3EE3CEF83C7CA2113DD9AC2C729EFE8 /* GTMNSData+zlib.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "GTMNSData+zlib.h"; path = "Foundation/GTMNSData+zlib.h"; sourceTree = ""; }; + A5F61877B4545A262CF5085CBDD39415 /* GPBCodedOutputStream.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = GPBCodedOutputStream.m; path = objectivec/GPBCodedOutputStream.m; sourceTree = ""; }; + A601D5266CD3A602585428F47C4DEC47 /* GPBArray_PackagePrivate.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBArray_PackagePrivate.h; path = objectivec/GPBArray_PackagePrivate.h; sourceTree = ""; }; + A663BCCCCC8C10CD1D45CD87BF708E9D /* Any.pbobjc.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = Any.pbobjc.h; path = objectivec/google/protobuf/Any.pbobjc.h; sourceTree = ""; }; + A6BAADCDCED5F2D192A56B27A30E98E7 /* GPBUtilities.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBUtilities.h; path = objectivec/GPBUtilities.h; sourceTree = ""; }; + AAB904A66A97657A417858F629E4BDBB /* Type.pbobjc.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = Type.pbobjc.h; path = objectivec/google/protobuf/Type.pbobjc.h; sourceTree = ""; }; + AB2FC4B13DA3ED00D8E226FF12A2F049 /* Duration.pbobjc.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = Duration.pbobjc.m; path = objectivec/google/protobuf/Duration.pbobjc.m; sourceTree = ""; }; + AD4DF62AE6E9D48CC565A462F3E7D6B8 /* GTMLogger.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = GTMLogger.m; path = Foundation/GTMLogger.m; sourceTree = ""; }; + B126EE8CE607140080ACD69440685729 /* GPBRootObject.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = GPBRootObject.m; path = objectivec/GPBRootObject.m; sourceTree = ""; }; + B546797C90A2C615CFCC2DF1C5A30668 /* SourceContext.pbobjc.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SourceContext.pbobjc.m; path = objectivec/google/protobuf/SourceContext.pbobjc.m; sourceTree = ""; }; + B5C0A5327E2B8DF1ADAFCEFBC8B60FF9 /* pb_encode.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = pb_encode.h; sourceTree = ""; }; + B73BC3416945C934E0186BD544934A45 /* nanopb-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "nanopb-prefix.pch"; sourceTree = ""; }; + B98C39E3674E3AB27A83ECAF421A2E9D /* Protobuf.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Protobuf.framework; path = Protobuf.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + BBECC2042DA3223E3CB65BA6BA633BD1 /* GPBExtensionRegistry.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBExtensionRegistry.h; path = objectivec/GPBExtensionRegistry.h; sourceTree = ""; }; + BD1A2BBAD2055349C4437BDC00A6CF8C /* GPBDictionary.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBDictionary.h; path = objectivec/GPBDictionary.h; sourceTree = ""; }; + C0D299A612F2D918CE551356F29ACE30 /* GTMLogger.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GTMLogger.h; path = Foundation/GTMLogger.h; sourceTree = ""; }; + C3C2FD839C4EE12CB542AEEDF6A4E860 /* Api.pbobjc.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = Api.pbobjc.m; path = objectivec/google/protobuf/Api.pbobjc.m; sourceTree = ""; }; + C776E3ABFC2BBFE5545FC0D9297965FD /* Timestamp.pbobjc.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = Timestamp.pbobjc.m; path = objectivec/google/protobuf/Timestamp.pbobjc.m; sourceTree = ""; }; + C92B3AD174BFA16CEFBD14B1D4A69E1D /* pb_common.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = pb_common.h; sourceTree = ""; }; + CB1CD1E5B688F08EB41849E108B4FCC1 /* GPBDictionary.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = GPBDictionary.m; path = objectivec/GPBDictionary.m; sourceTree = ""; }; + CE65C414A37E20D72616E44A7239C1A2 /* nanopb.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = nanopb.framework; path = nanopb.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + CED16CD69EB751E5A41BB48C5B47E146 /* Pods-blista-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-blista-umbrella.h"; sourceTree = ""; }; + D0E674497A291E43F5E9F55C2632494B /* FieldMask.pbobjc.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = FieldMask.pbobjc.h; path = objectivec/google/protobuf/FieldMask.pbobjc.h; sourceTree = ""; }; + D6964F57B6D94F25DA10FF4503E85481 /* GTMNSData+zlib.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "GTMNSData+zlib.m"; path = "Foundation/GTMNSData+zlib.m"; sourceTree = ""; }; + D93A093A830785420DD6105A8F49632F /* Pods-blista.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-blista.release.xcconfig"; sourceTree = ""; }; + DABF35642DA97C73DF0196A6AE304131 /* GTMDefines.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = GTMDefines.h; sourceTree = ""; }; + DB7E1E90DE520241ADA1A6C0B6113944 /* Api.pbobjc.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = Api.pbobjc.h; path = objectivec/google/protobuf/Api.pbobjc.h; sourceTree = ""; }; + DC0A29912E2160ABE67FD84CF71554F7 /* GPBMessage.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = GPBMessage.m; path = objectivec/GPBMessage.m; sourceTree = ""; }; + DC80E859B98A9DA7B7271B94572C1998 /* pb_decode.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = pb_decode.h; sourceTree = ""; }; + DE37671E3CE008D2C4F011CCAA537B94 /* GPBExtensionInternals.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = GPBExtensionInternals.m; path = objectivec/GPBExtensionInternals.m; sourceTree = ""; }; + E489131A594885F018B79967F109D4C4 /* FirebaseAnalytics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FirebaseAnalytics.framework; path = Frameworks/FirebaseAnalytics.framework; sourceTree = ""; }; + E978C30D521776F749F32DBA8A32171E /* GPBMessage_PackagePrivate.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBMessage_PackagePrivate.h; path = objectivec/GPBMessage_PackagePrivate.h; sourceTree = ""; }; + EB5E83FF21267268429230A4C0F31D55 /* Type.pbobjc.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = Type.pbobjc.m; path = objectivec/google/protobuf/Type.pbobjc.m; sourceTree = ""; }; + EDB4CF9FB34DD0DD7B85005AEB39585B /* nanopb-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "nanopb-umbrella.h"; sourceTree = ""; }; + EEA4D66EE6CCB00EB86AE5E80AC224A5 /* FirebaseInstanceID.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FirebaseInstanceID.framework; path = Frameworks/FirebaseInstanceID.framework; sourceTree = ""; }; + F099D52BA60EA489DE895E5D72AA19A6 /* Timestamp.pbobjc.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = Timestamp.pbobjc.h; path = objectivec/google/protobuf/Timestamp.pbobjc.h; sourceTree = ""; }; + F3D833AF41A8B219394C6478DBA6C6A6 /* GPBExtensionRegistry.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = GPBExtensionRegistry.m; path = objectivec/GPBExtensionRegistry.m; sourceTree = ""; }; + F63FAA4A623E43DB52D11A6485A6E8C7 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + F854BE2FDF90AD8CE6A082402D45C8C3 /* Pods-blista-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-blista-resources.sh"; sourceTree = ""; }; + F95B9BE197BF1DA6567E2987B00EC9C3 /* nanopb.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = nanopb.xcconfig; sourceTree = ""; }; + F96AE919BEDAA7DA46183D04D1820E06 /* Pods-blista-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-blista-acknowledgements.plist"; sourceTree = ""; }; + FB4A3DD045EEE6E7CD8C286A131C7840 /* Wrappers.pbobjc.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = Wrappers.pbobjc.m; path = objectivec/google/protobuf/Wrappers.pbobjc.m; sourceTree = ""; }; + FBD37FFAE7D4C5D20F561962012FBA1C /* GPBMessage.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = GPBMessage.h; path = objectivec/GPBMessage.h; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 65686942DCE439B68D0D53BD585F4AFE /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 4D90A812BD7E64537BC87CCFF0410008 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 971041836592E28ADEEDA495A96A62A2 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 05B1F02560378D28FEBD4E8F6D293216 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + AF347C815B5AF5F62815590F23A194C0 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 244EDBFE34EE389E15CF20677AFC9B44 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C5FBD50589CE2C516975A62886A56E07 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 554FEFCBC7B4F81FA40B1CBE88760112 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 007BA4D4D910BFBD6C7240627ECFF468 /* FirebaseAnalytics */ = { + isa = PBXGroup; + children = ( + 6F354D2E63549EA2BBB366BC180B4EE2 /* Frameworks */, + ); + name = FirebaseAnalytics; + path = FirebaseAnalytics; + sourceTree = ""; + }; + 0E651770079EF488178EB0674432F884 /* FirebaseInstanceID */ = { + isa = PBXGroup; + children = ( + EE6FEB187EF7C1E3143D3630C909F2BB /* Frameworks */, + ); + name = FirebaseInstanceID; + path = FirebaseInstanceID; + sourceTree = ""; + }; + 15B5113F63DF3AA3032E6DD00D742479 /* Pods */ = { + isa = PBXGroup; + children = ( + 8C6C6224B6144E581942937FE08D6270 /* Firebase */, + 007BA4D4D910BFBD6C7240627ECFF468 /* FirebaseAnalytics */, + 814CDE80B34382E456B5F8561546B979 /* FirebaseCore */, + 0E651770079EF488178EB0674432F884 /* FirebaseInstanceID */, + BDB613CFA115C5BD3BE91F2B5A141F5E /* FirebaseMessaging */, + 6BA6DA2E57CCCE57926338E95FCC8690 /* GoogleToolboxForMac */, + 8558CD7D36720957794357DC54D8A9F5 /* nanopb */, + A5812D29616C60191109452888C8E8BE /* Protobuf */, + ); + name = Pods; + sourceTree = ""; + }; + 2879A92740EB0C5874AEBB3481140D08 /* Defines */ = { + isa = PBXGroup; + children = ( + DABF35642DA97C73DF0196A6AE304131 /* GTMDefines.h */, + ); + name = Defines; + sourceTree = ""; + }; + 55572B3D6A1B39D31B075153A453B63B /* Pods-blista */ = { + isa = PBXGroup; + children = ( + 10B3E378AC648B4D56391259DB59BC36 /* Info.plist */, + 6FFC273E888F0E8EC0BA880316898998 /* Pods-blista.modulemap */, + 5DA9C0688ECC6AD8AFD02E88E49169BD /* Pods-blista-acknowledgements.markdown */, + F96AE919BEDAA7DA46183D04D1820E06 /* Pods-blista-acknowledgements.plist */, + 477CA59422C8A33AAF5782D746737ADD /* Pods-blista-dummy.m */, + 5EB5976B411EC5A085D396BA0D3EC840 /* Pods-blista-frameworks.sh */, + F854BE2FDF90AD8CE6A082402D45C8C3 /* Pods-blista-resources.sh */, + CED16CD69EB751E5A41BB48C5B47E146 /* Pods-blista-umbrella.h */, + 059AE92B7A25B96D00E022D5FDC830AB /* Pods-blista.debug.xcconfig */, + D93A093A830785420DD6105A8F49632F /* Pods-blista.release.xcconfig */, + ); + name = "Pods-blista"; + path = "Target Support Files/Pods-blista"; + sourceTree = ""; + }; + 5E92B6426A03F587E57EE77506AB7F44 /* Products */ = { + isa = PBXGroup; + children = ( + 03A877C6F9A7643363DA488FB3166DEE /* GoogleToolboxForMac.framework */, + CE65C414A37E20D72616E44A7239C1A2 /* nanopb.framework */, + 99BDAEF4A037B782565F2F84207A3FF8 /* Pods_blista.framework */, + B98C39E3674E3AB27A83ECAF421A2E9D /* Protobuf.framework */, + ); + name = Products; + sourceTree = ""; + }; + 686E9649CDF66AB1416E14EAB6729B5D /* Logger */ = { + isa = PBXGroup; + children = ( + C0D299A612F2D918CE551356F29ACE30 /* GTMLogger.h */, + AD4DF62AE6E9D48CC565A462F3E7D6B8 /* GTMLogger.m */, + ); + name = Logger; + sourceTree = ""; + }; + 6BA6DA2E57CCCE57926338E95FCC8690 /* GoogleToolboxForMac */ = { + isa = PBXGroup; + children = ( + 2879A92740EB0C5874AEBB3481140D08 /* Defines */, + 686E9649CDF66AB1416E14EAB6729B5D /* Logger */, + ADD4C5A672151B7779C7B717DAE83CAC /* NSData+zlib */, + AB8D9F9CE33BA78F2B172019E3F30265 /* Support Files */, + ); + name = GoogleToolboxForMac; + path = GoogleToolboxForMac; + sourceTree = ""; + }; + 6F354D2E63549EA2BBB366BC180B4EE2 /* Frameworks */ = { + isa = PBXGroup; + children = ( + E489131A594885F018B79967F109D4C4 /* FirebaseAnalytics.framework */, + 4A6A87F0960C8A1AE2904490CFA1BE32 /* FirebaseCoreDiagnostics.framework */, + 8D9AB3207FA19BA926AEC7A9C19BA0A2 /* FirebaseNanoPB.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 7DB346D0F39D3F0E887471402A8071AB = { + isa = PBXGroup; + children = ( + 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */, + BC3CA7F9E30CC8F7E2DD044DD34432FC /* Frameworks */, + 15B5113F63DF3AA3032E6DD00D742479 /* Pods */, + 5E92B6426A03F587E57EE77506AB7F44 /* Products */, + FA3B7A9739877CB0AC3C8D99BBF0F9A2 /* Targets Support Files */, + ); + sourceTree = ""; + }; + 7F71690648BCDD4AD37EB5379C71A7E7 /* Support Files */ = { + isa = PBXGroup; + children = ( + F63FAA4A623E43DB52D11A6485A6E8C7 /* Info.plist */, + 3BF6608EEF845F99E00B23B7D6CA8709 /* nanopb.modulemap */, + F95B9BE197BF1DA6567E2987B00EC9C3 /* nanopb.xcconfig */, + 275D3BDF234DECB073B4090E8841201B /* nanopb-dummy.m */, + B73BC3416945C934E0186BD544934A45 /* nanopb-prefix.pch */, + EDB4CF9FB34DD0DD7B85005AEB39585B /* nanopb-umbrella.h */, + ); + name = "Support Files"; + path = "../Target Support Files/nanopb"; + sourceTree = ""; + }; + 814CDE80B34382E456B5F8561546B979 /* FirebaseCore */ = { + isa = PBXGroup; + children = ( + DFEBCD156ACED7F10FD7A9ED52394A9C /* Frameworks */, + ); + name = FirebaseCore; + path = FirebaseCore; + sourceTree = ""; + }; + 8558CD7D36720957794357DC54D8A9F5 /* nanopb */ = { + isa = PBXGroup; + children = ( + 93DA288616C1B9F6E4D4C77D659AE164 /* pb.h */, + 118009AA37FA4346270ACC42C9444F35 /* pb_common.c */, + C92B3AD174BFA16CEFBD14B1D4A69E1D /* pb_common.h */, + 5F4630967F9078CD627B1D99C1A10BE4 /* pb_decode.c */, + DC80E859B98A9DA7B7271B94572C1998 /* pb_decode.h */, + 5966CD35E8E1CA1370318AAF93CAA559 /* pb_encode.c */, + B5C0A5327E2B8DF1ADAFCEFBC8B60FF9 /* pb_encode.h */, + AFEFC670BC28E9F57612DF6327E4FB48 /* decode */, + 94708DA65B0681DC0D5F5B569CEDFE76 /* encode */, + 7F71690648BCDD4AD37EB5379C71A7E7 /* Support Files */, + ); + name = nanopb; + path = nanopb; + sourceTree = ""; + }; + 8C6C6224B6144E581942937FE08D6270 /* Firebase */ = { + isa = PBXGroup; + children = ( + D483A57D17E4A0B4888E8A533A1E3496 /* Core */, + ); + name = Firebase; + path = Firebase; + sourceTree = ""; + }; + 94708DA65B0681DC0D5F5B569CEDFE76 /* encode */ = { + isa = PBXGroup; + children = ( + ); + name = encode; + sourceTree = ""; + }; + A5812D29616C60191109452888C8E8BE /* Protobuf */ = { + isa = PBXGroup; + children = ( + A663BCCCCC8C10CD1D45CD87BF708E9D /* Any.pbobjc.h */, + 65775860CC7E4A14598465C220D69AD6 /* Any.pbobjc.m */, + DB7E1E90DE520241ADA1A6C0B6113944 /* Api.pbobjc.h */, + C3C2FD839C4EE12CB542AEEDF6A4E860 /* Api.pbobjc.m */, + 71A6141A265F1200FDB8C322ABDFCA68 /* Duration.pbobjc.h */, + AB2FC4B13DA3ED00D8E226FF12A2F049 /* Duration.pbobjc.m */, + 438EF475DB0778433B652BD0549C31BC /* Empty.pbobjc.h */, + 078C2456FCD47F0D5F451DB0451A5CD0 /* Empty.pbobjc.m */, + D0E674497A291E43F5E9F55C2632494B /* FieldMask.pbobjc.h */, + 521BC722698B961EC91296CC2DAE0E7B /* FieldMask.pbobjc.m */, + 2EAA66A40D00BCDDAFA9980382C5EFE5 /* GPBArray.h */, + 10D791D354EEA6581EB63DB68BC4A2DC /* GPBArray.m */, + A601D5266CD3A602585428F47C4DEC47 /* GPBArray_PackagePrivate.h */, + 8AA8E7BCC056F17BBC59455F2B2AE698 /* GPBBootstrap.h */, + 525A1155D76DD372BF4D14A7C62EFE2B /* GPBCodedInputStream.h */, + 78F40EF10B48E25F6E8DAC46B6A11075 /* GPBCodedInputStream.m */, + 88C5C98B2A20198E1A021A9B9E87AC93 /* GPBCodedInputStream_PackagePrivate.h */, + 150CB46C4295EF02B5708C8877460ED2 /* GPBCodedOutputStream.h */, + A5F61877B4545A262CF5085CBDD39415 /* GPBCodedOutputStream.m */, + 04F245333671E568786F9B4457145481 /* GPBCodedOutputStream_PackagePrivate.h */, + 8101B3542E53B336F9F4400B26F420C4 /* GPBDescriptor.h */, + 1C638EBD5977EB01B99417235D03A50E /* GPBDescriptor.m */, + 6826DD97E13D633637D07F71E9D54149 /* GPBDescriptor_PackagePrivate.h */, + BD1A2BBAD2055349C4437BDC00A6CF8C /* GPBDictionary.h */, + CB1CD1E5B688F08EB41849E108B4FCC1 /* GPBDictionary.m */, + 4275C1C5335CDDE1B258C5A079A5A80A /* GPBDictionary_PackagePrivate.h */, + 0D53CD0966D446BB27A386ADE82F5986 /* GPBExtensionInternals.h */, + DE37671E3CE008D2C4F011CCAA537B94 /* GPBExtensionInternals.m */, + BBECC2042DA3223E3CB65BA6BA633BD1 /* GPBExtensionRegistry.h */, + F3D833AF41A8B219394C6478DBA6C6A6 /* GPBExtensionRegistry.m */, + FBD37FFAE7D4C5D20F561962012FBA1C /* GPBMessage.h */, + DC0A29912E2160ABE67FD84CF71554F7 /* GPBMessage.m */, + E978C30D521776F749F32DBA8A32171E /* GPBMessage_PackagePrivate.h */, + 98CB3F3811553A7F960661239DC4CD50 /* GPBProtocolBuffers.h */, + 9B5BAFA46BC181767A862E6938B99A34 /* GPBProtocolBuffers_RuntimeSupport.h */, + 98F849B4AB7E52FFFA1C80B3F63D3D55 /* GPBRootObject.h */, + B126EE8CE607140080ACD69440685729 /* GPBRootObject.m */, + 5F39363075D40A959F49BF3F1DEAEAD9 /* GPBRootObject_PackagePrivate.h */, + 28EECC6BF40C5EA45BFF83FE5AF5F71D /* GPBRuntimeTypes.h */, + 8E23C54F83CF004274E96571BA64E535 /* GPBUnknownField.h */, + 19ED33F0E3F2BA72AAF13956DDD993D2 /* GPBUnknownField.m */, + 706067214A1D2C83160ECC67D7A81532 /* GPBUnknownField_PackagePrivate.h */, + 43E593E914104CD3E053067B1846D1D6 /* GPBUnknownFieldSet.h */, + 53B1495973908531CF1CB45182726F21 /* GPBUnknownFieldSet.m */, + 4C09A14639AA0AA4621A68CD4A43EC7E /* GPBUnknownFieldSet_PackagePrivate.h */, + A6BAADCDCED5F2D192A56B27A30E98E7 /* GPBUtilities.h */, + 17370EC62F8E267340F264F1EEC678F4 /* GPBUtilities.m */, + 009A0427C75AF5D23AFBC0E2827D044C /* GPBUtilities_PackagePrivate.h */, + 526F4C967930411842B1FFA671D0E137 /* GPBWellKnownTypes.h */, + 04F3C29B3DD07E8819E5F39B92CEABD5 /* GPBWellKnownTypes.m */, + 4A5489280EF08E11BAF5B73674732D68 /* GPBWireFormat.h */, + 4804E7138784E758FD912EA5D97BBEBD /* GPBWireFormat.m */, + 53491A5744D0D2B7C020BD94CAE19859 /* SourceContext.pbobjc.h */, + B546797C90A2C615CFCC2DF1C5A30668 /* SourceContext.pbobjc.m */, + 582254AC879DA04855DF9AFCCE8025C5 /* Struct.pbobjc.h */, + 583299AD2746D1A7CB87676206BA7869 /* Struct.pbobjc.m */, + F099D52BA60EA489DE895E5D72AA19A6 /* Timestamp.pbobjc.h */, + C776E3ABFC2BBFE5545FC0D9297965FD /* Timestamp.pbobjc.m */, + AAB904A66A97657A417858F629E4BDBB /* Type.pbobjc.h */, + EB5E83FF21267268429230A4C0F31D55 /* Type.pbobjc.m */, + 560200B2128B8D052AF32F058B0F040C /* Wrappers.pbobjc.h */, + FB4A3DD045EEE6E7CD8C286A131C7840 /* Wrappers.pbobjc.m */, + C2073A02B32427DA6C46068153779F9E /* Support Files */, + ); + name = Protobuf; + path = Protobuf; + sourceTree = ""; + }; + AB8D9F9CE33BA78F2B172019E3F30265 /* Support Files */ = { + isa = PBXGroup; + children = ( + 98A2B87ED9DE3AA50282A9DBA93A9605 /* GoogleToolboxForMac.modulemap */, + 35F1616642044C0B422A4495D8D16D35 /* GoogleToolboxForMac.xcconfig */, + 18D4918C3B7E0E773D49B9CC6FA05C08 /* GoogleToolboxForMac-dummy.m */, + 1718449A5DBFDAF35B2DE024A5265616 /* GoogleToolboxForMac-prefix.pch */, + 255AA68EA1A1FC9FC56FAA63D074B951 /* GoogleToolboxForMac-umbrella.h */, + 27E70B8C269ABF68FF4FF52C7958629F /* Info.plist */, + ); + name = "Support Files"; + path = "../Target Support Files/GoogleToolboxForMac"; + sourceTree = ""; + }; + ADD4C5A672151B7779C7B717DAE83CAC /* NSData+zlib */ = { + isa = PBXGroup; + children = ( + A3EE3CEF83C7CA2113DD9AC2C729EFE8 /* GTMNSData+zlib.h */, + D6964F57B6D94F25DA10FF4503E85481 /* GTMNSData+zlib.m */, + ); + name = "NSData+zlib"; + sourceTree = ""; + }; + AFEFC670BC28E9F57612DF6327E4FB48 /* decode */ = { + isa = PBXGroup; + children = ( + ); + name = decode; + sourceTree = ""; + }; + BC3CA7F9E30CC8F7E2DD044DD34432FC /* Frameworks */ = { + isa = PBXGroup; + children = ( + D35AF013A5F0BAD4F32504907A52519E /* iOS */, + ); + name = Frameworks; + sourceTree = ""; + }; + BDB613CFA115C5BD3BE91F2B5A141F5E /* FirebaseMessaging */ = { + isa = PBXGroup; + children = ( + F8CEE023CCF17AD33A9F4AD4AF6BF653 /* Frameworks */, + ); + name = FirebaseMessaging; + path = FirebaseMessaging; + sourceTree = ""; + }; + C2073A02B32427DA6C46068153779F9E /* Support Files */ = { + isa = PBXGroup; + children = ( + 5214596CD4BA23B42F0B732B386D4F81 /* Info.plist */, + 34F5B0E5E4634A77852A79FEA3A0CF7E /* Protobuf.modulemap */, + 7E1F040B1AAEB5DB7BAC1434E7A0557C /* Protobuf.xcconfig */, + 2F88A0DF907BBA0BE797159BD516BE9B /* Protobuf-dummy.m */, + 923E38596D6A772561CB8C7808F79A90 /* Protobuf-prefix.pch */, + 9F986C5684FCA499C9169BC3145E8020 /* Protobuf-umbrella.h */, + ); + name = "Support Files"; + path = "../Target Support Files/Protobuf"; + sourceTree = ""; + }; + D35AF013A5F0BAD4F32504907A52519E /* iOS */ = { + isa = PBXGroup; + children = ( + 6604A7D69453B4569E4E4827FB9155A9 /* Foundation.framework */, + ); + name = iOS; + sourceTree = ""; + }; + D483A57D17E4A0B4888E8A533A1E3496 /* Core */ = { + isa = PBXGroup; + children = ( + 810933C7850ACA946DD4CD41DF2E6760 /* Firebase.h */, + ); + name = Core; + sourceTree = ""; + }; + DFEBCD156ACED7F10FD7A9ED52394A9C /* Frameworks */ = { + isa = PBXGroup; + children = ( + 917E5AE702B6E65DD89C7065A7174DEB /* FirebaseCore.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + EE6FEB187EF7C1E3143D3630C909F2BB /* Frameworks */ = { + isa = PBXGroup; + children = ( + EEA4D66EE6CCB00EB86AE5E80AC224A5 /* FirebaseInstanceID.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + F8CEE023CCF17AD33A9F4AD4AF6BF653 /* Frameworks */ = { + isa = PBXGroup; + children = ( + A2078612D4DC50CA6B1DE98A4912FEDD /* FirebaseMessaging.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + FA3B7A9739877CB0AC3C8D99BBF0F9A2 /* Targets Support Files */ = { + isa = PBXGroup; + children = ( + 55572B3D6A1B39D31B075153A453B63B /* Pods-blista */, + ); + name = "Targets Support Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 4547B9AF8085A499AA35614798F8F9E4 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + F9D92BA503505CB48EF4ECF0DDF57686 /* nanopb-umbrella.h in Headers */, + 392F2CF142BAA751AC1BB61D8B757D98 /* pb.h in Headers */, + 806BAA4E00218D70995697C4400BE7A0 /* pb_common.h in Headers */, + 29FEADDF2086FDEA7D5BA87DD23B08C6 /* pb_decode.h in Headers */, + E181395E73163EB702FCE9A21403D67B /* pb_encode.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5BFB68C5F550C3498C664E7FC900DC94 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + CC2EBC559F108EC7A3FA6250621F1033 /* Pods-blista-umbrella.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 9E4A7F152BA48D466686FE51C497388B /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 2970006B18A8D60F33AC073823312B53 /* Any.pbobjc.h in Headers */, + 2158693325BF85C0ED7192EF99F5C221 /* Api.pbobjc.h in Headers */, + 00C8CE9CC4B65A854791DA13EB48E36E /* Duration.pbobjc.h in Headers */, + 1DC8E6457E99AD68C57172B12E1B9F97 /* Empty.pbobjc.h in Headers */, + 73DA46214E4239838DA3195AB0B31AEA /* FieldMask.pbobjc.h in Headers */, + 005F122640E596BCF9FB2F69301A4A60 /* GPBArray.h in Headers */, + C6F1C82FF1FF4BC974A01A73581795C8 /* GPBArray_PackagePrivate.h in Headers */, + A92E3880E04FEE3543BA49528ACAFD19 /* GPBBootstrap.h in Headers */, + A793B4E7138EF931FE06731CFCB91D44 /* GPBCodedInputStream.h in Headers */, + DD44DB93CD656A9E416F06134146945C /* GPBCodedInputStream_PackagePrivate.h in Headers */, + 3A692A21E1F0F0E99606FA3C55B4A5ED /* GPBCodedOutputStream.h in Headers */, + F0EB9B317AC7C42299372CB1770E6228 /* GPBCodedOutputStream_PackagePrivate.h in Headers */, + 6D9E3153A382215CA76B2F5E42A58F3D /* GPBDescriptor.h in Headers */, + AF1438A8E738822AF659CCF1C67BA8F6 /* GPBDescriptor_PackagePrivate.h in Headers */, + 0EF7E91EDBD652DCA1F1EC8F3C05BA6A /* GPBDictionary.h in Headers */, + 7046C0C5D91A2542B96DB8BACB02D1EE /* GPBDictionary_PackagePrivate.h in Headers */, + 55A828B233D68FEAFF6A8C5764A1D679 /* GPBExtensionInternals.h in Headers */, + 973C7A5D628861BF9B19946F756D7569 /* GPBExtensionRegistry.h in Headers */, + DC8CBE8BF7A6B62FA70B94C96505FC10 /* GPBMessage.h in Headers */, + 71B0CD9FA26C16BF2025DF8307753832 /* GPBMessage_PackagePrivate.h in Headers */, + FC05F14A2061FBCA8B9D73C4F535A41B /* GPBProtocolBuffers.h in Headers */, + 10E51A61F26262D05DACFB163D3E29F0 /* GPBProtocolBuffers_RuntimeSupport.h in Headers */, + BCB54AA8CF9ED70872A297BA1072477D /* GPBRootObject.h in Headers */, + B11C079EE8D1F033D6676D202194BB15 /* GPBRootObject_PackagePrivate.h in Headers */, + 7877B41A017A28D30ACB5B91341E4431 /* GPBRuntimeTypes.h in Headers */, + 2B989D21EF69C88123AC04EB3E996AFA /* GPBUnknownField.h in Headers */, + 09CD20DE09A0C391E0758E63119C0EF2 /* GPBUnknownField_PackagePrivate.h in Headers */, + 024A1055AE4E24CC2DDD0CC837967F04 /* GPBUnknownFieldSet.h in Headers */, + C37587D9A8D8082A65E0AF46EF076C0C /* GPBUnknownFieldSet_PackagePrivate.h in Headers */, + E162B50E1BA950D17D1C18AE93A4CBC3 /* GPBUtilities.h in Headers */, + C74203D65B261DFAEE019E63625BA83A /* GPBUtilities_PackagePrivate.h in Headers */, + D11C2923A287AFF21EEDC0503F4B69B9 /* GPBWellKnownTypes.h in Headers */, + 79EBBA7401842D8A29A8D4E6A3CFD683 /* GPBWireFormat.h in Headers */, + 1B557B3C2D08812052F12F7A5CE4D03E /* Protobuf-umbrella.h in Headers */, + F969FD29C03C52D226A05379E04538A7 /* SourceContext.pbobjc.h in Headers */, + C80E6B366AEAAAF7C631D8D5237AE674 /* Struct.pbobjc.h in Headers */, + A4E9183C55E8AAC3C5907A6672D0DE4D /* Timestamp.pbobjc.h in Headers */, + 6901FD5494D2B83DB9733A4216B6DB89 /* Type.pbobjc.h in Headers */, + 7990E263A60AFE85F85EDE5342E3A89B /* Wrappers.pbobjc.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A65C674BC8B355E13D74FD423DC8F657 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ED66F8BD1D43065D931F2C8890806447 /* GoogleToolboxForMac-umbrella.h in Headers */, + 3E3B4CF239527A39CD308EBA9676FD8F /* GTMDefines.h in Headers */, + 0FF8F27F896850DB2973C4E26EC1F7EE /* GTMLogger.h in Headers */, + 755F55A7D577254B73EA7FEABA8E98E0 /* GTMNSData+zlib.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 7C98DEEE8FBAE7A8EC50E08EA77A1ADC /* Pods-blista */ = { + isa = PBXNativeTarget; + buildConfigurationList = 43FFB7E1C9AE97A759FCEEE9A8E40044 /* Build configuration list for PBXNativeTarget "Pods-blista" */; + buildPhases = ( + 919DEE7C61B3ED1F9FDD0B1E0E38245F /* Sources */, + 65686942DCE439B68D0D53BD585F4AFE /* Frameworks */, + 5BFB68C5F550C3498C664E7FC900DC94 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + 4CD03E71A10F0CD66D6B797F7CE80875 /* PBXTargetDependency */, + 8289D224BCD5FAE94D1A9BE35EB7C4B1 /* PBXTargetDependency */, + 90476D94654F38783305D710B699D34B /* PBXTargetDependency */, + ); + name = "Pods-blista"; + productName = "Pods-blista"; + productReference = 99BDAEF4A037B782565F2F84207A3FF8 /* Pods_blista.framework */; + productType = "com.apple.product-type.framework"; + }; + 989C940C959E8F0FA69E534D266A74FA /* Protobuf */ = { + isa = PBXNativeTarget; + buildConfigurationList = 6C0E9A69A547FF0970533D7C3D9C01DF /* Build configuration list for PBXNativeTarget "Protobuf" */; + buildPhases = ( + 7ECCEF97848AF20A975A70FFCDE205FC /* Sources */, + AF347C815B5AF5F62815590F23A194C0 /* Frameworks */, + 9E4A7F152BA48D466686FE51C497388B /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Protobuf; + productName = Protobuf; + productReference = B98C39E3674E3AB27A83ECAF421A2E9D /* Protobuf.framework */; + productType = "com.apple.product-type.framework"; + }; + C5B80060FE8C664DF08841000F41D515 /* GoogleToolboxForMac */ = { + isa = PBXNativeTarget; + buildConfigurationList = A7DCD5CC93C327FAB5EAF73A7ECA9866 /* Build configuration list for PBXNativeTarget "GoogleToolboxForMac" */; + buildPhases = ( + EF9AB148BBDF7952FC3CFBFF4694161B /* Sources */, + C5FBD50589CE2C516975A62886A56E07 /* Frameworks */, + A65C674BC8B355E13D74FD423DC8F657 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = GoogleToolboxForMac; + productName = GoogleToolboxForMac; + productReference = 03A877C6F9A7643363DA488FB3166DEE /* GoogleToolboxForMac.framework */; + productType = "com.apple.product-type.framework"; + }; + E4DD95323C54A78F879DAB0F1508B8E7 /* nanopb */ = { + isa = PBXNativeTarget; + buildConfigurationList = F118B0FA84AC9116AB2E480C302C3999 /* Build configuration list for PBXNativeTarget "nanopb" */; + buildPhases = ( + 238527BE8D494586023F2A2B8A60D242 /* Sources */, + 971041836592E28ADEEDA495A96A62A2 /* Frameworks */, + 4547B9AF8085A499AA35614798F8F9E4 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = nanopb; + productName = nanopb; + productReference = CE65C414A37E20D72616E44A7239C1A2 /* nanopb.framework */; + productType = "com.apple.product-type.framework"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + D41D8CD98F00B204E9800998ECF8427E /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0930; + LastUpgradeCheck = 0930; + }; + buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 7DB346D0F39D3F0E887471402A8071AB; + productRefGroup = 5E92B6426A03F587E57EE77506AB7F44 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + C5B80060FE8C664DF08841000F41D515 /* GoogleToolboxForMac */, + E4DD95323C54A78F879DAB0F1508B8E7 /* nanopb */, + 7C98DEEE8FBAE7A8EC50E08EA77A1ADC /* Pods-blista */, + 989C940C959E8F0FA69E534D266A74FA /* Protobuf */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 238527BE8D494586023F2A2B8A60D242 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 468DFD90B6C4DA2F7CFA0C1C89F1B615 /* nanopb-dummy.m in Sources */, + 3A50F5C8ECED9627F2EBD97F61BD376D /* pb_common.c in Sources */, + 54F580BF4588159D6A61F21D15591805 /* pb_decode.c in Sources */, + 55D8D5D912CFD2F3584E4553C2EAD734 /* pb_encode.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 7ECCEF97848AF20A975A70FFCDE205FC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 557F59E2029A338A443017E5A13026A4 /* Any.pbobjc.m in Sources */, + 466CC6ADCC9A9BC12E7FE08BE123D395 /* Api.pbobjc.m in Sources */, + BF7A350136A042ABC44DEFE8E0166CC6 /* Duration.pbobjc.m in Sources */, + 299C42158BACE311D1558C3322D7619D /* Empty.pbobjc.m in Sources */, + 22A8E87C6218934767B12E02EEAF6471 /* FieldMask.pbobjc.m in Sources */, + B3E44A13F7891D98191658404A5E1082 /* GPBArray.m in Sources */, + 481D8AF4ED895F0B4FCF134A763A7F04 /* GPBCodedInputStream.m in Sources */, + CE22A61ACE083D457A4D1383A6AB6420 /* GPBCodedOutputStream.m in Sources */, + 7A51235C98D3B3FE0D7191935F138185 /* GPBDescriptor.m in Sources */, + 1D8AFFE2FE9AA484D5834350A611666D /* GPBDictionary.m in Sources */, + B59397FE31968166B84D1CDFB72A278E /* GPBExtensionInternals.m in Sources */, + F2FCB4AE76C0E26F8FB4379F15C65AB0 /* GPBExtensionRegistry.m in Sources */, + 7178E85121EBD1B85098ACFDBC50AE14 /* GPBMessage.m in Sources */, + D537D2EC858FEEF10CEA9849CDCC5876 /* GPBRootObject.m in Sources */, + B30051007B4B3612DBE1267E684F22A8 /* GPBUnknownField.m in Sources */, + F6A9A77857DC54C33B4156A53D5092E0 /* GPBUnknownFieldSet.m in Sources */, + 20663455819141BE327880FE3C920E12 /* GPBUtilities.m in Sources */, + 2D3FB6CFC1A410938494EAED75370AB0 /* GPBWellKnownTypes.m in Sources */, + DF242C694455B99CCDF641A421770692 /* GPBWireFormat.m in Sources */, + AA1C43C98991B8340DA1B5BB1AA08384 /* Protobuf-dummy.m in Sources */, + 3A6957F43DF00B4A2074ADB669E3A489 /* SourceContext.pbobjc.m in Sources */, + 298B5D53627833DA13D67DE7893106C1 /* Struct.pbobjc.m in Sources */, + 1859784693CCBF663C5FBA89F35E8C27 /* Timestamp.pbobjc.m in Sources */, + B70F203762CB2D29EF9600BC81CC55AE /* Type.pbobjc.m in Sources */, + 2F6E6BF4DE2493557030F5950D10DCD1 /* Wrappers.pbobjc.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 919DEE7C61B3ED1F9FDD0B1E0E38245F /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D2DA4A606F790F472F6D2FEB3F578365 /* Pods-blista-dummy.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + EF9AB148BBDF7952FC3CFBFF4694161B /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 64418457D16D9A2F28F496AC75FC7DBD /* GoogleToolboxForMac-dummy.m in Sources */, + AB4F0970071E34D0384341466E0468EF /* GTMLogger.m in Sources */, + 9101CEA8562055177732244271008BBB /* GTMNSData+zlib.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 4CD03E71A10F0CD66D6B797F7CE80875 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = GoogleToolboxForMac; + target = C5B80060FE8C664DF08841000F41D515 /* GoogleToolboxForMac */; + targetProxy = 0CB1B932A732061694711658079D44F5 /* PBXContainerItemProxy */; + }; + 8289D224BCD5FAE94D1A9BE35EB7C4B1 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = Protobuf; + target = 989C940C959E8F0FA69E534D266A74FA /* Protobuf */; + targetProxy = EB1A3A836DC988E492CAD1ED1B9E571F /* PBXContainerItemProxy */; + }; + 90476D94654F38783305D710B699D34B /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = nanopb; + target = E4DD95323C54A78F879DAB0F1508B8E7 /* nanopb */; + targetProxy = EEAF7FB8643F05F2618791F00AD673F1 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 15C069F155AD7CFEFD1E42E043D24C9F /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = F95B9BE197BF1DA6567E2987B00EC9C3 /* nanopb.xcconfig */; + buildSettings = { + CODE_SIGN_IDENTITY = ""; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_PREFIX_HEADER = "Target Support Files/nanopb/nanopb-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/nanopb/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/nanopb/nanopb.modulemap"; + PRODUCT_NAME = nanopb; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 1B00FFF5D3734D8823EC80BF05AED341 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7E1F040B1AAEB5DB7BAC1434E7A0557C /* Protobuf.xcconfig */; + buildSettings = { + CODE_SIGN_IDENTITY = ""; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_PREFIX_HEADER = "Target Support Files/Protobuf/Protobuf-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/Protobuf/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/Protobuf/Protobuf.modulemap"; + PRODUCT_NAME = Protobuf; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 1DF8DE66EF353D66664F16316183F535 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 35F1616642044C0B422A4495D8D16D35 /* GoogleToolboxForMac.xcconfig */; + buildSettings = { + CODE_SIGN_IDENTITY = ""; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_PREFIX_HEADER = "Target Support Files/GoogleToolboxForMac/GoogleToolboxForMac-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/GoogleToolboxForMac/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/GoogleToolboxForMac/GoogleToolboxForMac.modulemap"; + PRODUCT_NAME = GoogleToolboxForMac; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 27CC37A59030091939F82A7AA938BA71 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = D93A093A830785420DD6105A8F49632F /* Pods-blista.release.xcconfig */; + buildSettings = { + CODE_SIGN_IDENTITY = ""; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = "Target Support Files/Pods-blista/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACH_O_TYPE = staticlib; + MODULEMAP_FILE = "Target Support Files/Pods-blista/Pods-blista.modulemap"; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = Pods_blista; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 8AFE746BC56B43150C00F936D6B13A6D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7E1F040B1AAEB5DB7BAC1434E7A0557C /* Protobuf.xcconfig */; + buildSettings = { + CODE_SIGN_IDENTITY = ""; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_PREFIX_HEADER = "Target Support Files/Protobuf/Protobuf-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/Protobuf/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/Protobuf/Protobuf.modulemap"; + PRODUCT_NAME = Protobuf; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 9B08F59FF51AFF627CB714A7411CD158 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = F95B9BE197BF1DA6567E2987B00EC9C3 /* nanopb.xcconfig */; + buildSettings = { + CODE_SIGN_IDENTITY = ""; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_PREFIX_HEADER = "Target Support Files/nanopb/nanopb-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/nanopb/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/nanopb/nanopb.modulemap"; + PRODUCT_NAME = nanopb; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + C0CDEDB29AA4162294C2EB1546033AD1 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 059AE92B7A25B96D00E022D5FDC830AB /* Pods-blista.debug.xcconfig */; + buildSettings = { + CODE_SIGN_IDENTITY = ""; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = "Target Support Files/Pods-blista/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACH_O_TYPE = staticlib; + MODULEMAP_FILE = "Target Support Files/Pods-blista/Pods-blista.modulemap"; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = Pods_blista; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + C3E37FB098AE76440E29106ADBF00CEB /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGNING_REQUIRED = NO; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "POD_CONFIGURATION_DEBUG=1", + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = NO_SIGNING/; + STRIP_INSTALLED_PRODUCT = NO; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SYMROOT = "${SRCROOT}/../build"; + }; + name = Debug; + }; + DA03565BE765DB55C6448FB363A44481 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGNING_REQUIRED = NO; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "POD_CONFIGURATION_RELEASE=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = NO_SIGNING/; + STRIP_INSTALLED_PRODUCT = NO; + SYMROOT = "${SRCROOT}/../build"; + }; + name = Release; + }; + E3C8A514280C5C3F8BB0B82192A556A1 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 35F1616642044C0B422A4495D8D16D35 /* GoogleToolboxForMac.xcconfig */; + buildSettings = { + CODE_SIGN_IDENTITY = ""; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_PREFIX_HEADER = "Target Support Files/GoogleToolboxForMac/GoogleToolboxForMac-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/GoogleToolboxForMac/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/GoogleToolboxForMac/GoogleToolboxForMac.modulemap"; + PRODUCT_NAME = GoogleToolboxForMac; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C3E37FB098AE76440E29106ADBF00CEB /* Debug */, + DA03565BE765DB55C6448FB363A44481 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 43FFB7E1C9AE97A759FCEEE9A8E40044 /* Build configuration list for PBXNativeTarget "Pods-blista" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C0CDEDB29AA4162294C2EB1546033AD1 /* Debug */, + 27CC37A59030091939F82A7AA938BA71 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 6C0E9A69A547FF0970533D7C3D9C01DF /* Build configuration list for PBXNativeTarget "Protobuf" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1B00FFF5D3734D8823EC80BF05AED341 /* Debug */, + 8AFE746BC56B43150C00F936D6B13A6D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + A7DCD5CC93C327FAB5EAF73A7ECA9866 /* Build configuration list for PBXNativeTarget "GoogleToolboxForMac" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DF8DE66EF353D66664F16316183F535 /* Debug */, + E3C8A514280C5C3F8BB0B82192A556A1 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + F118B0FA84AC9116AB2E480C302C3999 /* Build configuration list for PBXNativeTarget "nanopb" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9B08F59FF51AFF627CB714A7411CD158 /* Debug */, + 15C069F155AD7CFEFD1E42E043D24C9F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = D41D8CD98F00B204E9800998ECF8427E /* Project object */; +} diff --git a/Pods/Pods.xcodeproj/xcuserdata/falk.xcuserdatad/xcschemes/GoogleToolboxForMac.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/falk.xcuserdatad/xcschemes/GoogleToolboxForMac.xcscheme new file mode 100644 index 0000000..db0dcd8 --- /dev/null +++ b/Pods/Pods.xcodeproj/xcuserdata/falk.xcuserdatad/xcschemes/GoogleToolboxForMac.xcscheme @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Pods/Pods.xcodeproj/xcuserdata/falk.xcuserdatad/xcschemes/Pods-blista.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/falk.xcuserdatad/xcschemes/Pods-blista.xcscheme new file mode 100644 index 0000000..ea10918 --- /dev/null +++ b/Pods/Pods.xcodeproj/xcuserdata/falk.xcuserdatad/xcschemes/Pods-blista.xcscheme @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Pods/Pods.xcodeproj/xcuserdata/falk.xcuserdatad/xcschemes/Protobuf.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/falk.xcuserdatad/xcschemes/Protobuf.xcscheme new file mode 100644 index 0000000..bdf74ee --- /dev/null +++ b/Pods/Pods.xcodeproj/xcuserdata/falk.xcuserdatad/xcschemes/Protobuf.xcscheme @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Pods/Pods.xcodeproj/xcuserdata/falk.xcuserdatad/xcschemes/nanopb.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/falk.xcuserdatad/xcschemes/nanopb.xcscheme new file mode 100644 index 0000000..094cfea --- /dev/null +++ b/Pods/Pods.xcodeproj/xcuserdata/falk.xcuserdatad/xcschemes/nanopb.xcscheme @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Pods/Pods.xcodeproj/xcuserdata/falk.xcuserdatad/xcschemes/xcschememanagement.plist b/Pods/Pods.xcodeproj/xcuserdata/falk.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..428deae --- /dev/null +++ b/Pods/Pods.xcodeproj/xcuserdata/falk.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,39 @@ + + + + + SchemeUserState + + GoogleToolboxForMac.xcscheme + + isShown + + orderHint + 0 + + Pods-blista.xcscheme + + isShown + + orderHint + 2 + + Protobuf.xcscheme + + isShown + + orderHint + 3 + + nanopb.xcscheme + + isShown + + orderHint + 1 + + + SuppressBuildableAutocreation + + + diff --git a/Pods/Protobuf/LICENSE b/Pods/Protobuf/LICENSE new file mode 100644 index 0000000..f028c82 --- /dev/null +++ b/Pods/Protobuf/LICENSE @@ -0,0 +1,42 @@ +This license applies to all parts of Protocol Buffers except the following: + + - Atomicops support for generic gcc, located in + src/google/protobuf/stubs/atomicops_internals_generic_gcc.h. + This file is copyrighted by Red Hat Inc. + + - Atomicops support for AIX/POWER, located in + src/google/protobuf/stubs/atomicops_internals_power.h. + This file is copyrighted by Bloomberg Finance LP. + +Copyright 2014, Google Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Code generated by the Protocol Buffer compiler is owned by the owner +of the input file used when generating it. This code is not +standalone and requires a support library to be linked with it. This +support library is itself covered by the above license. diff --git a/Pods/Protobuf/README.md b/Pods/Protobuf/README.md new file mode 100644 index 0000000..3a4e6ed --- /dev/null +++ b/Pods/Protobuf/README.md @@ -0,0 +1,88 @@ +Protocol Buffers - Google's data interchange format +=================================================== + +[![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https://travis-ci.org/google/protobuf) [![Build status](https://ci.appveyor.com/api/projects/status/73ctee6ua4w2ruin?svg=true)](https://ci.appveyor.com/project/protobuf/protobuf) [![Build Status](https://grpc-testing.appspot.com/buildStatus/icon?job=protobuf_branch)](https://grpc-testing.appspot.com/job/protobuf_branch) [![Build Status](https://grpc-testing.appspot.com/job/protobuf_branch_32/badge/icon)](https://grpc-testing.appspot.com/job/protobuf_branch_32) [![Build Status](http://ci.bazel.io/buildStatus/icon?job=protobuf)](http://ci.bazel.io/job/protobuf/) + +Copyright 2008 Google Inc. + +https://developers.google.com/protocol-buffers/ + +Overview +-------- + +Protocol Buffers (a.k.a., protobuf) are Google's language-neutral, +platform-neutral, extensible mechanism for serializing structured data. You +can find [protobuf's documentation on the Google Developers site](https://developers.google.com/protocol-buffers/). + +This README file contains protobuf installation instructions. To install +protobuf, you need to install the protocol compiler (used to compile .proto +files) and the protobuf runtime for your chosen programming language. + +Protocol Compiler Installation +------------------------------ + +The protocol compiler is written in C++. If you are using C++, please follow +the [C++ Installation Instructions](src/README.md) to install protoc along +with the C++ runtime. + +For non-C++ users, the simplest way to install the protocol compiler is to +download a pre-built binary from our release page: + + [https://github.com/google/protobuf/releases](https://github.com/google/protobuf/releases) + +In the downloads section of each release, you can find pre-built binaries in +zip packages: protoc-$VERSION-$PLATFORM.zip. It contains the protoc binary +as well as a set of standard .proto files distributed along with protobuf. + +If you are looking for an old version that is not available in the release +page, check out the maven repo here: + + [https://repo1.maven.org/maven2/com/google/protobuf/protoc/](https://repo1.maven.org/maven2/com/google/protobuf/protoc/) + +These pre-built binaries are only provided for released versions. If you want +to use the github master version at HEAD, or you need to modify protobuf code, +or you are using C++, it's recommended to build your own protoc binary from +source. + +If you would like to build protoc binary from source, see the [C++ Installation +Instructions](src/README.md). + +Protobuf Runtime Installation +----------------------------- + +Protobuf supports several different programming languages. For each programming +language, you can find instructions in the corresponding source directory about +how to install protobuf runtime for that specific language: + +| Language | Source | +|--------------------------------------|-------------------------------------------------------------| +| C++ (include C++ runtime and protoc) | [src](src) | +| Java | [java](java) | +| Python | [python](python) | +| Objective-C | [objectivec](objectivec) | +| C# | [csharp](csharp) | +| JavaNano | [javanano](javanano) | +| JavaScript | [js](js) | +| Ruby | [ruby](ruby) | +| Go | [golang/protobuf](https://github.com/golang/protobuf) | +| PHP | [php](php) | +| Dart | [dart-lang/protobuf](https://github.com/dart-lang/protobuf) | + +Quick Start +----------- + +The best way to learn how to use protobuf is to follow the tutorials in our +developer guide: + +https://developers.google.com/protocol-buffers/docs/tutorials + +If you want to learn from code examples, take a look at the examples in the +[examples](examples) directory. + +Documentation +------------- + +The complete documentation for Protocol Buffers is available via the +web at: + +https://developers.google.com/protocol-buffers/ diff --git a/Pods/Protobuf/objectivec/GPBArray.h b/Pods/Protobuf/objectivec/GPBArray.h new file mode 100644 index 0000000..638b288 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBArray.h @@ -0,0 +1,1967 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import + +#import "GPBRuntimeTypes.h" + +NS_ASSUME_NONNULL_BEGIN + +//%PDDM-EXPAND DECLARE_ARRAYS() +// This block of code is generated, do not edit it directly. + +#pragma mark - Int32 + +/** + * Class used for repeated fields of int32_t values. This performs better than + * boxing into NSNumbers in NSArrays. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBInt32Array : NSObject + +/** The number of elements contained in the array. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty GPBInt32Array. + **/ ++ (instancetype)array; + +/** + * Creates and initializes a GPBInt32Array with the single element given. + * + * @param value The value to be placed in the array. + * + * @return A newly instanced GPBInt32Array with value in it. + **/ ++ (instancetype)arrayWithValue:(int32_t)value; + +/** + * Creates and initializes a GPBInt32Array with the contents of the given + * array. + * + * @param array Array with the contents to be put into the new array. + * + * @return A newly instanced GPBInt32Array with the contents of array. + **/ ++ (instancetype)arrayWithValueArray:(GPBInt32Array *)array; + +/** + * Creates and initializes a GPBInt32Array with the given capacity. + * + * @param count The capacity needed for the array. + * + * @return A newly instanced GPBInt32Array with a capacity of count. + **/ ++ (instancetype)arrayWithCapacity:(NSUInteger)count; + +/** + * @return A newly initialized and empty GPBInt32Array. + **/ +- (instancetype)init NS_DESIGNATED_INITIALIZER; + +/** + * Initializes the array, copying the given values. + * + * @param values An array with the values to put inside this array. + * @param count The number of elements to copy into the array. + * + * @return A newly initialized GPBInt32Array with a copy of the values. + **/ +- (instancetype)initWithValues:(const int32_t [__nullable])values + count:(NSUInteger)count; + +/** + * Initializes the array, copying the given values. + * + * @param array An array with the values to put inside this array. + * + * @return A newly initialized GPBInt32Array with a copy of the values. + **/ +- (instancetype)initWithValueArray:(GPBInt32Array *)array; + +/** + * Initializes the array with the given capacity. + * + * @param count The capacity needed for the array. + * + * @return A newly initialized GPBInt32Array with a capacity of count. + **/ +- (instancetype)initWithCapacity:(NSUInteger)count; + +/** + * Gets the value at the given index. + * + * @param index The index of the value to get. + * + * @return The value at the given index. + **/ +- (int32_t)valueAtIndex:(NSUInteger)index; + +/** + * Enumerates the values on this array with the given block. + * + * @param block The block to enumerate with. + * **value**: The current value being enumerated. + * **idx**: The index of the current value. + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block; + +/** + * Enumerates the values on this array with the given block. + * + * @param opts Options to control the enumeration. + * @param block The block to enumerate with. + * **value**: The current value being enumerated. + * **idx**: The index of the current value. + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts + usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block; + +/** + * Adds a value to this array. + * + * @param value The value to add to this array. + **/ +- (void)addValue:(int32_t)value; + +/** + * Adds values to this array. + * + * @param values The values to add to this array. + * @param count The number of elements to add. + **/ +- (void)addValues:(const int32_t [__nullable])values count:(NSUInteger)count; + +/** + * Adds the values from the given array to this array. + * + * @param array The array containing the elements to add to this array. + **/ +- (void)addValuesFromArray:(GPBInt32Array *)array; + +/** + * Inserts a value into the given position. + * + * @param value The value to add to this array. + * @param index The index into which to insert the value. + **/ +- (void)insertValue:(int32_t)value atIndex:(NSUInteger)index; + +/** + * Replaces the value at the given index with the given value. + * + * @param index The index for which to replace the value. + * @param value The value to replace with. + **/ +- (void)replaceValueAtIndex:(NSUInteger)index withValue:(int32_t)value; + +/** + * Removes the value at the given index. + * + * @param index The index of the value to remove. + **/ +- (void)removeValueAtIndex:(NSUInteger)index; + +/** + * Removes all the values from this array. + **/ +- (void)removeAll; + +/** + * Exchanges the values between the given indexes. + * + * @param idx1 The index of the first element to exchange. + * @param idx2 The index of the second element to exchange. + **/ +- (void)exchangeValueAtIndex:(NSUInteger)idx1 + withValueAtIndex:(NSUInteger)idx2; + +@end + +#pragma mark - UInt32 + +/** + * Class used for repeated fields of uint32_t values. This performs better than + * boxing into NSNumbers in NSArrays. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBUInt32Array : NSObject + +/** The number of elements contained in the array. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty GPBUInt32Array. + **/ ++ (instancetype)array; + +/** + * Creates and initializes a GPBUInt32Array with the single element given. + * + * @param value The value to be placed in the array. + * + * @return A newly instanced GPBUInt32Array with value in it. + **/ ++ (instancetype)arrayWithValue:(uint32_t)value; + +/** + * Creates and initializes a GPBUInt32Array with the contents of the given + * array. + * + * @param array Array with the contents to be put into the new array. + * + * @return A newly instanced GPBUInt32Array with the contents of array. + **/ ++ (instancetype)arrayWithValueArray:(GPBUInt32Array *)array; + +/** + * Creates and initializes a GPBUInt32Array with the given capacity. + * + * @param count The capacity needed for the array. + * + * @return A newly instanced GPBUInt32Array with a capacity of count. + **/ ++ (instancetype)arrayWithCapacity:(NSUInteger)count; + +/** + * @return A newly initialized and empty GPBUInt32Array. + **/ +- (instancetype)init NS_DESIGNATED_INITIALIZER; + +/** + * Initializes the array, copying the given values. + * + * @param values An array with the values to put inside this array. + * @param count The number of elements to copy into the array. + * + * @return A newly initialized GPBUInt32Array with a copy of the values. + **/ +- (instancetype)initWithValues:(const uint32_t [__nullable])values + count:(NSUInteger)count; + +/** + * Initializes the array, copying the given values. + * + * @param array An array with the values to put inside this array. + * + * @return A newly initialized GPBUInt32Array with a copy of the values. + **/ +- (instancetype)initWithValueArray:(GPBUInt32Array *)array; + +/** + * Initializes the array with the given capacity. + * + * @param count The capacity needed for the array. + * + * @return A newly initialized GPBUInt32Array with a capacity of count. + **/ +- (instancetype)initWithCapacity:(NSUInteger)count; + +/** + * Gets the value at the given index. + * + * @param index The index of the value to get. + * + * @return The value at the given index. + **/ +- (uint32_t)valueAtIndex:(NSUInteger)index; + +/** + * Enumerates the values on this array with the given block. + * + * @param block The block to enumerate with. + * **value**: The current value being enumerated. + * **idx**: The index of the current value. + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateValuesWithBlock:(void (^)(uint32_t value, NSUInteger idx, BOOL *stop))block; + +/** + * Enumerates the values on this array with the given block. + * + * @param opts Options to control the enumeration. + * @param block The block to enumerate with. + * **value**: The current value being enumerated. + * **idx**: The index of the current value. + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts + usingBlock:(void (^)(uint32_t value, NSUInteger idx, BOOL *stop))block; + +/** + * Adds a value to this array. + * + * @param value The value to add to this array. + **/ +- (void)addValue:(uint32_t)value; + +/** + * Adds values to this array. + * + * @param values The values to add to this array. + * @param count The number of elements to add. + **/ +- (void)addValues:(const uint32_t [__nullable])values count:(NSUInteger)count; + +/** + * Adds the values from the given array to this array. + * + * @param array The array containing the elements to add to this array. + **/ +- (void)addValuesFromArray:(GPBUInt32Array *)array; + +/** + * Inserts a value into the given position. + * + * @param value The value to add to this array. + * @param index The index into which to insert the value. + **/ +- (void)insertValue:(uint32_t)value atIndex:(NSUInteger)index; + +/** + * Replaces the value at the given index with the given value. + * + * @param index The index for which to replace the value. + * @param value The value to replace with. + **/ +- (void)replaceValueAtIndex:(NSUInteger)index withValue:(uint32_t)value; + +/** + * Removes the value at the given index. + * + * @param index The index of the value to remove. + **/ +- (void)removeValueAtIndex:(NSUInteger)index; + +/** + * Removes all the values from this array. + **/ +- (void)removeAll; + +/** + * Exchanges the values between the given indexes. + * + * @param idx1 The index of the first element to exchange. + * @param idx2 The index of the second element to exchange. + **/ +- (void)exchangeValueAtIndex:(NSUInteger)idx1 + withValueAtIndex:(NSUInteger)idx2; + +@end + +#pragma mark - Int64 + +/** + * Class used for repeated fields of int64_t values. This performs better than + * boxing into NSNumbers in NSArrays. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBInt64Array : NSObject + +/** The number of elements contained in the array. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty GPBInt64Array. + **/ ++ (instancetype)array; + +/** + * Creates and initializes a GPBInt64Array with the single element given. + * + * @param value The value to be placed in the array. + * + * @return A newly instanced GPBInt64Array with value in it. + **/ ++ (instancetype)arrayWithValue:(int64_t)value; + +/** + * Creates and initializes a GPBInt64Array with the contents of the given + * array. + * + * @param array Array with the contents to be put into the new array. + * + * @return A newly instanced GPBInt64Array with the contents of array. + **/ ++ (instancetype)arrayWithValueArray:(GPBInt64Array *)array; + +/** + * Creates and initializes a GPBInt64Array with the given capacity. + * + * @param count The capacity needed for the array. + * + * @return A newly instanced GPBInt64Array with a capacity of count. + **/ ++ (instancetype)arrayWithCapacity:(NSUInteger)count; + +/** + * @return A newly initialized and empty GPBInt64Array. + **/ +- (instancetype)init NS_DESIGNATED_INITIALIZER; + +/** + * Initializes the array, copying the given values. + * + * @param values An array with the values to put inside this array. + * @param count The number of elements to copy into the array. + * + * @return A newly initialized GPBInt64Array with a copy of the values. + **/ +- (instancetype)initWithValues:(const int64_t [__nullable])values + count:(NSUInteger)count; + +/** + * Initializes the array, copying the given values. + * + * @param array An array with the values to put inside this array. + * + * @return A newly initialized GPBInt64Array with a copy of the values. + **/ +- (instancetype)initWithValueArray:(GPBInt64Array *)array; + +/** + * Initializes the array with the given capacity. + * + * @param count The capacity needed for the array. + * + * @return A newly initialized GPBInt64Array with a capacity of count. + **/ +- (instancetype)initWithCapacity:(NSUInteger)count; + +/** + * Gets the value at the given index. + * + * @param index The index of the value to get. + * + * @return The value at the given index. + **/ +- (int64_t)valueAtIndex:(NSUInteger)index; + +/** + * Enumerates the values on this array with the given block. + * + * @param block The block to enumerate with. + * **value**: The current value being enumerated. + * **idx**: The index of the current value. + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateValuesWithBlock:(void (^)(int64_t value, NSUInteger idx, BOOL *stop))block; + +/** + * Enumerates the values on this array with the given block. + * + * @param opts Options to control the enumeration. + * @param block The block to enumerate with. + * **value**: The current value being enumerated. + * **idx**: The index of the current value. + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts + usingBlock:(void (^)(int64_t value, NSUInteger idx, BOOL *stop))block; + +/** + * Adds a value to this array. + * + * @param value The value to add to this array. + **/ +- (void)addValue:(int64_t)value; + +/** + * Adds values to this array. + * + * @param values The values to add to this array. + * @param count The number of elements to add. + **/ +- (void)addValues:(const int64_t [__nullable])values count:(NSUInteger)count; + +/** + * Adds the values from the given array to this array. + * + * @param array The array containing the elements to add to this array. + **/ +- (void)addValuesFromArray:(GPBInt64Array *)array; + +/** + * Inserts a value into the given position. + * + * @param value The value to add to this array. + * @param index The index into which to insert the value. + **/ +- (void)insertValue:(int64_t)value atIndex:(NSUInteger)index; + +/** + * Replaces the value at the given index with the given value. + * + * @param index The index for which to replace the value. + * @param value The value to replace with. + **/ +- (void)replaceValueAtIndex:(NSUInteger)index withValue:(int64_t)value; + +/** + * Removes the value at the given index. + * + * @param index The index of the value to remove. + **/ +- (void)removeValueAtIndex:(NSUInteger)index; + +/** + * Removes all the values from this array. + **/ +- (void)removeAll; + +/** + * Exchanges the values between the given indexes. + * + * @param idx1 The index of the first element to exchange. + * @param idx2 The index of the second element to exchange. + **/ +- (void)exchangeValueAtIndex:(NSUInteger)idx1 + withValueAtIndex:(NSUInteger)idx2; + +@end + +#pragma mark - UInt64 + +/** + * Class used for repeated fields of uint64_t values. This performs better than + * boxing into NSNumbers in NSArrays. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBUInt64Array : NSObject + +/** The number of elements contained in the array. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty GPBUInt64Array. + **/ ++ (instancetype)array; + +/** + * Creates and initializes a GPBUInt64Array with the single element given. + * + * @param value The value to be placed in the array. + * + * @return A newly instanced GPBUInt64Array with value in it. + **/ ++ (instancetype)arrayWithValue:(uint64_t)value; + +/** + * Creates and initializes a GPBUInt64Array with the contents of the given + * array. + * + * @param array Array with the contents to be put into the new array. + * + * @return A newly instanced GPBUInt64Array with the contents of array. + **/ ++ (instancetype)arrayWithValueArray:(GPBUInt64Array *)array; + +/** + * Creates and initializes a GPBUInt64Array with the given capacity. + * + * @param count The capacity needed for the array. + * + * @return A newly instanced GPBUInt64Array with a capacity of count. + **/ ++ (instancetype)arrayWithCapacity:(NSUInteger)count; + +/** + * @return A newly initialized and empty GPBUInt64Array. + **/ +- (instancetype)init NS_DESIGNATED_INITIALIZER; + +/** + * Initializes the array, copying the given values. + * + * @param values An array with the values to put inside this array. + * @param count The number of elements to copy into the array. + * + * @return A newly initialized GPBUInt64Array with a copy of the values. + **/ +- (instancetype)initWithValues:(const uint64_t [__nullable])values + count:(NSUInteger)count; + +/** + * Initializes the array, copying the given values. + * + * @param array An array with the values to put inside this array. + * + * @return A newly initialized GPBUInt64Array with a copy of the values. + **/ +- (instancetype)initWithValueArray:(GPBUInt64Array *)array; + +/** + * Initializes the array with the given capacity. + * + * @param count The capacity needed for the array. + * + * @return A newly initialized GPBUInt64Array with a capacity of count. + **/ +- (instancetype)initWithCapacity:(NSUInteger)count; + +/** + * Gets the value at the given index. + * + * @param index The index of the value to get. + * + * @return The value at the given index. + **/ +- (uint64_t)valueAtIndex:(NSUInteger)index; + +/** + * Enumerates the values on this array with the given block. + * + * @param block The block to enumerate with. + * **value**: The current value being enumerated. + * **idx**: The index of the current value. + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateValuesWithBlock:(void (^)(uint64_t value, NSUInteger idx, BOOL *stop))block; + +/** + * Enumerates the values on this array with the given block. + * + * @param opts Options to control the enumeration. + * @param block The block to enumerate with. + * **value**: The current value being enumerated. + * **idx**: The index of the current value. + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts + usingBlock:(void (^)(uint64_t value, NSUInteger idx, BOOL *stop))block; + +/** + * Adds a value to this array. + * + * @param value The value to add to this array. + **/ +- (void)addValue:(uint64_t)value; + +/** + * Adds values to this array. + * + * @param values The values to add to this array. + * @param count The number of elements to add. + **/ +- (void)addValues:(const uint64_t [__nullable])values count:(NSUInteger)count; + +/** + * Adds the values from the given array to this array. + * + * @param array The array containing the elements to add to this array. + **/ +- (void)addValuesFromArray:(GPBUInt64Array *)array; + +/** + * Inserts a value into the given position. + * + * @param value The value to add to this array. + * @param index The index into which to insert the value. + **/ +- (void)insertValue:(uint64_t)value atIndex:(NSUInteger)index; + +/** + * Replaces the value at the given index with the given value. + * + * @param index The index for which to replace the value. + * @param value The value to replace with. + **/ +- (void)replaceValueAtIndex:(NSUInteger)index withValue:(uint64_t)value; + +/** + * Removes the value at the given index. + * + * @param index The index of the value to remove. + **/ +- (void)removeValueAtIndex:(NSUInteger)index; + +/** + * Removes all the values from this array. + **/ +- (void)removeAll; + +/** + * Exchanges the values between the given indexes. + * + * @param idx1 The index of the first element to exchange. + * @param idx2 The index of the second element to exchange. + **/ +- (void)exchangeValueAtIndex:(NSUInteger)idx1 + withValueAtIndex:(NSUInteger)idx2; + +@end + +#pragma mark - Float + +/** + * Class used for repeated fields of float values. This performs better than + * boxing into NSNumbers in NSArrays. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBFloatArray : NSObject + +/** The number of elements contained in the array. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty GPBFloatArray. + **/ ++ (instancetype)array; + +/** + * Creates and initializes a GPBFloatArray with the single element given. + * + * @param value The value to be placed in the array. + * + * @return A newly instanced GPBFloatArray with value in it. + **/ ++ (instancetype)arrayWithValue:(float)value; + +/** + * Creates and initializes a GPBFloatArray with the contents of the given + * array. + * + * @param array Array with the contents to be put into the new array. + * + * @return A newly instanced GPBFloatArray with the contents of array. + **/ ++ (instancetype)arrayWithValueArray:(GPBFloatArray *)array; + +/** + * Creates and initializes a GPBFloatArray with the given capacity. + * + * @param count The capacity needed for the array. + * + * @return A newly instanced GPBFloatArray with a capacity of count. + **/ ++ (instancetype)arrayWithCapacity:(NSUInteger)count; + +/** + * @return A newly initialized and empty GPBFloatArray. + **/ +- (instancetype)init NS_DESIGNATED_INITIALIZER; + +/** + * Initializes the array, copying the given values. + * + * @param values An array with the values to put inside this array. + * @param count The number of elements to copy into the array. + * + * @return A newly initialized GPBFloatArray with a copy of the values. + **/ +- (instancetype)initWithValues:(const float [__nullable])values + count:(NSUInteger)count; + +/** + * Initializes the array, copying the given values. + * + * @param array An array with the values to put inside this array. + * + * @return A newly initialized GPBFloatArray with a copy of the values. + **/ +- (instancetype)initWithValueArray:(GPBFloatArray *)array; + +/** + * Initializes the array with the given capacity. + * + * @param count The capacity needed for the array. + * + * @return A newly initialized GPBFloatArray with a capacity of count. + **/ +- (instancetype)initWithCapacity:(NSUInteger)count; + +/** + * Gets the value at the given index. + * + * @param index The index of the value to get. + * + * @return The value at the given index. + **/ +- (float)valueAtIndex:(NSUInteger)index; + +/** + * Enumerates the values on this array with the given block. + * + * @param block The block to enumerate with. + * **value**: The current value being enumerated. + * **idx**: The index of the current value. + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateValuesWithBlock:(void (^)(float value, NSUInteger idx, BOOL *stop))block; + +/** + * Enumerates the values on this array with the given block. + * + * @param opts Options to control the enumeration. + * @param block The block to enumerate with. + * **value**: The current value being enumerated. + * **idx**: The index of the current value. + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts + usingBlock:(void (^)(float value, NSUInteger idx, BOOL *stop))block; + +/** + * Adds a value to this array. + * + * @param value The value to add to this array. + **/ +- (void)addValue:(float)value; + +/** + * Adds values to this array. + * + * @param values The values to add to this array. + * @param count The number of elements to add. + **/ +- (void)addValues:(const float [__nullable])values count:(NSUInteger)count; + +/** + * Adds the values from the given array to this array. + * + * @param array The array containing the elements to add to this array. + **/ +- (void)addValuesFromArray:(GPBFloatArray *)array; + +/** + * Inserts a value into the given position. + * + * @param value The value to add to this array. + * @param index The index into which to insert the value. + **/ +- (void)insertValue:(float)value atIndex:(NSUInteger)index; + +/** + * Replaces the value at the given index with the given value. + * + * @param index The index for which to replace the value. + * @param value The value to replace with. + **/ +- (void)replaceValueAtIndex:(NSUInteger)index withValue:(float)value; + +/** + * Removes the value at the given index. + * + * @param index The index of the value to remove. + **/ +- (void)removeValueAtIndex:(NSUInteger)index; + +/** + * Removes all the values from this array. + **/ +- (void)removeAll; + +/** + * Exchanges the values between the given indexes. + * + * @param idx1 The index of the first element to exchange. + * @param idx2 The index of the second element to exchange. + **/ +- (void)exchangeValueAtIndex:(NSUInteger)idx1 + withValueAtIndex:(NSUInteger)idx2; + +@end + +#pragma mark - Double + +/** + * Class used for repeated fields of double values. This performs better than + * boxing into NSNumbers in NSArrays. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBDoubleArray : NSObject + +/** The number of elements contained in the array. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty GPBDoubleArray. + **/ ++ (instancetype)array; + +/** + * Creates and initializes a GPBDoubleArray with the single element given. + * + * @param value The value to be placed in the array. + * + * @return A newly instanced GPBDoubleArray with value in it. + **/ ++ (instancetype)arrayWithValue:(double)value; + +/** + * Creates and initializes a GPBDoubleArray with the contents of the given + * array. + * + * @param array Array with the contents to be put into the new array. + * + * @return A newly instanced GPBDoubleArray with the contents of array. + **/ ++ (instancetype)arrayWithValueArray:(GPBDoubleArray *)array; + +/** + * Creates and initializes a GPBDoubleArray with the given capacity. + * + * @param count The capacity needed for the array. + * + * @return A newly instanced GPBDoubleArray with a capacity of count. + **/ ++ (instancetype)arrayWithCapacity:(NSUInteger)count; + +/** + * @return A newly initialized and empty GPBDoubleArray. + **/ +- (instancetype)init NS_DESIGNATED_INITIALIZER; + +/** + * Initializes the array, copying the given values. + * + * @param values An array with the values to put inside this array. + * @param count The number of elements to copy into the array. + * + * @return A newly initialized GPBDoubleArray with a copy of the values. + **/ +- (instancetype)initWithValues:(const double [__nullable])values + count:(NSUInteger)count; + +/** + * Initializes the array, copying the given values. + * + * @param array An array with the values to put inside this array. + * + * @return A newly initialized GPBDoubleArray with a copy of the values. + **/ +- (instancetype)initWithValueArray:(GPBDoubleArray *)array; + +/** + * Initializes the array with the given capacity. + * + * @param count The capacity needed for the array. + * + * @return A newly initialized GPBDoubleArray with a capacity of count. + **/ +- (instancetype)initWithCapacity:(NSUInteger)count; + +/** + * Gets the value at the given index. + * + * @param index The index of the value to get. + * + * @return The value at the given index. + **/ +- (double)valueAtIndex:(NSUInteger)index; + +/** + * Enumerates the values on this array with the given block. + * + * @param block The block to enumerate with. + * **value**: The current value being enumerated. + * **idx**: The index of the current value. + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateValuesWithBlock:(void (^)(double value, NSUInteger idx, BOOL *stop))block; + +/** + * Enumerates the values on this array with the given block. + * + * @param opts Options to control the enumeration. + * @param block The block to enumerate with. + * **value**: The current value being enumerated. + * **idx**: The index of the current value. + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts + usingBlock:(void (^)(double value, NSUInteger idx, BOOL *stop))block; + +/** + * Adds a value to this array. + * + * @param value The value to add to this array. + **/ +- (void)addValue:(double)value; + +/** + * Adds values to this array. + * + * @param values The values to add to this array. + * @param count The number of elements to add. + **/ +- (void)addValues:(const double [__nullable])values count:(NSUInteger)count; + +/** + * Adds the values from the given array to this array. + * + * @param array The array containing the elements to add to this array. + **/ +- (void)addValuesFromArray:(GPBDoubleArray *)array; + +/** + * Inserts a value into the given position. + * + * @param value The value to add to this array. + * @param index The index into which to insert the value. + **/ +- (void)insertValue:(double)value atIndex:(NSUInteger)index; + +/** + * Replaces the value at the given index with the given value. + * + * @param index The index for which to replace the value. + * @param value The value to replace with. + **/ +- (void)replaceValueAtIndex:(NSUInteger)index withValue:(double)value; + +/** + * Removes the value at the given index. + * + * @param index The index of the value to remove. + **/ +- (void)removeValueAtIndex:(NSUInteger)index; + +/** + * Removes all the values from this array. + **/ +- (void)removeAll; + +/** + * Exchanges the values between the given indexes. + * + * @param idx1 The index of the first element to exchange. + * @param idx2 The index of the second element to exchange. + **/ +- (void)exchangeValueAtIndex:(NSUInteger)idx1 + withValueAtIndex:(NSUInteger)idx2; + +@end + +#pragma mark - Bool + +/** + * Class used for repeated fields of BOOL values. This performs better than + * boxing into NSNumbers in NSArrays. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBBoolArray : NSObject + +/** The number of elements contained in the array. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty GPBBoolArray. + **/ ++ (instancetype)array; + +/** + * Creates and initializes a GPBBoolArray with the single element given. + * + * @param value The value to be placed in the array. + * + * @return A newly instanced GPBBoolArray with value in it. + **/ ++ (instancetype)arrayWithValue:(BOOL)value; + +/** + * Creates and initializes a GPBBoolArray with the contents of the given + * array. + * + * @param array Array with the contents to be put into the new array. + * + * @return A newly instanced GPBBoolArray with the contents of array. + **/ ++ (instancetype)arrayWithValueArray:(GPBBoolArray *)array; + +/** + * Creates and initializes a GPBBoolArray with the given capacity. + * + * @param count The capacity needed for the array. + * + * @return A newly instanced GPBBoolArray with a capacity of count. + **/ ++ (instancetype)arrayWithCapacity:(NSUInteger)count; + +/** + * @return A newly initialized and empty GPBBoolArray. + **/ +- (instancetype)init NS_DESIGNATED_INITIALIZER; + +/** + * Initializes the array, copying the given values. + * + * @param values An array with the values to put inside this array. + * @param count The number of elements to copy into the array. + * + * @return A newly initialized GPBBoolArray with a copy of the values. + **/ +- (instancetype)initWithValues:(const BOOL [__nullable])values + count:(NSUInteger)count; + +/** + * Initializes the array, copying the given values. + * + * @param array An array with the values to put inside this array. + * + * @return A newly initialized GPBBoolArray with a copy of the values. + **/ +- (instancetype)initWithValueArray:(GPBBoolArray *)array; + +/** + * Initializes the array with the given capacity. + * + * @param count The capacity needed for the array. + * + * @return A newly initialized GPBBoolArray with a capacity of count. + **/ +- (instancetype)initWithCapacity:(NSUInteger)count; + +/** + * Gets the value at the given index. + * + * @param index The index of the value to get. + * + * @return The value at the given index. + **/ +- (BOOL)valueAtIndex:(NSUInteger)index; + +/** + * Enumerates the values on this array with the given block. + * + * @param block The block to enumerate with. + * **value**: The current value being enumerated. + * **idx**: The index of the current value. + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateValuesWithBlock:(void (^)(BOOL value, NSUInteger idx, BOOL *stop))block; + +/** + * Enumerates the values on this array with the given block. + * + * @param opts Options to control the enumeration. + * @param block The block to enumerate with. + * **value**: The current value being enumerated. + * **idx**: The index of the current value. + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts + usingBlock:(void (^)(BOOL value, NSUInteger idx, BOOL *stop))block; + +/** + * Adds a value to this array. + * + * @param value The value to add to this array. + **/ +- (void)addValue:(BOOL)value; + +/** + * Adds values to this array. + * + * @param values The values to add to this array. + * @param count The number of elements to add. + **/ +- (void)addValues:(const BOOL [__nullable])values count:(NSUInteger)count; + +/** + * Adds the values from the given array to this array. + * + * @param array The array containing the elements to add to this array. + **/ +- (void)addValuesFromArray:(GPBBoolArray *)array; + +/** + * Inserts a value into the given position. + * + * @param value The value to add to this array. + * @param index The index into which to insert the value. + **/ +- (void)insertValue:(BOOL)value atIndex:(NSUInteger)index; + +/** + * Replaces the value at the given index with the given value. + * + * @param index The index for which to replace the value. + * @param value The value to replace with. + **/ +- (void)replaceValueAtIndex:(NSUInteger)index withValue:(BOOL)value; + +/** + * Removes the value at the given index. + * + * @param index The index of the value to remove. + **/ +- (void)removeValueAtIndex:(NSUInteger)index; + +/** + * Removes all the values from this array. + **/ +- (void)removeAll; + +/** + * Exchanges the values between the given indexes. + * + * @param idx1 The index of the first element to exchange. + * @param idx2 The index of the second element to exchange. + **/ +- (void)exchangeValueAtIndex:(NSUInteger)idx1 + withValueAtIndex:(NSUInteger)idx2; + +@end + +#pragma mark - Enum + +/** + * This class is used for repeated fields of int32_t values. This performs + * better than boxing into NSNumbers in NSArrays. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBEnumArray : NSObject + +/** The number of elements contained in the array. */ +@property(nonatomic, readonly) NSUInteger count; +/** The validation function to check if the enums are valid. */ +@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; + +/** + * @return A newly instanced and empty GPBEnumArray. + **/ ++ (instancetype)array; + +/** + * Creates and initializes a GPBEnumArray with the enum validation function + * given. + * + * @param func The enum validation function for the array. + * + * @return A newly instanced GPBEnumArray. + **/ ++ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func; + +/** + * Creates and initializes a GPBEnumArray with the enum validation function + * given and the single raw value given. + * + * @param func The enum validation function for the array. + * @param value The raw value to add to this array. + * + * @return A newly instanced GPBEnumArray. + **/ ++ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func + rawValue:(int32_t)value; + +/** + * Creates and initializes a GPBEnumArray that adds the elements from the + * given array. + * + * @param array Array containing the values to add to the new array. + * + * @return A newly instanced GPBEnumArray. + **/ ++ (instancetype)arrayWithValueArray:(GPBEnumArray *)array; + +/** + * Creates and initializes a GPBEnumArray with the given enum validation + * function and with the givencapacity. + * + * @param func The enum validation function for the array. + * @param count The capacity needed for the array. + * + * @return A newly instanced GPBEnumArray with a capacity of count. + **/ ++ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func + capacity:(NSUInteger)count; + +/** + * Initializes the array with the given enum validation function. + * + * @param func The enum validation function for the array. + * + * @return A newly initialized GPBEnumArray with a copy of the values. + **/ +- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func + NS_DESIGNATED_INITIALIZER; + +/** + * Initializes the array, copying the given values. + * + * @param func The enum validation function for the array. + * @param values An array with the values to put inside this array. + * @param count The number of elements to copy into the array. + * + * @return A newly initialized GPBEnumArray with a copy of the values. + **/ +- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func + rawValues:(const int32_t [__nullable])values + count:(NSUInteger)count; + +/** + * Initializes the array, copying the given values. + * + * @param array An array with the values to put inside this array. + * + * @return A newly initialized GPBEnumArray with a copy of the values. + **/ +- (instancetype)initWithValueArray:(GPBEnumArray *)array; + +/** + * Initializes the array with the given capacity. + * + * @param func The enum validation function for the array. + * @param count The capacity needed for the array. + * + * @return A newly initialized GPBEnumArray with a capacity of count. + **/ +- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func + capacity:(NSUInteger)count; + +// These will return kGPBUnrecognizedEnumeratorValue if the value at index is not a +// valid enumerator as defined by validationFunc. If the actual value is +// desired, use "raw" version of the method. + +/** + * Gets the value at the given index. + * + * @param index The index of the value to get. + * + * @return The value at the given index. + **/ +- (int32_t)valueAtIndex:(NSUInteger)index; + +/** + * Enumerates the values on this array with the given block. + * + * @param block The block to enumerate with. + * **value**: The current value being enumerated. + * **idx**: The index of the current value. + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block; + +/** + * Enumerates the values on this array with the given block. + * + * @param opts Options to control the enumeration. + * @param block The block to enumerate with. + * **value**: The current value being enumerated. + * **idx**: The index of the current value. + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts + usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block; + +// These methods bypass the validationFunc to provide access to values that were not +// known at the time the binary was compiled. + +/** + * Gets the raw enum value at the given index. + * + * @param index The index of the raw enum value to get. + * + * @return The raw enum value at the given index. + **/ +- (int32_t)rawValueAtIndex:(NSUInteger)index; + +/** + * Enumerates the values on this array with the given block. + * + * @param block The block to enumerate with. + * **value**: The current value being enumerated. + * **idx**: The index of the current value. + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateRawValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block; + +/** + * Enumerates the values on this array with the given block. + * + * @param opts Options to control the enumeration. + * @param block The block to enumerate with. + * **value**: The current value being enumerated. + * **idx**: The index of the current value. + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts + usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block; + +// If value is not a valid enumerator as defined by validationFunc, these +// methods will assert in debug, and will log in release and assign the value +// to the default value. Use the rawValue methods below to assign non enumerator +// values. + +/** + * Adds a value to this array. + * + * @param value The value to add to this array. + **/ +- (void)addValue:(int32_t)value; + +/** + * Adds values to this array. + * + * @param values The values to add to this array. + * @param count The number of elements to add. + **/ +- (void)addValues:(const int32_t [__nullable])values count:(NSUInteger)count; + + +/** + * Inserts a value into the given position. + * + * @param value The value to add to this array. + * @param index The index into which to insert the value. + **/ +- (void)insertValue:(int32_t)value atIndex:(NSUInteger)index; + +/** + * Replaces the value at the given index with the given value. + * + * @param index The index for which to replace the value. + * @param value The value to replace with. + **/ +- (void)replaceValueAtIndex:(NSUInteger)index withValue:(int32_t)value; + +// These methods bypass the validationFunc to provide setting of values that were not +// known at the time the binary was compiled. + +/** + * Adds a raw enum value to this array. + * + * @note This method bypass the validationFunc to enable the setting of values that + * were not known at the time the binary was compiled. + * + * @param value The raw enum value to add to the array. + **/ +- (void)addRawValue:(int32_t)value; + +/** + * Adds raw enum values to this array. + * + * @note This method bypass the validationFunc to enable the setting of values that + * were not known at the time the binary was compiled. + * + * @param array Array containing the raw enum values to add to this array. + **/ +- (void)addRawValuesFromArray:(GPBEnumArray *)array; + +/** + * Adds raw enum values to this array. + * + * @note This method bypass the validationFunc to enable the setting of values that + * were not known at the time the binary was compiled. + * + * @param values Array containing the raw enum values to add to this array. + * @param count The number of raw values to add. + **/ +- (void)addRawValues:(const int32_t [__nullable])values count:(NSUInteger)count; + +/** + * Inserts a raw enum value at the given index. + * + * @note This method bypass the validationFunc to enable the setting of values that + * were not known at the time the binary was compiled. + * + * @param value Raw enum value to add. + * @param index The index into which to insert the value. + **/ +- (void)insertRawValue:(int32_t)value atIndex:(NSUInteger)index; + +/** + * Replaces the raw enum value at the given index with the given value. + * + * @note This method bypass the validationFunc to enable the setting of values that + * were not known at the time the binary was compiled. + * + * @param index The index for which to replace the value. + * @param value The raw enum value to replace with. + **/ +- (void)replaceValueAtIndex:(NSUInteger)index withRawValue:(int32_t)value; + +// No validation applies to these methods. + +/** + * Removes the value at the given index. + * + * @param index The index of the value to remove. + **/ +- (void)removeValueAtIndex:(NSUInteger)index; + +/** + * Removes all the values from this array. + **/ +- (void)removeAll; + +/** + * Exchanges the values between the given indexes. + * + * @param idx1 The index of the first element to exchange. + * @param idx2 The index of the second element to exchange. + **/ +- (void)exchangeValueAtIndex:(NSUInteger)idx1 + withValueAtIndex:(NSUInteger)idx2; + +@end + +//%PDDM-EXPAND-END DECLARE_ARRAYS() + +NS_ASSUME_NONNULL_END + +//%PDDM-DEFINE DECLARE_ARRAYS() +//%ARRAY_INTERFACE_SIMPLE(Int32, int32_t) +//%ARRAY_INTERFACE_SIMPLE(UInt32, uint32_t) +//%ARRAY_INTERFACE_SIMPLE(Int64, int64_t) +//%ARRAY_INTERFACE_SIMPLE(UInt64, uint64_t) +//%ARRAY_INTERFACE_SIMPLE(Float, float) +//%ARRAY_INTERFACE_SIMPLE(Double, double) +//%ARRAY_INTERFACE_SIMPLE(Bool, BOOL) +//%ARRAY_INTERFACE_ENUM(Enum, int32_t) + +// +// The common case (everything but Enum) +// + +//%PDDM-DEFINE ARRAY_INTERFACE_SIMPLE(NAME, TYPE) +//%#pragma mark - NAME +//% +//%/** +//% * Class used for repeated fields of ##TYPE## values. This performs better than +//% * boxing into NSNumbers in NSArrays. +//% * +//% * @note This class is not meant to be subclassed. +//% **/ +//%@interface GPB##NAME##Array : NSObject +//% +//%/** The number of elements contained in the array. */ +//%@property(nonatomic, readonly) NSUInteger count; +//% +//%/** +//% * @return A newly instanced and empty GPB##NAME##Array. +//% **/ +//%+ (instancetype)array; +//% +//%/** +//% * Creates and initializes a GPB##NAME##Array with the single element given. +//% * +//% * @param value The value to be placed in the array. +//% * +//% * @return A newly instanced GPB##NAME##Array with value in it. +//% **/ +//%+ (instancetype)arrayWithValue:(TYPE)value; +//% +//%/** +//% * Creates and initializes a GPB##NAME##Array with the contents of the given +//% * array. +//% * +//% * @param array Array with the contents to be put into the new array. +//% * +//% * @return A newly instanced GPB##NAME##Array with the contents of array. +//% **/ +//%+ (instancetype)arrayWithValueArray:(GPB##NAME##Array *)array; +//% +//%/** +//% * Creates and initializes a GPB##NAME##Array with the given capacity. +//% * +//% * @param count The capacity needed for the array. +//% * +//% * @return A newly instanced GPB##NAME##Array with a capacity of count. +//% **/ +//%+ (instancetype)arrayWithCapacity:(NSUInteger)count; +//% +//%/** +//% * @return A newly initialized and empty GPB##NAME##Array. +//% **/ +//%- (instancetype)init NS_DESIGNATED_INITIALIZER; +//% +//%/** +//% * Initializes the array, copying the given values. +//% * +//% * @param values An array with the values to put inside this array. +//% * @param count The number of elements to copy into the array. +//% * +//% * @return A newly initialized GPB##NAME##Array with a copy of the values. +//% **/ +//%- (instancetype)initWithValues:(const TYPE [__nullable])values +//% count:(NSUInteger)count; +//% +//%/** +//% * Initializes the array, copying the given values. +//% * +//% * @param array An array with the values to put inside this array. +//% * +//% * @return A newly initialized GPB##NAME##Array with a copy of the values. +//% **/ +//%- (instancetype)initWithValueArray:(GPB##NAME##Array *)array; +//% +//%/** +//% * Initializes the array with the given capacity. +//% * +//% * @param count The capacity needed for the array. +//% * +//% * @return A newly initialized GPB##NAME##Array with a capacity of count. +//% **/ +//%- (instancetype)initWithCapacity:(NSUInteger)count; +//% +//%ARRAY_IMMUTABLE_INTERFACE(NAME, TYPE, Basic) +//% +//%ARRAY_MUTABLE_INTERFACE(NAME, TYPE, Basic) +//% +//%@end +//% + +// +// Macros specific to Enums (to tweak their interface). +// + +//%PDDM-DEFINE ARRAY_INTERFACE_ENUM(NAME, TYPE) +//%#pragma mark - NAME +//% +//%/** +//% * This class is used for repeated fields of ##TYPE## values. This performs +//% * better than boxing into NSNumbers in NSArrays. +//% * +//% * @note This class is not meant to be subclassed. +//% **/ +//%@interface GPB##NAME##Array : NSObject +//% +//%/** The number of elements contained in the array. */ +//%@property(nonatomic, readonly) NSUInteger count; +//%/** The validation function to check if the enums are valid. */ +//%@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; +//% +//%/** +//% * @return A newly instanced and empty GPB##NAME##Array. +//% **/ +//%+ (instancetype)array; +//% +//%/** +//% * Creates and initializes a GPB##NAME##Array with the enum validation function +//% * given. +//% * +//% * @param func The enum validation function for the array. +//% * +//% * @return A newly instanced GPB##NAME##Array. +//% **/ +//%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func; +//% +//%/** +//% * Creates and initializes a GPB##NAME##Array with the enum validation function +//% * given and the single raw value given. +//% * +//% * @param func The enum validation function for the array. +//% * @param value The raw value to add to this array. +//% * +//% * @return A newly instanced GPB##NAME##Array. +//% **/ +//%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func +//% rawValue:(TYPE)value; +//% +//%/** +//% * Creates and initializes a GPB##NAME##Array that adds the elements from the +//% * given array. +//% * +//% * @param array Array containing the values to add to the new array. +//% * +//% * @return A newly instanced GPB##NAME##Array. +//% **/ +//%+ (instancetype)arrayWithValueArray:(GPB##NAME##Array *)array; +//% +//%/** +//% * Creates and initializes a GPB##NAME##Array with the given enum validation +//% * function and with the givencapacity. +//% * +//% * @param func The enum validation function for the array. +//% * @param count The capacity needed for the array. +//% * +//% * @return A newly instanced GPB##NAME##Array with a capacity of count. +//% **/ +//%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func +//% capacity:(NSUInteger)count; +//% +//%/** +//% * Initializes the array with the given enum validation function. +//% * +//% * @param func The enum validation function for the array. +//% * +//% * @return A newly initialized GPB##NAME##Array with a copy of the values. +//% **/ +//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func +//% NS_DESIGNATED_INITIALIZER; +//% +//%/** +//% * Initializes the array, copying the given values. +//% * +//% * @param func The enum validation function for the array. +//% * @param values An array with the values to put inside this array. +//% * @param count The number of elements to copy into the array. +//% * +//% * @return A newly initialized GPB##NAME##Array with a copy of the values. +//% **/ +//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func +//% rawValues:(const TYPE [__nullable])values +//% count:(NSUInteger)count; +//% +//%/** +//% * Initializes the array, copying the given values. +//% * +//% * @param array An array with the values to put inside this array. +//% * +//% * @return A newly initialized GPB##NAME##Array with a copy of the values. +//% **/ +//%- (instancetype)initWithValueArray:(GPB##NAME##Array *)array; +//% +//%/** +//% * Initializes the array with the given capacity. +//% * +//% * @param func The enum validation function for the array. +//% * @param count The capacity needed for the array. +//% * +//% * @return A newly initialized GPB##NAME##Array with a capacity of count. +//% **/ +//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func +//% capacity:(NSUInteger)count; +//% +//%// These will return kGPBUnrecognizedEnumeratorValue if the value at index is not a +//%// valid enumerator as defined by validationFunc. If the actual value is +//%// desired, use "raw" version of the method. +//% +//%ARRAY_IMMUTABLE_INTERFACE(NAME, TYPE, NAME) +//% +//%// These methods bypass the validationFunc to provide access to values that were not +//%// known at the time the binary was compiled. +//% +//%/** +//% * Gets the raw enum value at the given index. +//% * +//% * @param index The index of the raw enum value to get. +//% * +//% * @return The raw enum value at the given index. +//% **/ +//%- (TYPE)rawValueAtIndex:(NSUInteger)index; +//% +//%/** +//% * Enumerates the values on this array with the given block. +//% * +//% * @param block The block to enumerate with. +//% * **value**: The current value being enumerated. +//% * **idx**: The index of the current value. +//% * **stop**: A pointer to a boolean that when set stops the enumeration. +//% **/ +//%- (void)enumerateRawValuesWithBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block; +//% +//%/** +//% * Enumerates the values on this array with the given block. +//% * +//% * @param opts Options to control the enumeration. +//% * @param block The block to enumerate with. +//% * **value**: The current value being enumerated. +//% * **idx**: The index of the current value. +//% * **stop**: A pointer to a boolean that when set stops the enumeration. +//% **/ +//%- (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts +//% usingBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block; +//% +//%// If value is not a valid enumerator as defined by validationFunc, these +//%// methods will assert in debug, and will log in release and assign the value +//%// to the default value. Use the rawValue methods below to assign non enumerator +//%// values. +//% +//%ARRAY_MUTABLE_INTERFACE(NAME, TYPE, NAME) +//% +//%@end +//% + +//%PDDM-DEFINE ARRAY_IMMUTABLE_INTERFACE(NAME, TYPE, HELPER_NAME) +//%/** +//% * Gets the value at the given index. +//% * +//% * @param index The index of the value to get. +//% * +//% * @return The value at the given index. +//% **/ +//%- (TYPE)valueAtIndex:(NSUInteger)index; +//% +//%/** +//% * Enumerates the values on this array with the given block. +//% * +//% * @param block The block to enumerate with. +//% * **value**: The current value being enumerated. +//% * **idx**: The index of the current value. +//% * **stop**: A pointer to a boolean that when set stops the enumeration. +//% **/ +//%- (void)enumerateValuesWithBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block; +//% +//%/** +//% * Enumerates the values on this array with the given block. +//% * +//% * @param opts Options to control the enumeration. +//% * @param block The block to enumerate with. +//% * **value**: The current value being enumerated. +//% * **idx**: The index of the current value. +//% * **stop**: A pointer to a boolean that when set stops the enumeration. +//% **/ +//%- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts +//% usingBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block; + +//%PDDM-DEFINE ARRAY_MUTABLE_INTERFACE(NAME, TYPE, HELPER_NAME) +//%/** +//% * Adds a value to this array. +//% * +//% * @param value The value to add to this array. +//% **/ +//%- (void)addValue:(TYPE)value; +//% +//%/** +//% * Adds values to this array. +//% * +//% * @param values The values to add to this array. +//% * @param count The number of elements to add. +//% **/ +//%- (void)addValues:(const TYPE [__nullable])values count:(NSUInteger)count; +//% +//%ARRAY_EXTRA_MUTABLE_METHODS1_##HELPER_NAME(NAME, TYPE) +//%/** +//% * Inserts a value into the given position. +//% * +//% * @param value The value to add to this array. +//% * @param index The index into which to insert the value. +//% **/ +//%- (void)insertValue:(TYPE)value atIndex:(NSUInteger)index; +//% +//%/** +//% * Replaces the value at the given index with the given value. +//% * +//% * @param index The index for which to replace the value. +//% * @param value The value to replace with. +//% **/ +//%- (void)replaceValueAtIndex:(NSUInteger)index withValue:(TYPE)value; +//%ARRAY_EXTRA_MUTABLE_METHODS2_##HELPER_NAME(NAME, TYPE) +//%/** +//% * Removes the value at the given index. +//% * +//% * @param index The index of the value to remove. +//% **/ +//%- (void)removeValueAtIndex:(NSUInteger)index; +//% +//%/** +//% * Removes all the values from this array. +//% **/ +//%- (void)removeAll; +//% +//%/** +//% * Exchanges the values between the given indexes. +//% * +//% * @param idx1 The index of the first element to exchange. +//% * @param idx2 The index of the second element to exchange. +//% **/ +//%- (void)exchangeValueAtIndex:(NSUInteger)idx1 +//% withValueAtIndex:(NSUInteger)idx2; + +// +// These are hooks invoked by the above to do insert as needed. +// + +//%PDDM-DEFINE ARRAY_EXTRA_MUTABLE_METHODS1_Basic(NAME, TYPE) +//%/** +//% * Adds the values from the given array to this array. +//% * +//% * @param array The array containing the elements to add to this array. +//% **/ +//%- (void)addValuesFromArray:(GPB##NAME##Array *)array; +//% +//%PDDM-DEFINE ARRAY_EXTRA_MUTABLE_METHODS2_Basic(NAME, TYPE) +// Empty +//%PDDM-DEFINE ARRAY_EXTRA_MUTABLE_METHODS1_Enum(NAME, TYPE) +// Empty +//%PDDM-DEFINE ARRAY_EXTRA_MUTABLE_METHODS2_Enum(NAME, TYPE) +//% +//%// These methods bypass the validationFunc to provide setting of values that were not +//%// known at the time the binary was compiled. +//% +//%/** +//% * Adds a raw enum value to this array. +//% * +//% * @note This method bypass the validationFunc to enable the setting of values that +//% * were not known at the time the binary was compiled. +//% * +//% * @param value The raw enum value to add to the array. +//% **/ +//%- (void)addRawValue:(TYPE)value; +//% +//%/** +//% * Adds raw enum values to this array. +//% * +//% * @note This method bypass the validationFunc to enable the setting of values that +//% * were not known at the time the binary was compiled. +//% * +//% * @param array Array containing the raw enum values to add to this array. +//% **/ +//%- (void)addRawValuesFromArray:(GPB##NAME##Array *)array; +//% +//%/** +//% * Adds raw enum values to this array. +//% * +//% * @note This method bypass the validationFunc to enable the setting of values that +//% * were not known at the time the binary was compiled. +//% * +//% * @param values Array containing the raw enum values to add to this array. +//% * @param count The number of raw values to add. +//% **/ +//%- (void)addRawValues:(const TYPE [__nullable])values count:(NSUInteger)count; +//% +//%/** +//% * Inserts a raw enum value at the given index. +//% * +//% * @note This method bypass the validationFunc to enable the setting of values that +//% * were not known at the time the binary was compiled. +//% * +//% * @param value Raw enum value to add. +//% * @param index The index into which to insert the value. +//% **/ +//%- (void)insertRawValue:(TYPE)value atIndex:(NSUInteger)index; +//% +//%/** +//% * Replaces the raw enum value at the given index with the given value. +//% * +//% * @note This method bypass the validationFunc to enable the setting of values that +//% * were not known at the time the binary was compiled. +//% * +//% * @param index The index for which to replace the value. +//% * @param value The raw enum value to replace with. +//% **/ +//%- (void)replaceValueAtIndex:(NSUInteger)index withRawValue:(TYPE)value; +//% +//%// No validation applies to these methods. +//% diff --git a/Pods/Protobuf/objectivec/GPBArray.m b/Pods/Protobuf/objectivec/GPBArray.m new file mode 100644 index 0000000..f401631 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBArray.m @@ -0,0 +1,2551 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import "GPBArray_PackagePrivate.h" + +#import "GPBMessage_PackagePrivate.h" + +// Direct access is use for speed, to avoid even internally declaring things +// read/write, etc. The warning is enabled in the project to ensure code calling +// protos can turn on -Wdirect-ivar-access without issues. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdirect-ivar-access" + +// Mutable arrays use an internal buffer that can always hold a multiple of this elements. +#define kChunkSize 16 +#define CapacityFromCount(x) (((x / kChunkSize) + 1) * kChunkSize) + +static BOOL ArrayDefault_IsValidValue(int32_t value) { + // Anything but the bad value marker is allowed. + return (value != kGPBUnrecognizedEnumeratorValue); +} + +//%PDDM-DEFINE VALIDATE_RANGE(INDEX, COUNT) +//% if (INDEX >= COUNT) { +//% [NSException raise:NSRangeException +//% format:@"Index (%lu) beyond bounds (%lu)", +//% (unsigned long)INDEX, (unsigned long)COUNT]; +//% } +//%PDDM-DEFINE MAYBE_GROW_TO_SET_COUNT(NEW_COUNT) +//% if (NEW_COUNT > _capacity) { +//% [self internalResizeToCapacity:CapacityFromCount(NEW_COUNT)]; +//% } +//% _count = NEW_COUNT; +//%PDDM-DEFINE SET_COUNT_AND_MAYBE_SHRINK(NEW_COUNT) +//% _count = NEW_COUNT; +//% if ((NEW_COUNT + (2 * kChunkSize)) < _capacity) { +//% [self internalResizeToCapacity:CapacityFromCount(NEW_COUNT)]; +//% } + +// +// Macros for the common basic cases. +// + +//%PDDM-DEFINE ARRAY_INTERFACE_SIMPLE(NAME, TYPE, FORMAT) +//%#pragma mark - NAME +//% +//%@implementation GPB##NAME##Array { +//% @package +//% TYPE *_values; +//% NSUInteger _count; +//% NSUInteger _capacity; +//%} +//% +//%@synthesize count = _count; +//% +//%+ (instancetype)array { +//% return [[[self alloc] init] autorelease]; +//%} +//% +//%+ (instancetype)arrayWithValue:(TYPE)value { +//% // Cast is needed so the compiler knows what class we are invoking initWithValues: on to get +//% // the type correct. +//% return [[(GPB##NAME##Array*)[self alloc] initWithValues:&value count:1] autorelease]; +//%} +//% +//%+ (instancetype)arrayWithValueArray:(GPB##NAME##Array *)array { +//% return [[(GPB##NAME##Array*)[self alloc] initWithValueArray:array] autorelease]; +//%} +//% +//%+ (instancetype)arrayWithCapacity:(NSUInteger)count { +//% return [[[self alloc] initWithCapacity:count] autorelease]; +//%} +//% +//%- (instancetype)init { +//% self = [super init]; +//% // No work needed; +//% return self; +//%} +//% +//%- (instancetype)initWithValueArray:(GPB##NAME##Array *)array { +//% return [self initWithValues:array->_values count:array->_count]; +//%} +//% +//%- (instancetype)initWithValues:(const TYPE [])values count:(NSUInteger)count { +//% self = [self init]; +//% if (self) { +//% if (count && values) { +//% _values = reallocf(_values, count * sizeof(TYPE)); +//% if (_values != NULL) { +//% _capacity = count; +//% memcpy(_values, values, count * sizeof(TYPE)); +//% _count = count; +//% } else { +//% [self release]; +//% [NSException raise:NSMallocException +//% format:@"Failed to allocate %lu bytes", +//% (unsigned long)(count * sizeof(TYPE))]; +//% } +//% } +//% } +//% return self; +//%} +//% +//%- (instancetype)initWithCapacity:(NSUInteger)count { +//% self = [self initWithValues:NULL count:0]; +//% if (self && count) { +//% [self internalResizeToCapacity:count]; +//% } +//% return self; +//%} +//% +//%- (instancetype)copyWithZone:(NSZone *)zone { +//% return [[GPB##NAME##Array allocWithZone:zone] initWithValues:_values count:_count]; +//%} +//% +//%ARRAY_IMMUTABLE_CORE(NAME, TYPE, , FORMAT) +//% +//%- (TYPE)valueAtIndex:(NSUInteger)index { +//%VALIDATE_RANGE(index, _count) +//% return _values[index]; +//%} +//% +//%ARRAY_MUTABLE_CORE(NAME, TYPE, , FORMAT) +//%@end +//% + +// +// Some core macros used for both the simple types and Enums. +// + +//%PDDM-DEFINE ARRAY_IMMUTABLE_CORE(NAME, TYPE, ACCESSOR_NAME, FORMAT) +//%- (void)dealloc { +//% NSAssert(!_autocreator, +//% @"%@: Autocreator must be cleared before release, autocreator: %@", +//% [self class], _autocreator); +//% free(_values); +//% [super dealloc]; +//%} +//% +//%- (BOOL)isEqual:(id)other { +//% if (self == other) { +//% return YES; +//% } +//% if (![other isKindOfClass:[GPB##NAME##Array class]]) { +//% return NO; +//% } +//% GPB##NAME##Array *otherArray = other; +//% return (_count == otherArray->_count +//% && memcmp(_values, otherArray->_values, (_count * sizeof(TYPE))) == 0); +//%} +//% +//%- (NSUInteger)hash { +//% // Follow NSArray's lead, and use the count as the hash. +//% return _count; +//%} +//% +//%- (NSString *)description { +//% NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [self class], self]; +//% for (NSUInteger i = 0, count = _count; i < count; ++i) { +//% if (i == 0) { +//% [result appendFormat:@"##FORMAT##", _values[i]]; +//% } else { +//% [result appendFormat:@", ##FORMAT##", _values[i]]; +//% } +//% } +//% [result appendFormat:@" }"]; +//% return result; +//%} +//% +//%- (void)enumerate##ACCESSOR_NAME##ValuesWithBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block { +//% [self enumerate##ACCESSOR_NAME##ValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block]; +//%} +//% +//%- (void)enumerate##ACCESSOR_NAME##ValuesWithOptions:(NSEnumerationOptions)opts +//% ACCESSOR_NAME$S usingBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block { +//% // NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok). +//% BOOL stop = NO; +//% if ((opts & NSEnumerationReverse) == 0) { +//% for (NSUInteger i = 0, count = _count; i < count; ++i) { +//% block(_values[i], i, &stop); +//% if (stop) break; +//% } +//% } else if (_count > 0) { +//% for (NSUInteger i = _count; i > 0; --i) { +//% block(_values[i - 1], (i - 1), &stop); +//% if (stop) break; +//% } +//% } +//%} + +//%PDDM-DEFINE MUTATION_HOOK_None() +//%PDDM-DEFINE MUTATION_METHODS(NAME, TYPE, ACCESSOR_NAME, HOOK_1, HOOK_2) +//%- (void)add##ACCESSOR_NAME##Value:(TYPE)value { +//% [self add##ACCESSOR_NAME##Values:&value count:1]; +//%} +//% +//%- (void)add##ACCESSOR_NAME##Values:(const TYPE [])values count:(NSUInteger)count { +//% if (values == NULL || count == 0) return; +//%MUTATION_HOOK_##HOOK_1() NSUInteger initialCount = _count; +//% NSUInteger newCount = initialCount + count; +//%MAYBE_GROW_TO_SET_COUNT(newCount) +//% memcpy(&_values[initialCount], values, count * sizeof(TYPE)); +//% if (_autocreator) { +//% GPBAutocreatedArrayModified(_autocreator, self); +//% } +//%} +//% +//%- (void)insert##ACCESSOR_NAME##Value:(TYPE)value atIndex:(NSUInteger)index { +//%VALIDATE_RANGE(index, _count + 1) +//%MUTATION_HOOK_##HOOK_2() NSUInteger initialCount = _count; +//% NSUInteger newCount = initialCount + 1; +//%MAYBE_GROW_TO_SET_COUNT(newCount) +//% if (index != initialCount) { +//% memmove(&_values[index + 1], &_values[index], (initialCount - index) * sizeof(TYPE)); +//% } +//% _values[index] = value; +//% if (_autocreator) { +//% GPBAutocreatedArrayModified(_autocreator, self); +//% } +//%} +//% +//%- (void)replaceValueAtIndex:(NSUInteger)index with##ACCESSOR_NAME##Value:(TYPE)value { +//%VALIDATE_RANGE(index, _count) +//%MUTATION_HOOK_##HOOK_2() _values[index] = value; +//%} + +//%PDDM-DEFINE ARRAY_MUTABLE_CORE(NAME, TYPE, ACCESSOR_NAME, FORMAT) +//%- (void)internalResizeToCapacity:(NSUInteger)newCapacity { +//% _values = reallocf(_values, newCapacity * sizeof(TYPE)); +//% if (_values == NULL) { +//% _capacity = 0; +//% _count = 0; +//% [NSException raise:NSMallocException +//% format:@"Failed to allocate %lu bytes", +//% (unsigned long)(newCapacity * sizeof(TYPE))]; +//% } +//% _capacity = newCapacity; +//%} +//% +//%MUTATION_METHODS(NAME, TYPE, ACCESSOR_NAME, None, None) +//% +//%- (void)add##ACCESSOR_NAME##ValuesFromArray:(GPB##NAME##Array *)array { +//% [self add##ACCESSOR_NAME##Values:array->_values count:array->_count]; +//%} +//% +//%- (void)removeValueAtIndex:(NSUInteger)index { +//%VALIDATE_RANGE(index, _count) +//% NSUInteger newCount = _count - 1; +//% if (index != newCount) { +//% memmove(&_values[index], &_values[index + 1], (newCount - index) * sizeof(TYPE)); +//% } +//%SET_COUNT_AND_MAYBE_SHRINK(newCount) +//%} +//% +//%- (void)removeAll { +//%SET_COUNT_AND_MAYBE_SHRINK(0) +//%} +//% +//%- (void)exchangeValueAtIndex:(NSUInteger)idx1 +//% withValueAtIndex:(NSUInteger)idx2 { +//%VALIDATE_RANGE(idx1, _count) +//%VALIDATE_RANGE(idx2, _count) +//% TYPE temp = _values[idx1]; +//% _values[idx1] = _values[idx2]; +//% _values[idx2] = temp; +//%} +//% + +//%PDDM-EXPAND ARRAY_INTERFACE_SIMPLE(Int32, int32_t, %d) +// This block of code is generated, do not edit it directly. + +#pragma mark - Int32 + +@implementation GPBInt32Array { + @package + int32_t *_values; + NSUInteger _count; + NSUInteger _capacity; +} + +@synthesize count = _count; + ++ (instancetype)array { + return [[[self alloc] init] autorelease]; +} + ++ (instancetype)arrayWithValue:(int32_t)value { + // Cast is needed so the compiler knows what class we are invoking initWithValues: on to get + // the type correct. + return [[(GPBInt32Array*)[self alloc] initWithValues:&value count:1] autorelease]; +} + ++ (instancetype)arrayWithValueArray:(GPBInt32Array *)array { + return [[(GPBInt32Array*)[self alloc] initWithValueArray:array] autorelease]; +} + ++ (instancetype)arrayWithCapacity:(NSUInteger)count { + return [[[self alloc] initWithCapacity:count] autorelease]; +} + +- (instancetype)init { + self = [super init]; + // No work needed; + return self; +} + +- (instancetype)initWithValueArray:(GPBInt32Array *)array { + return [self initWithValues:array->_values count:array->_count]; +} + +- (instancetype)initWithValues:(const int32_t [])values count:(NSUInteger)count { + self = [self init]; + if (self) { + if (count && values) { + _values = reallocf(_values, count * sizeof(int32_t)); + if (_values != NULL) { + _capacity = count; + memcpy(_values, values, count * sizeof(int32_t)); + _count = count; + } else { + [self release]; + [NSException raise:NSMallocException + format:@"Failed to allocate %lu bytes", + (unsigned long)(count * sizeof(int32_t))]; + } + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)count { + self = [self initWithValues:NULL count:0]; + if (self && count) { + [self internalResizeToCapacity:count]; + } + return self; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBInt32Array allocWithZone:zone] initWithValues:_values count:_count]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + free(_values); + [super dealloc]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBInt32Array class]]) { + return NO; + } + GPBInt32Array *otherArray = other; + return (_count == otherArray->_count + && memcmp(_values, otherArray->_values, (_count * sizeof(int32_t))) == 0); +} + +- (NSUInteger)hash { + // Follow NSArray's lead, and use the count as the hash. + return _count; +} + +- (NSString *)description { + NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [self class], self]; + for (NSUInteger i = 0, count = _count; i < count; ++i) { + if (i == 0) { + [result appendFormat:@"%d", _values[i]]; + } else { + [result appendFormat:@", %d", _values[i]]; + } + } + [result appendFormat:@" }"]; + return result; +} + +- (void)enumerateValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block { + [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block]; +} + +- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts + usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block { + // NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok). + BOOL stop = NO; + if ((opts & NSEnumerationReverse) == 0) { + for (NSUInteger i = 0, count = _count; i < count; ++i) { + block(_values[i], i, &stop); + if (stop) break; + } + } else if (_count > 0) { + for (NSUInteger i = _count; i > 0; --i) { + block(_values[i - 1], (i - 1), &stop); + if (stop) break; + } + } +} + +- (int32_t)valueAtIndex:(NSUInteger)index { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + return _values[index]; +} + +- (void)internalResizeToCapacity:(NSUInteger)newCapacity { + _values = reallocf(_values, newCapacity * sizeof(int32_t)); + if (_values == NULL) { + _capacity = 0; + _count = 0; + [NSException raise:NSMallocException + format:@"Failed to allocate %lu bytes", + (unsigned long)(newCapacity * sizeof(int32_t))]; + } + _capacity = newCapacity; +} + +- (void)addValue:(int32_t)value { + [self addValues:&value count:1]; +} + +- (void)addValues:(const int32_t [])values count:(NSUInteger)count { + if (values == NULL || count == 0) return; + NSUInteger initialCount = _count; + NSUInteger newCount = initialCount + count; + if (newCount > _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } + _count = newCount; + memcpy(&_values[initialCount], values, count * sizeof(int32_t)); + if (_autocreator) { + GPBAutocreatedArrayModified(_autocreator, self); + } +} + +- (void)insertValue:(int32_t)value atIndex:(NSUInteger)index { + if (index >= _count + 1) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count + 1]; + } + NSUInteger initialCount = _count; + NSUInteger newCount = initialCount + 1; + if (newCount > _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } + _count = newCount; + if (index != initialCount) { + memmove(&_values[index + 1], &_values[index], (initialCount - index) * sizeof(int32_t)); + } + _values[index] = value; + if (_autocreator) { + GPBAutocreatedArrayModified(_autocreator, self); + } +} + +- (void)replaceValueAtIndex:(NSUInteger)index withValue:(int32_t)value { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + _values[index] = value; +} + +- (void)addValuesFromArray:(GPBInt32Array *)array { + [self addValues:array->_values count:array->_count]; +} + +- (void)removeValueAtIndex:(NSUInteger)index { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + NSUInteger newCount = _count - 1; + if (index != newCount) { + memmove(&_values[index], &_values[index + 1], (newCount - index) * sizeof(int32_t)); + } + _count = newCount; + if ((newCount + (2 * kChunkSize)) < _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } +} + +- (void)removeAll { + _count = 0; + if ((0 + (2 * kChunkSize)) < _capacity) { + [self internalResizeToCapacity:CapacityFromCount(0)]; + } +} + +- (void)exchangeValueAtIndex:(NSUInteger)idx1 + withValueAtIndex:(NSUInteger)idx2 { + if (idx1 >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)idx1, (unsigned long)_count]; + } + if (idx2 >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)idx2, (unsigned long)_count]; + } + int32_t temp = _values[idx1]; + _values[idx1] = _values[idx2]; + _values[idx2] = temp; +} + +@end + +//%PDDM-EXPAND ARRAY_INTERFACE_SIMPLE(UInt32, uint32_t, %u) +// This block of code is generated, do not edit it directly. + +#pragma mark - UInt32 + +@implementation GPBUInt32Array { + @package + uint32_t *_values; + NSUInteger _count; + NSUInteger _capacity; +} + +@synthesize count = _count; + ++ (instancetype)array { + return [[[self alloc] init] autorelease]; +} + ++ (instancetype)arrayWithValue:(uint32_t)value { + // Cast is needed so the compiler knows what class we are invoking initWithValues: on to get + // the type correct. + return [[(GPBUInt32Array*)[self alloc] initWithValues:&value count:1] autorelease]; +} + ++ (instancetype)arrayWithValueArray:(GPBUInt32Array *)array { + return [[(GPBUInt32Array*)[self alloc] initWithValueArray:array] autorelease]; +} + ++ (instancetype)arrayWithCapacity:(NSUInteger)count { + return [[[self alloc] initWithCapacity:count] autorelease]; +} + +- (instancetype)init { + self = [super init]; + // No work needed; + return self; +} + +- (instancetype)initWithValueArray:(GPBUInt32Array *)array { + return [self initWithValues:array->_values count:array->_count]; +} + +- (instancetype)initWithValues:(const uint32_t [])values count:(NSUInteger)count { + self = [self init]; + if (self) { + if (count && values) { + _values = reallocf(_values, count * sizeof(uint32_t)); + if (_values != NULL) { + _capacity = count; + memcpy(_values, values, count * sizeof(uint32_t)); + _count = count; + } else { + [self release]; + [NSException raise:NSMallocException + format:@"Failed to allocate %lu bytes", + (unsigned long)(count * sizeof(uint32_t))]; + } + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)count { + self = [self initWithValues:NULL count:0]; + if (self && count) { + [self internalResizeToCapacity:count]; + } + return self; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBUInt32Array allocWithZone:zone] initWithValues:_values count:_count]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + free(_values); + [super dealloc]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBUInt32Array class]]) { + return NO; + } + GPBUInt32Array *otherArray = other; + return (_count == otherArray->_count + && memcmp(_values, otherArray->_values, (_count * sizeof(uint32_t))) == 0); +} + +- (NSUInteger)hash { + // Follow NSArray's lead, and use the count as the hash. + return _count; +} + +- (NSString *)description { + NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [self class], self]; + for (NSUInteger i = 0, count = _count; i < count; ++i) { + if (i == 0) { + [result appendFormat:@"%u", _values[i]]; + } else { + [result appendFormat:@", %u", _values[i]]; + } + } + [result appendFormat:@" }"]; + return result; +} + +- (void)enumerateValuesWithBlock:(void (^)(uint32_t value, NSUInteger idx, BOOL *stop))block { + [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block]; +} + +- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts + usingBlock:(void (^)(uint32_t value, NSUInteger idx, BOOL *stop))block { + // NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok). + BOOL stop = NO; + if ((opts & NSEnumerationReverse) == 0) { + for (NSUInteger i = 0, count = _count; i < count; ++i) { + block(_values[i], i, &stop); + if (stop) break; + } + } else if (_count > 0) { + for (NSUInteger i = _count; i > 0; --i) { + block(_values[i - 1], (i - 1), &stop); + if (stop) break; + } + } +} + +- (uint32_t)valueAtIndex:(NSUInteger)index { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + return _values[index]; +} + +- (void)internalResizeToCapacity:(NSUInteger)newCapacity { + _values = reallocf(_values, newCapacity * sizeof(uint32_t)); + if (_values == NULL) { + _capacity = 0; + _count = 0; + [NSException raise:NSMallocException + format:@"Failed to allocate %lu bytes", + (unsigned long)(newCapacity * sizeof(uint32_t))]; + } + _capacity = newCapacity; +} + +- (void)addValue:(uint32_t)value { + [self addValues:&value count:1]; +} + +- (void)addValues:(const uint32_t [])values count:(NSUInteger)count { + if (values == NULL || count == 0) return; + NSUInteger initialCount = _count; + NSUInteger newCount = initialCount + count; + if (newCount > _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } + _count = newCount; + memcpy(&_values[initialCount], values, count * sizeof(uint32_t)); + if (_autocreator) { + GPBAutocreatedArrayModified(_autocreator, self); + } +} + +- (void)insertValue:(uint32_t)value atIndex:(NSUInteger)index { + if (index >= _count + 1) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count + 1]; + } + NSUInteger initialCount = _count; + NSUInteger newCount = initialCount + 1; + if (newCount > _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } + _count = newCount; + if (index != initialCount) { + memmove(&_values[index + 1], &_values[index], (initialCount - index) * sizeof(uint32_t)); + } + _values[index] = value; + if (_autocreator) { + GPBAutocreatedArrayModified(_autocreator, self); + } +} + +- (void)replaceValueAtIndex:(NSUInteger)index withValue:(uint32_t)value { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + _values[index] = value; +} + +- (void)addValuesFromArray:(GPBUInt32Array *)array { + [self addValues:array->_values count:array->_count]; +} + +- (void)removeValueAtIndex:(NSUInteger)index { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + NSUInteger newCount = _count - 1; + if (index != newCount) { + memmove(&_values[index], &_values[index + 1], (newCount - index) * sizeof(uint32_t)); + } + _count = newCount; + if ((newCount + (2 * kChunkSize)) < _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } +} + +- (void)removeAll { + _count = 0; + if ((0 + (2 * kChunkSize)) < _capacity) { + [self internalResizeToCapacity:CapacityFromCount(0)]; + } +} + +- (void)exchangeValueAtIndex:(NSUInteger)idx1 + withValueAtIndex:(NSUInteger)idx2 { + if (idx1 >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)idx1, (unsigned long)_count]; + } + if (idx2 >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)idx2, (unsigned long)_count]; + } + uint32_t temp = _values[idx1]; + _values[idx1] = _values[idx2]; + _values[idx2] = temp; +} + +@end + +//%PDDM-EXPAND ARRAY_INTERFACE_SIMPLE(Int64, int64_t, %lld) +// This block of code is generated, do not edit it directly. + +#pragma mark - Int64 + +@implementation GPBInt64Array { + @package + int64_t *_values; + NSUInteger _count; + NSUInteger _capacity; +} + +@synthesize count = _count; + ++ (instancetype)array { + return [[[self alloc] init] autorelease]; +} + ++ (instancetype)arrayWithValue:(int64_t)value { + // Cast is needed so the compiler knows what class we are invoking initWithValues: on to get + // the type correct. + return [[(GPBInt64Array*)[self alloc] initWithValues:&value count:1] autorelease]; +} + ++ (instancetype)arrayWithValueArray:(GPBInt64Array *)array { + return [[(GPBInt64Array*)[self alloc] initWithValueArray:array] autorelease]; +} + ++ (instancetype)arrayWithCapacity:(NSUInteger)count { + return [[[self alloc] initWithCapacity:count] autorelease]; +} + +- (instancetype)init { + self = [super init]; + // No work needed; + return self; +} + +- (instancetype)initWithValueArray:(GPBInt64Array *)array { + return [self initWithValues:array->_values count:array->_count]; +} + +- (instancetype)initWithValues:(const int64_t [])values count:(NSUInteger)count { + self = [self init]; + if (self) { + if (count && values) { + _values = reallocf(_values, count * sizeof(int64_t)); + if (_values != NULL) { + _capacity = count; + memcpy(_values, values, count * sizeof(int64_t)); + _count = count; + } else { + [self release]; + [NSException raise:NSMallocException + format:@"Failed to allocate %lu bytes", + (unsigned long)(count * sizeof(int64_t))]; + } + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)count { + self = [self initWithValues:NULL count:0]; + if (self && count) { + [self internalResizeToCapacity:count]; + } + return self; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBInt64Array allocWithZone:zone] initWithValues:_values count:_count]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + free(_values); + [super dealloc]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBInt64Array class]]) { + return NO; + } + GPBInt64Array *otherArray = other; + return (_count == otherArray->_count + && memcmp(_values, otherArray->_values, (_count * sizeof(int64_t))) == 0); +} + +- (NSUInteger)hash { + // Follow NSArray's lead, and use the count as the hash. + return _count; +} + +- (NSString *)description { + NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [self class], self]; + for (NSUInteger i = 0, count = _count; i < count; ++i) { + if (i == 0) { + [result appendFormat:@"%lld", _values[i]]; + } else { + [result appendFormat:@", %lld", _values[i]]; + } + } + [result appendFormat:@" }"]; + return result; +} + +- (void)enumerateValuesWithBlock:(void (^)(int64_t value, NSUInteger idx, BOOL *stop))block { + [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block]; +} + +- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts + usingBlock:(void (^)(int64_t value, NSUInteger idx, BOOL *stop))block { + // NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok). + BOOL stop = NO; + if ((opts & NSEnumerationReverse) == 0) { + for (NSUInteger i = 0, count = _count; i < count; ++i) { + block(_values[i], i, &stop); + if (stop) break; + } + } else if (_count > 0) { + for (NSUInteger i = _count; i > 0; --i) { + block(_values[i - 1], (i - 1), &stop); + if (stop) break; + } + } +} + +- (int64_t)valueAtIndex:(NSUInteger)index { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + return _values[index]; +} + +- (void)internalResizeToCapacity:(NSUInteger)newCapacity { + _values = reallocf(_values, newCapacity * sizeof(int64_t)); + if (_values == NULL) { + _capacity = 0; + _count = 0; + [NSException raise:NSMallocException + format:@"Failed to allocate %lu bytes", + (unsigned long)(newCapacity * sizeof(int64_t))]; + } + _capacity = newCapacity; +} + +- (void)addValue:(int64_t)value { + [self addValues:&value count:1]; +} + +- (void)addValues:(const int64_t [])values count:(NSUInteger)count { + if (values == NULL || count == 0) return; + NSUInteger initialCount = _count; + NSUInteger newCount = initialCount + count; + if (newCount > _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } + _count = newCount; + memcpy(&_values[initialCount], values, count * sizeof(int64_t)); + if (_autocreator) { + GPBAutocreatedArrayModified(_autocreator, self); + } +} + +- (void)insertValue:(int64_t)value atIndex:(NSUInteger)index { + if (index >= _count + 1) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count + 1]; + } + NSUInteger initialCount = _count; + NSUInteger newCount = initialCount + 1; + if (newCount > _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } + _count = newCount; + if (index != initialCount) { + memmove(&_values[index + 1], &_values[index], (initialCount - index) * sizeof(int64_t)); + } + _values[index] = value; + if (_autocreator) { + GPBAutocreatedArrayModified(_autocreator, self); + } +} + +- (void)replaceValueAtIndex:(NSUInteger)index withValue:(int64_t)value { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + _values[index] = value; +} + +- (void)addValuesFromArray:(GPBInt64Array *)array { + [self addValues:array->_values count:array->_count]; +} + +- (void)removeValueAtIndex:(NSUInteger)index { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + NSUInteger newCount = _count - 1; + if (index != newCount) { + memmove(&_values[index], &_values[index + 1], (newCount - index) * sizeof(int64_t)); + } + _count = newCount; + if ((newCount + (2 * kChunkSize)) < _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } +} + +- (void)removeAll { + _count = 0; + if ((0 + (2 * kChunkSize)) < _capacity) { + [self internalResizeToCapacity:CapacityFromCount(0)]; + } +} + +- (void)exchangeValueAtIndex:(NSUInteger)idx1 + withValueAtIndex:(NSUInteger)idx2 { + if (idx1 >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)idx1, (unsigned long)_count]; + } + if (idx2 >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)idx2, (unsigned long)_count]; + } + int64_t temp = _values[idx1]; + _values[idx1] = _values[idx2]; + _values[idx2] = temp; +} + +@end + +//%PDDM-EXPAND ARRAY_INTERFACE_SIMPLE(UInt64, uint64_t, %llu) +// This block of code is generated, do not edit it directly. + +#pragma mark - UInt64 + +@implementation GPBUInt64Array { + @package + uint64_t *_values; + NSUInteger _count; + NSUInteger _capacity; +} + +@synthesize count = _count; + ++ (instancetype)array { + return [[[self alloc] init] autorelease]; +} + ++ (instancetype)arrayWithValue:(uint64_t)value { + // Cast is needed so the compiler knows what class we are invoking initWithValues: on to get + // the type correct. + return [[(GPBUInt64Array*)[self alloc] initWithValues:&value count:1] autorelease]; +} + ++ (instancetype)arrayWithValueArray:(GPBUInt64Array *)array { + return [[(GPBUInt64Array*)[self alloc] initWithValueArray:array] autorelease]; +} + ++ (instancetype)arrayWithCapacity:(NSUInteger)count { + return [[[self alloc] initWithCapacity:count] autorelease]; +} + +- (instancetype)init { + self = [super init]; + // No work needed; + return self; +} + +- (instancetype)initWithValueArray:(GPBUInt64Array *)array { + return [self initWithValues:array->_values count:array->_count]; +} + +- (instancetype)initWithValues:(const uint64_t [])values count:(NSUInteger)count { + self = [self init]; + if (self) { + if (count && values) { + _values = reallocf(_values, count * sizeof(uint64_t)); + if (_values != NULL) { + _capacity = count; + memcpy(_values, values, count * sizeof(uint64_t)); + _count = count; + } else { + [self release]; + [NSException raise:NSMallocException + format:@"Failed to allocate %lu bytes", + (unsigned long)(count * sizeof(uint64_t))]; + } + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)count { + self = [self initWithValues:NULL count:0]; + if (self && count) { + [self internalResizeToCapacity:count]; + } + return self; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBUInt64Array allocWithZone:zone] initWithValues:_values count:_count]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + free(_values); + [super dealloc]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBUInt64Array class]]) { + return NO; + } + GPBUInt64Array *otherArray = other; + return (_count == otherArray->_count + && memcmp(_values, otherArray->_values, (_count * sizeof(uint64_t))) == 0); +} + +- (NSUInteger)hash { + // Follow NSArray's lead, and use the count as the hash. + return _count; +} + +- (NSString *)description { + NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [self class], self]; + for (NSUInteger i = 0, count = _count; i < count; ++i) { + if (i == 0) { + [result appendFormat:@"%llu", _values[i]]; + } else { + [result appendFormat:@", %llu", _values[i]]; + } + } + [result appendFormat:@" }"]; + return result; +} + +- (void)enumerateValuesWithBlock:(void (^)(uint64_t value, NSUInteger idx, BOOL *stop))block { + [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block]; +} + +- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts + usingBlock:(void (^)(uint64_t value, NSUInteger idx, BOOL *stop))block { + // NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok). + BOOL stop = NO; + if ((opts & NSEnumerationReverse) == 0) { + for (NSUInteger i = 0, count = _count; i < count; ++i) { + block(_values[i], i, &stop); + if (stop) break; + } + } else if (_count > 0) { + for (NSUInteger i = _count; i > 0; --i) { + block(_values[i - 1], (i - 1), &stop); + if (stop) break; + } + } +} + +- (uint64_t)valueAtIndex:(NSUInteger)index { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + return _values[index]; +} + +- (void)internalResizeToCapacity:(NSUInteger)newCapacity { + _values = reallocf(_values, newCapacity * sizeof(uint64_t)); + if (_values == NULL) { + _capacity = 0; + _count = 0; + [NSException raise:NSMallocException + format:@"Failed to allocate %lu bytes", + (unsigned long)(newCapacity * sizeof(uint64_t))]; + } + _capacity = newCapacity; +} + +- (void)addValue:(uint64_t)value { + [self addValues:&value count:1]; +} + +- (void)addValues:(const uint64_t [])values count:(NSUInteger)count { + if (values == NULL || count == 0) return; + NSUInteger initialCount = _count; + NSUInteger newCount = initialCount + count; + if (newCount > _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } + _count = newCount; + memcpy(&_values[initialCount], values, count * sizeof(uint64_t)); + if (_autocreator) { + GPBAutocreatedArrayModified(_autocreator, self); + } +} + +- (void)insertValue:(uint64_t)value atIndex:(NSUInteger)index { + if (index >= _count + 1) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count + 1]; + } + NSUInteger initialCount = _count; + NSUInteger newCount = initialCount + 1; + if (newCount > _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } + _count = newCount; + if (index != initialCount) { + memmove(&_values[index + 1], &_values[index], (initialCount - index) * sizeof(uint64_t)); + } + _values[index] = value; + if (_autocreator) { + GPBAutocreatedArrayModified(_autocreator, self); + } +} + +- (void)replaceValueAtIndex:(NSUInteger)index withValue:(uint64_t)value { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + _values[index] = value; +} + +- (void)addValuesFromArray:(GPBUInt64Array *)array { + [self addValues:array->_values count:array->_count]; +} + +- (void)removeValueAtIndex:(NSUInteger)index { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + NSUInteger newCount = _count - 1; + if (index != newCount) { + memmove(&_values[index], &_values[index + 1], (newCount - index) * sizeof(uint64_t)); + } + _count = newCount; + if ((newCount + (2 * kChunkSize)) < _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } +} + +- (void)removeAll { + _count = 0; + if ((0 + (2 * kChunkSize)) < _capacity) { + [self internalResizeToCapacity:CapacityFromCount(0)]; + } +} + +- (void)exchangeValueAtIndex:(NSUInteger)idx1 + withValueAtIndex:(NSUInteger)idx2 { + if (idx1 >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)idx1, (unsigned long)_count]; + } + if (idx2 >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)idx2, (unsigned long)_count]; + } + uint64_t temp = _values[idx1]; + _values[idx1] = _values[idx2]; + _values[idx2] = temp; +} + +@end + +//%PDDM-EXPAND ARRAY_INTERFACE_SIMPLE(Float, float, %f) +// This block of code is generated, do not edit it directly. + +#pragma mark - Float + +@implementation GPBFloatArray { + @package + float *_values; + NSUInteger _count; + NSUInteger _capacity; +} + +@synthesize count = _count; + ++ (instancetype)array { + return [[[self alloc] init] autorelease]; +} + ++ (instancetype)arrayWithValue:(float)value { + // Cast is needed so the compiler knows what class we are invoking initWithValues: on to get + // the type correct. + return [[(GPBFloatArray*)[self alloc] initWithValues:&value count:1] autorelease]; +} + ++ (instancetype)arrayWithValueArray:(GPBFloatArray *)array { + return [[(GPBFloatArray*)[self alloc] initWithValueArray:array] autorelease]; +} + ++ (instancetype)arrayWithCapacity:(NSUInteger)count { + return [[[self alloc] initWithCapacity:count] autorelease]; +} + +- (instancetype)init { + self = [super init]; + // No work needed; + return self; +} + +- (instancetype)initWithValueArray:(GPBFloatArray *)array { + return [self initWithValues:array->_values count:array->_count]; +} + +- (instancetype)initWithValues:(const float [])values count:(NSUInteger)count { + self = [self init]; + if (self) { + if (count && values) { + _values = reallocf(_values, count * sizeof(float)); + if (_values != NULL) { + _capacity = count; + memcpy(_values, values, count * sizeof(float)); + _count = count; + } else { + [self release]; + [NSException raise:NSMallocException + format:@"Failed to allocate %lu bytes", + (unsigned long)(count * sizeof(float))]; + } + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)count { + self = [self initWithValues:NULL count:0]; + if (self && count) { + [self internalResizeToCapacity:count]; + } + return self; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBFloatArray allocWithZone:zone] initWithValues:_values count:_count]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + free(_values); + [super dealloc]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBFloatArray class]]) { + return NO; + } + GPBFloatArray *otherArray = other; + return (_count == otherArray->_count + && memcmp(_values, otherArray->_values, (_count * sizeof(float))) == 0); +} + +- (NSUInteger)hash { + // Follow NSArray's lead, and use the count as the hash. + return _count; +} + +- (NSString *)description { + NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [self class], self]; + for (NSUInteger i = 0, count = _count; i < count; ++i) { + if (i == 0) { + [result appendFormat:@"%f", _values[i]]; + } else { + [result appendFormat:@", %f", _values[i]]; + } + } + [result appendFormat:@" }"]; + return result; +} + +- (void)enumerateValuesWithBlock:(void (^)(float value, NSUInteger idx, BOOL *stop))block { + [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block]; +} + +- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts + usingBlock:(void (^)(float value, NSUInteger idx, BOOL *stop))block { + // NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok). + BOOL stop = NO; + if ((opts & NSEnumerationReverse) == 0) { + for (NSUInteger i = 0, count = _count; i < count; ++i) { + block(_values[i], i, &stop); + if (stop) break; + } + } else if (_count > 0) { + for (NSUInteger i = _count; i > 0; --i) { + block(_values[i - 1], (i - 1), &stop); + if (stop) break; + } + } +} + +- (float)valueAtIndex:(NSUInteger)index { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + return _values[index]; +} + +- (void)internalResizeToCapacity:(NSUInteger)newCapacity { + _values = reallocf(_values, newCapacity * sizeof(float)); + if (_values == NULL) { + _capacity = 0; + _count = 0; + [NSException raise:NSMallocException + format:@"Failed to allocate %lu bytes", + (unsigned long)(newCapacity * sizeof(float))]; + } + _capacity = newCapacity; +} + +- (void)addValue:(float)value { + [self addValues:&value count:1]; +} + +- (void)addValues:(const float [])values count:(NSUInteger)count { + if (values == NULL || count == 0) return; + NSUInteger initialCount = _count; + NSUInteger newCount = initialCount + count; + if (newCount > _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } + _count = newCount; + memcpy(&_values[initialCount], values, count * sizeof(float)); + if (_autocreator) { + GPBAutocreatedArrayModified(_autocreator, self); + } +} + +- (void)insertValue:(float)value atIndex:(NSUInteger)index { + if (index >= _count + 1) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count + 1]; + } + NSUInteger initialCount = _count; + NSUInteger newCount = initialCount + 1; + if (newCount > _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } + _count = newCount; + if (index != initialCount) { + memmove(&_values[index + 1], &_values[index], (initialCount - index) * sizeof(float)); + } + _values[index] = value; + if (_autocreator) { + GPBAutocreatedArrayModified(_autocreator, self); + } +} + +- (void)replaceValueAtIndex:(NSUInteger)index withValue:(float)value { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + _values[index] = value; +} + +- (void)addValuesFromArray:(GPBFloatArray *)array { + [self addValues:array->_values count:array->_count]; +} + +- (void)removeValueAtIndex:(NSUInteger)index { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + NSUInteger newCount = _count - 1; + if (index != newCount) { + memmove(&_values[index], &_values[index + 1], (newCount - index) * sizeof(float)); + } + _count = newCount; + if ((newCount + (2 * kChunkSize)) < _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } +} + +- (void)removeAll { + _count = 0; + if ((0 + (2 * kChunkSize)) < _capacity) { + [self internalResizeToCapacity:CapacityFromCount(0)]; + } +} + +- (void)exchangeValueAtIndex:(NSUInteger)idx1 + withValueAtIndex:(NSUInteger)idx2 { + if (idx1 >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)idx1, (unsigned long)_count]; + } + if (idx2 >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)idx2, (unsigned long)_count]; + } + float temp = _values[idx1]; + _values[idx1] = _values[idx2]; + _values[idx2] = temp; +} + +@end + +//%PDDM-EXPAND ARRAY_INTERFACE_SIMPLE(Double, double, %lf) +// This block of code is generated, do not edit it directly. + +#pragma mark - Double + +@implementation GPBDoubleArray { + @package + double *_values; + NSUInteger _count; + NSUInteger _capacity; +} + +@synthesize count = _count; + ++ (instancetype)array { + return [[[self alloc] init] autorelease]; +} + ++ (instancetype)arrayWithValue:(double)value { + // Cast is needed so the compiler knows what class we are invoking initWithValues: on to get + // the type correct. + return [[(GPBDoubleArray*)[self alloc] initWithValues:&value count:1] autorelease]; +} + ++ (instancetype)arrayWithValueArray:(GPBDoubleArray *)array { + return [[(GPBDoubleArray*)[self alloc] initWithValueArray:array] autorelease]; +} + ++ (instancetype)arrayWithCapacity:(NSUInteger)count { + return [[[self alloc] initWithCapacity:count] autorelease]; +} + +- (instancetype)init { + self = [super init]; + // No work needed; + return self; +} + +- (instancetype)initWithValueArray:(GPBDoubleArray *)array { + return [self initWithValues:array->_values count:array->_count]; +} + +- (instancetype)initWithValues:(const double [])values count:(NSUInteger)count { + self = [self init]; + if (self) { + if (count && values) { + _values = reallocf(_values, count * sizeof(double)); + if (_values != NULL) { + _capacity = count; + memcpy(_values, values, count * sizeof(double)); + _count = count; + } else { + [self release]; + [NSException raise:NSMallocException + format:@"Failed to allocate %lu bytes", + (unsigned long)(count * sizeof(double))]; + } + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)count { + self = [self initWithValues:NULL count:0]; + if (self && count) { + [self internalResizeToCapacity:count]; + } + return self; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBDoubleArray allocWithZone:zone] initWithValues:_values count:_count]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + free(_values); + [super dealloc]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBDoubleArray class]]) { + return NO; + } + GPBDoubleArray *otherArray = other; + return (_count == otherArray->_count + && memcmp(_values, otherArray->_values, (_count * sizeof(double))) == 0); +} + +- (NSUInteger)hash { + // Follow NSArray's lead, and use the count as the hash. + return _count; +} + +- (NSString *)description { + NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [self class], self]; + for (NSUInteger i = 0, count = _count; i < count; ++i) { + if (i == 0) { + [result appendFormat:@"%lf", _values[i]]; + } else { + [result appendFormat:@", %lf", _values[i]]; + } + } + [result appendFormat:@" }"]; + return result; +} + +- (void)enumerateValuesWithBlock:(void (^)(double value, NSUInteger idx, BOOL *stop))block { + [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block]; +} + +- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts + usingBlock:(void (^)(double value, NSUInteger idx, BOOL *stop))block { + // NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok). + BOOL stop = NO; + if ((opts & NSEnumerationReverse) == 0) { + for (NSUInteger i = 0, count = _count; i < count; ++i) { + block(_values[i], i, &stop); + if (stop) break; + } + } else if (_count > 0) { + for (NSUInteger i = _count; i > 0; --i) { + block(_values[i - 1], (i - 1), &stop); + if (stop) break; + } + } +} + +- (double)valueAtIndex:(NSUInteger)index { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + return _values[index]; +} + +- (void)internalResizeToCapacity:(NSUInteger)newCapacity { + _values = reallocf(_values, newCapacity * sizeof(double)); + if (_values == NULL) { + _capacity = 0; + _count = 0; + [NSException raise:NSMallocException + format:@"Failed to allocate %lu bytes", + (unsigned long)(newCapacity * sizeof(double))]; + } + _capacity = newCapacity; +} + +- (void)addValue:(double)value { + [self addValues:&value count:1]; +} + +- (void)addValues:(const double [])values count:(NSUInteger)count { + if (values == NULL || count == 0) return; + NSUInteger initialCount = _count; + NSUInteger newCount = initialCount + count; + if (newCount > _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } + _count = newCount; + memcpy(&_values[initialCount], values, count * sizeof(double)); + if (_autocreator) { + GPBAutocreatedArrayModified(_autocreator, self); + } +} + +- (void)insertValue:(double)value atIndex:(NSUInteger)index { + if (index >= _count + 1) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count + 1]; + } + NSUInteger initialCount = _count; + NSUInteger newCount = initialCount + 1; + if (newCount > _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } + _count = newCount; + if (index != initialCount) { + memmove(&_values[index + 1], &_values[index], (initialCount - index) * sizeof(double)); + } + _values[index] = value; + if (_autocreator) { + GPBAutocreatedArrayModified(_autocreator, self); + } +} + +- (void)replaceValueAtIndex:(NSUInteger)index withValue:(double)value { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + _values[index] = value; +} + +- (void)addValuesFromArray:(GPBDoubleArray *)array { + [self addValues:array->_values count:array->_count]; +} + +- (void)removeValueAtIndex:(NSUInteger)index { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + NSUInteger newCount = _count - 1; + if (index != newCount) { + memmove(&_values[index], &_values[index + 1], (newCount - index) * sizeof(double)); + } + _count = newCount; + if ((newCount + (2 * kChunkSize)) < _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } +} + +- (void)removeAll { + _count = 0; + if ((0 + (2 * kChunkSize)) < _capacity) { + [self internalResizeToCapacity:CapacityFromCount(0)]; + } +} + +- (void)exchangeValueAtIndex:(NSUInteger)idx1 + withValueAtIndex:(NSUInteger)idx2 { + if (idx1 >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)idx1, (unsigned long)_count]; + } + if (idx2 >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)idx2, (unsigned long)_count]; + } + double temp = _values[idx1]; + _values[idx1] = _values[idx2]; + _values[idx2] = temp; +} + +@end + +//%PDDM-EXPAND ARRAY_INTERFACE_SIMPLE(Bool, BOOL, %d) +// This block of code is generated, do not edit it directly. + +#pragma mark - Bool + +@implementation GPBBoolArray { + @package + BOOL *_values; + NSUInteger _count; + NSUInteger _capacity; +} + +@synthesize count = _count; + ++ (instancetype)array { + return [[[self alloc] init] autorelease]; +} + ++ (instancetype)arrayWithValue:(BOOL)value { + // Cast is needed so the compiler knows what class we are invoking initWithValues: on to get + // the type correct. + return [[(GPBBoolArray*)[self alloc] initWithValues:&value count:1] autorelease]; +} + ++ (instancetype)arrayWithValueArray:(GPBBoolArray *)array { + return [[(GPBBoolArray*)[self alloc] initWithValueArray:array] autorelease]; +} + ++ (instancetype)arrayWithCapacity:(NSUInteger)count { + return [[[self alloc] initWithCapacity:count] autorelease]; +} + +- (instancetype)init { + self = [super init]; + // No work needed; + return self; +} + +- (instancetype)initWithValueArray:(GPBBoolArray *)array { + return [self initWithValues:array->_values count:array->_count]; +} + +- (instancetype)initWithValues:(const BOOL [])values count:(NSUInteger)count { + self = [self init]; + if (self) { + if (count && values) { + _values = reallocf(_values, count * sizeof(BOOL)); + if (_values != NULL) { + _capacity = count; + memcpy(_values, values, count * sizeof(BOOL)); + _count = count; + } else { + [self release]; + [NSException raise:NSMallocException + format:@"Failed to allocate %lu bytes", + (unsigned long)(count * sizeof(BOOL))]; + } + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)count { + self = [self initWithValues:NULL count:0]; + if (self && count) { + [self internalResizeToCapacity:count]; + } + return self; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBBoolArray allocWithZone:zone] initWithValues:_values count:_count]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + free(_values); + [super dealloc]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBBoolArray class]]) { + return NO; + } + GPBBoolArray *otherArray = other; + return (_count == otherArray->_count + && memcmp(_values, otherArray->_values, (_count * sizeof(BOOL))) == 0); +} + +- (NSUInteger)hash { + // Follow NSArray's lead, and use the count as the hash. + return _count; +} + +- (NSString *)description { + NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [self class], self]; + for (NSUInteger i = 0, count = _count; i < count; ++i) { + if (i == 0) { + [result appendFormat:@"%d", _values[i]]; + } else { + [result appendFormat:@", %d", _values[i]]; + } + } + [result appendFormat:@" }"]; + return result; +} + +- (void)enumerateValuesWithBlock:(void (^)(BOOL value, NSUInteger idx, BOOL *stop))block { + [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block]; +} + +- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts + usingBlock:(void (^)(BOOL value, NSUInteger idx, BOOL *stop))block { + // NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok). + BOOL stop = NO; + if ((opts & NSEnumerationReverse) == 0) { + for (NSUInteger i = 0, count = _count; i < count; ++i) { + block(_values[i], i, &stop); + if (stop) break; + } + } else if (_count > 0) { + for (NSUInteger i = _count; i > 0; --i) { + block(_values[i - 1], (i - 1), &stop); + if (stop) break; + } + } +} + +- (BOOL)valueAtIndex:(NSUInteger)index { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + return _values[index]; +} + +- (void)internalResizeToCapacity:(NSUInteger)newCapacity { + _values = reallocf(_values, newCapacity * sizeof(BOOL)); + if (_values == NULL) { + _capacity = 0; + _count = 0; + [NSException raise:NSMallocException + format:@"Failed to allocate %lu bytes", + (unsigned long)(newCapacity * sizeof(BOOL))]; + } + _capacity = newCapacity; +} + +- (void)addValue:(BOOL)value { + [self addValues:&value count:1]; +} + +- (void)addValues:(const BOOL [])values count:(NSUInteger)count { + if (values == NULL || count == 0) return; + NSUInteger initialCount = _count; + NSUInteger newCount = initialCount + count; + if (newCount > _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } + _count = newCount; + memcpy(&_values[initialCount], values, count * sizeof(BOOL)); + if (_autocreator) { + GPBAutocreatedArrayModified(_autocreator, self); + } +} + +- (void)insertValue:(BOOL)value atIndex:(NSUInteger)index { + if (index >= _count + 1) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count + 1]; + } + NSUInteger initialCount = _count; + NSUInteger newCount = initialCount + 1; + if (newCount > _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } + _count = newCount; + if (index != initialCount) { + memmove(&_values[index + 1], &_values[index], (initialCount - index) * sizeof(BOOL)); + } + _values[index] = value; + if (_autocreator) { + GPBAutocreatedArrayModified(_autocreator, self); + } +} + +- (void)replaceValueAtIndex:(NSUInteger)index withValue:(BOOL)value { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + _values[index] = value; +} + +- (void)addValuesFromArray:(GPBBoolArray *)array { + [self addValues:array->_values count:array->_count]; +} + +- (void)removeValueAtIndex:(NSUInteger)index { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + NSUInteger newCount = _count - 1; + if (index != newCount) { + memmove(&_values[index], &_values[index + 1], (newCount - index) * sizeof(BOOL)); + } + _count = newCount; + if ((newCount + (2 * kChunkSize)) < _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } +} + +- (void)removeAll { + _count = 0; + if ((0 + (2 * kChunkSize)) < _capacity) { + [self internalResizeToCapacity:CapacityFromCount(0)]; + } +} + +- (void)exchangeValueAtIndex:(NSUInteger)idx1 + withValueAtIndex:(NSUInteger)idx2 { + if (idx1 >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)idx1, (unsigned long)_count]; + } + if (idx2 >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)idx2, (unsigned long)_count]; + } + BOOL temp = _values[idx1]; + _values[idx1] = _values[idx2]; + _values[idx2] = temp; +} + +@end + +//%PDDM-EXPAND-END (7 expansions) + +#pragma mark - Enum + +@implementation GPBEnumArray { + @package + GPBEnumValidationFunc _validationFunc; + int32_t *_values; + NSUInteger _count; + NSUInteger _capacity; +} + +@synthesize count = _count; +@synthesize validationFunc = _validationFunc; + ++ (instancetype)array { + return [[[self alloc] initWithValidationFunction:NULL] autorelease]; +} + ++ (instancetype)arrayWithValidationFunction:(GPBEnumValidationFunc)func { + return [[[self alloc] initWithValidationFunction:func] autorelease]; +} + ++ (instancetype)arrayWithValidationFunction:(GPBEnumValidationFunc)func + rawValue:(int32_t)value { + return [[[self alloc] initWithValidationFunction:func + rawValues:&value + count:1] autorelease]; +} + ++ (instancetype)arrayWithValueArray:(GPBEnumArray *)array { + return [[(GPBEnumArray*)[self alloc] initWithValueArray:array] autorelease]; +} + ++ (instancetype)arrayWithValidationFunction:(GPBEnumValidationFunc)func + capacity:(NSUInteger)count { + return [[[self alloc] initWithValidationFunction:func capacity:count] autorelease]; +} + +- (instancetype)init { + return [self initWithValidationFunction:NULL]; +} + +- (instancetype)initWithValueArray:(GPBEnumArray *)array { + return [self initWithValidationFunction:array->_validationFunc + rawValues:array->_values + count:array->_count]; +} + +- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func { + self = [super init]; + if (self) { + _validationFunc = (func != NULL ? func : ArrayDefault_IsValidValue); + } + return self; +} + +- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func + rawValues:(const int32_t [])values + count:(NSUInteger)count { + self = [self initWithValidationFunction:func]; + if (self) { + if (count && values) { + _values = reallocf(_values, count * sizeof(int32_t)); + if (_values != NULL) { + _capacity = count; + memcpy(_values, values, count * sizeof(int32_t)); + _count = count; + } else { + [self release]; + [NSException raise:NSMallocException + format:@"Failed to allocate %lu bytes", + (unsigned long)(count * sizeof(int32_t))]; + } + } + } + return self; +} + +- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func + capacity:(NSUInteger)count { + self = [self initWithValidationFunction:func]; + if (self && count) { + [self internalResizeToCapacity:count]; + } + return self; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBEnumArray allocWithZone:zone] + initWithValidationFunction:_validationFunc + rawValues:_values + count:_count]; +} + +//%PDDM-EXPAND ARRAY_IMMUTABLE_CORE(Enum, int32_t, Raw, %d) +// This block of code is generated, do not edit it directly. + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + free(_values); + [super dealloc]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBEnumArray class]]) { + return NO; + } + GPBEnumArray *otherArray = other; + return (_count == otherArray->_count + && memcmp(_values, otherArray->_values, (_count * sizeof(int32_t))) == 0); +} + +- (NSUInteger)hash { + // Follow NSArray's lead, and use the count as the hash. + return _count; +} + +- (NSString *)description { + NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [self class], self]; + for (NSUInteger i = 0, count = _count; i < count; ++i) { + if (i == 0) { + [result appendFormat:@"%d", _values[i]]; + } else { + [result appendFormat:@", %d", _values[i]]; + } + } + [result appendFormat:@" }"]; + return result; +} + +- (void)enumerateRawValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block { + [self enumerateRawValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block]; +} + +- (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts + usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block { + // NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok). + BOOL stop = NO; + if ((opts & NSEnumerationReverse) == 0) { + for (NSUInteger i = 0, count = _count; i < count; ++i) { + block(_values[i], i, &stop); + if (stop) break; + } + } else if (_count > 0) { + for (NSUInteger i = _count; i > 0; --i) { + block(_values[i - 1], (i - 1), &stop); + if (stop) break; + } + } +} +//%PDDM-EXPAND-END ARRAY_IMMUTABLE_CORE(Enum, int32_t, Raw, %d) + +- (int32_t)valueAtIndex:(NSUInteger)index { +//%PDDM-EXPAND VALIDATE_RANGE(index, _count) +// This block of code is generated, do not edit it directly. + + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } +//%PDDM-EXPAND-END VALIDATE_RANGE(index, _count) + int32_t result = _values[index]; + if (!_validationFunc(result)) { + result = kGPBUnrecognizedEnumeratorValue; + } + return result; +} + +- (int32_t)rawValueAtIndex:(NSUInteger)index { +//%PDDM-EXPAND VALIDATE_RANGE(index, _count) +// This block of code is generated, do not edit it directly. + + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } +//%PDDM-EXPAND-END VALIDATE_RANGE(index, _count) + return _values[index]; +} + +- (void)enumerateValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block { + [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block]; +} + +- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts + usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block { + // NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok). + BOOL stop = NO; + GPBEnumValidationFunc func = _validationFunc; + if ((opts & NSEnumerationReverse) == 0) { + int32_t *scan = _values; + int32_t *end = scan + _count; + for (NSUInteger i = 0; scan < end; ++i, ++scan) { + int32_t value = *scan; + if (!func(value)) { + value = kGPBUnrecognizedEnumeratorValue; + } + block(value, i, &stop); + if (stop) break; + } + } else if (_count > 0) { + int32_t *end = _values; + int32_t *scan = end + (_count - 1); + for (NSUInteger i = (_count - 1); scan >= end; --i, --scan) { + int32_t value = *scan; + if (!func(value)) { + value = kGPBUnrecognizedEnumeratorValue; + } + block(value, i, &stop); + if (stop) break; + } + } +} + +//%PDDM-EXPAND ARRAY_MUTABLE_CORE(Enum, int32_t, Raw, %d) +// This block of code is generated, do not edit it directly. + +- (void)internalResizeToCapacity:(NSUInteger)newCapacity { + _values = reallocf(_values, newCapacity * sizeof(int32_t)); + if (_values == NULL) { + _capacity = 0; + _count = 0; + [NSException raise:NSMallocException + format:@"Failed to allocate %lu bytes", + (unsigned long)(newCapacity * sizeof(int32_t))]; + } + _capacity = newCapacity; +} + +- (void)addRawValue:(int32_t)value { + [self addRawValues:&value count:1]; +} + +- (void)addRawValues:(const int32_t [])values count:(NSUInteger)count { + if (values == NULL || count == 0) return; + NSUInteger initialCount = _count; + NSUInteger newCount = initialCount + count; + if (newCount > _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } + _count = newCount; + memcpy(&_values[initialCount], values, count * sizeof(int32_t)); + if (_autocreator) { + GPBAutocreatedArrayModified(_autocreator, self); + } +} + +- (void)insertRawValue:(int32_t)value atIndex:(NSUInteger)index { + if (index >= _count + 1) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count + 1]; + } + NSUInteger initialCount = _count; + NSUInteger newCount = initialCount + 1; + if (newCount > _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } + _count = newCount; + if (index != initialCount) { + memmove(&_values[index + 1], &_values[index], (initialCount - index) * sizeof(int32_t)); + } + _values[index] = value; + if (_autocreator) { + GPBAutocreatedArrayModified(_autocreator, self); + } +} + +- (void)replaceValueAtIndex:(NSUInteger)index withRawValue:(int32_t)value { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + _values[index] = value; +} + +- (void)addRawValuesFromArray:(GPBEnumArray *)array { + [self addRawValues:array->_values count:array->_count]; +} + +- (void)removeValueAtIndex:(NSUInteger)index { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + NSUInteger newCount = _count - 1; + if (index != newCount) { + memmove(&_values[index], &_values[index + 1], (newCount - index) * sizeof(int32_t)); + } + _count = newCount; + if ((newCount + (2 * kChunkSize)) < _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } +} + +- (void)removeAll { + _count = 0; + if ((0 + (2 * kChunkSize)) < _capacity) { + [self internalResizeToCapacity:CapacityFromCount(0)]; + } +} + +- (void)exchangeValueAtIndex:(NSUInteger)idx1 + withValueAtIndex:(NSUInteger)idx2 { + if (idx1 >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)idx1, (unsigned long)_count]; + } + if (idx2 >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)idx2, (unsigned long)_count]; + } + int32_t temp = _values[idx1]; + _values[idx1] = _values[idx2]; + _values[idx2] = temp; +} + +//%PDDM-EXPAND MUTATION_METHODS(Enum, int32_t, , EnumValidationList, EnumValidationOne) +// This block of code is generated, do not edit it directly. + +- (void)addValue:(int32_t)value { + [self addValues:&value count:1]; +} + +- (void)addValues:(const int32_t [])values count:(NSUInteger)count { + if (values == NULL || count == 0) return; + GPBEnumValidationFunc func = _validationFunc; + for (NSUInteger i = 0; i < count; ++i) { + if (!func(values[i])) { + [NSException raise:NSInvalidArgumentException + format:@"%@: Attempt to set an unknown enum value (%d)", + [self class], values[i]]; + } + } + NSUInteger initialCount = _count; + NSUInteger newCount = initialCount + count; + if (newCount > _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } + _count = newCount; + memcpy(&_values[initialCount], values, count * sizeof(int32_t)); + if (_autocreator) { + GPBAutocreatedArrayModified(_autocreator, self); + } +} + +- (void)insertValue:(int32_t)value atIndex:(NSUInteger)index { + if (index >= _count + 1) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count + 1]; + } + if (!_validationFunc(value)) { + [NSException raise:NSInvalidArgumentException + format:@"%@: Attempt to set an unknown enum value (%d)", + [self class], value]; + } + NSUInteger initialCount = _count; + NSUInteger newCount = initialCount + 1; + if (newCount > _capacity) { + [self internalResizeToCapacity:CapacityFromCount(newCount)]; + } + _count = newCount; + if (index != initialCount) { + memmove(&_values[index + 1], &_values[index], (initialCount - index) * sizeof(int32_t)); + } + _values[index] = value; + if (_autocreator) { + GPBAutocreatedArrayModified(_autocreator, self); + } +} + +- (void)replaceValueAtIndex:(NSUInteger)index withValue:(int32_t)value { + if (index >= _count) { + [NSException raise:NSRangeException + format:@"Index (%lu) beyond bounds (%lu)", + (unsigned long)index, (unsigned long)_count]; + } + if (!_validationFunc(value)) { + [NSException raise:NSInvalidArgumentException + format:@"%@: Attempt to set an unknown enum value (%d)", + [self class], value]; + } + _values[index] = value; +} +//%PDDM-EXPAND-END (2 expansions) + +//%PDDM-DEFINE MUTATION_HOOK_EnumValidationList() +//% GPBEnumValidationFunc func = _validationFunc; +//% for (NSUInteger i = 0; i < count; ++i) { +//% if (!func(values[i])) { +//% [NSException raise:NSInvalidArgumentException +//% format:@"%@: Attempt to set an unknown enum value (%d)", +//% [self class], values[i]]; +//% } +//% } +//% +//%PDDM-DEFINE MUTATION_HOOK_EnumValidationOne() +//% if (!_validationFunc(value)) { +//% [NSException raise:NSInvalidArgumentException +//% format:@"%@: Attempt to set an unknown enum value (%d)", +//% [self class], value]; +//% } +//% + +@end + +#pragma mark - NSArray Subclass + +@implementation GPBAutocreatedArray { + NSMutableArray *_array; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_array release]; + [super dealloc]; +} + +#pragma mark Required NSArray overrides + +- (NSUInteger)count { + return [_array count]; +} + +- (id)objectAtIndex:(NSUInteger)idx { + return [_array objectAtIndex:idx]; +} + +#pragma mark Required NSMutableArray overrides + +// Only need to call GPBAutocreatedArrayModified() when adding things since +// we only autocreate empty arrays. + +- (void)insertObject:(id)anObject atIndex:(NSUInteger)idx { + if (_array == nil) { + _array = [[NSMutableArray alloc] init]; + } + [_array insertObject:anObject atIndex:idx]; + + if (_autocreator) { + GPBAutocreatedArrayModified(_autocreator, self); + } +} + +- (void)removeObject:(id)anObject { + [_array removeObject:anObject]; +} + +- (void)removeObjectAtIndex:(NSUInteger)idx { + [_array removeObjectAtIndex:idx]; +} + +- (void)addObject:(id)anObject { + if (_array == nil) { + _array = [[NSMutableArray alloc] init]; + } + [_array addObject:anObject]; + + if (_autocreator) { + GPBAutocreatedArrayModified(_autocreator, self); + } +} + +- (void)removeLastObject { + [_array removeLastObject]; +} + +- (void)replaceObjectAtIndex:(NSUInteger)idx withObject:(id)anObject { + [_array replaceObjectAtIndex:idx withObject:anObject]; +} + +#pragma mark Extra things hooked + +- (id)copyWithZone:(NSZone *)zone { + if (_array == nil) { + return [[NSMutableArray allocWithZone:zone] init]; + } + return [_array copyWithZone:zone]; +} + +- (id)mutableCopyWithZone:(NSZone *)zone { + if (_array == nil) { + return [[NSMutableArray allocWithZone:zone] init]; + } + return [_array mutableCopyWithZone:zone]; +} + +- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state + objects:(id __unsafe_unretained [])buffer + count:(NSUInteger)len { + return [_array countByEnumeratingWithState:state objects:buffer count:len]; +} + +- (void)enumerateObjectsUsingBlock:(void (^)(id obj, NSUInteger idx, BOOL *stop))block { + [_array enumerateObjectsUsingBlock:block]; +} + +- (void)enumerateObjectsWithOptions:(NSEnumerationOptions)opts + usingBlock:(void (^)(id obj, NSUInteger idx, BOOL *stop))block { + [_array enumerateObjectsWithOptions:opts usingBlock:block]; +} + +@end + +#pragma clang diagnostic pop diff --git a/Pods/Protobuf/objectivec/GPBArray_PackagePrivate.h b/Pods/Protobuf/objectivec/GPBArray_PackagePrivate.h new file mode 100644 index 0000000..35a4538 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBArray_PackagePrivate.h @@ -0,0 +1,130 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import "GPBArray.h" + +@class GPBMessage; + +//%PDDM-DEFINE DECLARE_ARRAY_EXTRAS() +//%ARRAY_INTERFACE_EXTRAS(Int32, int32_t) +//%ARRAY_INTERFACE_EXTRAS(UInt32, uint32_t) +//%ARRAY_INTERFACE_EXTRAS(Int64, int64_t) +//%ARRAY_INTERFACE_EXTRAS(UInt64, uint64_t) +//%ARRAY_INTERFACE_EXTRAS(Float, float) +//%ARRAY_INTERFACE_EXTRAS(Double, double) +//%ARRAY_INTERFACE_EXTRAS(Bool, BOOL) +//%ARRAY_INTERFACE_EXTRAS(Enum, int32_t) + +//%PDDM-DEFINE ARRAY_INTERFACE_EXTRAS(NAME, TYPE) +//%#pragma mark - NAME +//% +//%@interface GPB##NAME##Array () { +//% @package +//% GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +//%} +//%@end +//% + +//%PDDM-EXPAND DECLARE_ARRAY_EXTRAS() +// This block of code is generated, do not edit it directly. + +#pragma mark - Int32 + +@interface GPBInt32Array () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +#pragma mark - UInt32 + +@interface GPBUInt32Array () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +#pragma mark - Int64 + +@interface GPBInt64Array () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +#pragma mark - UInt64 + +@interface GPBUInt64Array () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +#pragma mark - Float + +@interface GPBFloatArray () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +#pragma mark - Double + +@interface GPBDoubleArray () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +#pragma mark - Bool + +@interface GPBBoolArray () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +#pragma mark - Enum + +@interface GPBEnumArray () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +//%PDDM-EXPAND-END DECLARE_ARRAY_EXTRAS() + +#pragma mark - NSArray Subclass + +@interface GPBAutocreatedArray : NSMutableArray { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end diff --git a/Pods/Protobuf/objectivec/GPBBootstrap.h b/Pods/Protobuf/objectivec/GPBBootstrap.h new file mode 100644 index 0000000..ed53ae7 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBBootstrap.h @@ -0,0 +1,123 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +/** + * The Objective C runtime has complete enough info that most protos don’t end + * up using this, so leaving it on is no cost or very little cost. If you + * happen to see it causing bloat, this is the way to disable it. If you do + * need to disable it, try only disabling it for Release builds as having + * full TextFormat can be useful for debugging. + **/ +#ifndef GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS +#define GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS 0 +#endif + +// Used in the generated code to give sizes to enums. int32_t was chosen based +// on the fact that Protocol Buffers enums are limited to this range. +#if !__has_feature(objc_fixed_enum) + #error All supported Xcode versions should support objc_fixed_enum. +#endif + +// If the headers are imported into Objective-C++, we can run into an issue +// where the defintion of NS_ENUM (really CF_ENUM) changes based on the C++ +// standard that is in effect. If it isn't C++11 or higher, the definition +// doesn't allow us to forward declare. We work around this one case by +// providing a local definition. The default case has to use NS_ENUM for the +// magic that is Swift bridging of enums. +#if (defined(__cplusplus) && __cplusplus && __cplusplus < 201103L) + #define GPB_ENUM(X) enum X : int32_t X; enum X : int32_t +#else + #define GPB_ENUM(X) NS_ENUM(int32_t, X) +#endif + +/** + * GPB_ENUM_FWD_DECLARE is used for forward declaring enums, for example: + * + * ``` + * GPB_ENUM_FWD_DECLARE(Foo_Enum) + * + * @interface BarClass : NSObject + * @property (nonatomic) enum Foo_Enum value; + * - (void)bazMethod:(enum Foo_Enum):value; + * @end + * ``` + **/ +#define GPB_ENUM_FWD_DECLARE(X) enum X : int32_t + +/** + * Based upon CF_INLINE. Forces inlining in non DEBUG builds. + **/ +#if !defined(DEBUG) +#define GPB_INLINE static __inline__ __attribute__((always_inline)) +#else +#define GPB_INLINE static __inline__ +#endif + +/** + * For use in public headers that might need to deal with ARC. + **/ +#ifndef GPB_UNSAFE_UNRETAINED +#if __has_feature(objc_arc) +#define GPB_UNSAFE_UNRETAINED __unsafe_unretained +#else +#define GPB_UNSAFE_UNRETAINED +#endif +#endif + +// If property name starts with init we need to annotate it to get past ARC. +// http://stackoverflow.com/questions/18723226/how-do-i-annotate-an-objective-c-property-with-an-objc-method-family/18723227#18723227 +// +// Meant to be used internally by generated code. +#define GPB_METHOD_FAMILY_NONE __attribute__((objc_method_family(none))) + +// ---------------------------------------------------------------------------- +// These version numbers are all internal to the ObjC Protobuf runtime; they +// are used to ensure compatibility between the generated sources and the +// headers being compiled against and/or the version of sources being run +// against. +// +// They are all #defines so the values are captured into every .o file they +// are used in and to allow comparisons in the preprocessor. + +// Current library runtime version. +// - Gets bumped when the runtime makes changes to the interfaces between the +// generated code and runtime (things added/removed, etc). +#define GOOGLE_PROTOBUF_OBJC_VERSION 30002 + +// Minimum runtime version supported for compiling/running against. +// - Gets changed when support for the older generated code is dropped. +#define GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION 30001 + + +// This is a legacy constant now frozen in time for old generated code. If +// GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION ever gets moved above 30001 then +// this should also change to break code compiled with an old runtime that +// can't be supported any more. +#define GOOGLE_PROTOBUF_OBJC_GEN_VERSION 30001 diff --git a/Pods/Protobuf/objectivec/GPBCodedInputStream.h b/Pods/Protobuf/objectivec/GPBCodedInputStream.h new file mode 100644 index 0000000..fbe5009 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBCodedInputStream.h @@ -0,0 +1,253 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import + +@class GPBMessage; +@class GPBExtensionRegistry; + +NS_ASSUME_NONNULL_BEGIN + +CF_EXTERN_C_BEGIN + +/** + * @c GPBCodedInputStream exception name. Exceptions raised from + * @c GPBCodedInputStream contain an underlying error in the userInfo dictionary + * under the GPBCodedInputStreamUnderlyingErrorKey key. + **/ +extern NSString *const GPBCodedInputStreamException; + +/** The key under which the underlying NSError from the exception is stored. */ +extern NSString *const GPBCodedInputStreamUnderlyingErrorKey; + +/** NSError domain used for @c GPBCodedInputStream errors. */ +extern NSString *const GPBCodedInputStreamErrorDomain; + +/** + * Error code for NSError with @c GPBCodedInputStreamErrorDomain. + **/ +typedef NS_ENUM(NSInteger, GPBCodedInputStreamErrorCode) { + /** The size does not fit in the remaining bytes to be read. */ + GPBCodedInputStreamErrorInvalidSize = -100, + /** Attempted to read beyond the subsection limit. */ + GPBCodedInputStreamErrorSubsectionLimitReached = -101, + /** The requested subsection limit is invalid. */ + GPBCodedInputStreamErrorInvalidSubsectionLimit = -102, + /** Invalid tag read. */ + GPBCodedInputStreamErrorInvalidTag = -103, + /** Invalid UTF-8 character in a string. */ + GPBCodedInputStreamErrorInvalidUTF8 = -104, + /** Invalid VarInt read. */ + GPBCodedInputStreamErrorInvalidVarInt = -105, + /** The maximum recursion depth of messages was exceeded. */ + GPBCodedInputStreamErrorRecursionDepthExceeded = -106, +}; + +CF_EXTERN_C_END + +/** + * Reads and decodes protocol message fields. + * + * The common uses of protocol buffers shouldn't need to use this class. + * @c GPBMessage's provide a @c +parseFromData:error: and + * @c +parseFromData:extensionRegistry:error: method that will decode a + * message for you. + * + * @note Subclassing of @c GPBCodedInputStream is NOT supported. + **/ +@interface GPBCodedInputStream : NSObject + +/** + * Creates a new stream wrapping some data. + * + * @param data The data to wrap inside the stream. + * + * @return A newly instanced GPBCodedInputStream. + **/ ++ (instancetype)streamWithData:(NSData *)data; + +/** + * Initializes a stream wrapping some data. + * + * @param data The data to wrap inside the stream. + * + * @return A newly initialized GPBCodedInputStream. + **/ +- (instancetype)initWithData:(NSData *)data; + +/** + * Attempts to read a field tag, returning zero if we have reached EOF. + * Protocol message parsers use this to read tags, since a protocol message + * may legally end wherever a tag occurs, and zero is not a valid tag number. + * + * @return The field tag, or zero if EOF was reached. + **/ +- (int32_t)readTag; + +/** + * @return A double read from the stream. + **/ +- (double)readDouble; +/** + * @return A float read from the stream. + **/ +- (float)readFloat; +/** + * @return A uint64 read from the stream. + **/ +- (uint64_t)readUInt64; +/** + * @return A uint32 read from the stream. + **/ +- (uint32_t)readUInt32; +/** + * @return An int64 read from the stream. + **/ +- (int64_t)readInt64; +/** + * @return An int32 read from the stream. + **/ +- (int32_t)readInt32; +/** + * @return A fixed64 read from the stream. + **/ +- (uint64_t)readFixed64; +/** + * @return A fixed32 read from the stream. + **/ +- (uint32_t)readFixed32; +/** + * @return An enum read from the stream. + **/ +- (int32_t)readEnum; +/** + * @return A sfixed32 read from the stream. + **/ +- (int32_t)readSFixed32; +/** + * @return A fixed64 read from the stream. + **/ +- (int64_t)readSFixed64; +/** + * @return A sint32 read from the stream. + **/ +- (int32_t)readSInt32; +/** + * @return A sint64 read from the stream. + **/ +- (int64_t)readSInt64; +/** + * @return A boolean read from the stream. + **/ +- (BOOL)readBool; +/** + * @return A string read from the stream. + **/ +- (NSString *)readString; +/** + * @return Data read from the stream. + **/ +- (NSData *)readBytes; + +/** + * Read an embedded message field value from the stream. + * + * @param message The message to set fields on as they are read. + * @param extensionRegistry An optional extension registry to use to lookup + * extensions for message. + **/ +- (void)readMessage:(GPBMessage *)message + extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry; + +/** + * Reads and discards a single field, given its tag value. + * + * @param tag The tag number of the field to skip. + * + * @return NO if the tag is an endgroup tag (in which case nothing is skipped), + * YES in all other cases. + **/ +- (BOOL)skipField:(int32_t)tag; + +/** + * Reads and discards an entire message. This will read either until EOF or + * until an endgroup tag, whichever comes first. + **/ +- (void)skipMessage; + +/** + * Check to see if the logical end of the stream has been reached. + * + * @note This can return NO when there is no more data, but the current parsing + * expected more data. + * + * @return YES if the logical end of the stream has been reached, NO otherwise. + **/ +- (BOOL)isAtEnd; + +/** + * @return The offset into the stream. + **/ +- (size_t)position; + +/** + * Moves the limit to the given byte offset starting at the current location. + * + * @exception GPBCodedInputStreamException If the requested bytes exceeed the + * current limit. + * + * @param byteLimit The number of bytes to move the limit, offset to the current + * location. + * + * @return The limit offset before moving the new limit. + */ +- (size_t)pushLimit:(size_t)byteLimit; + +/** + * Moves the limit back to the offset as it was before calling pushLimit:. + * + * @param oldLimit The number of bytes to move the current limit. Usually this + * is the value returned by the pushLimit: method. + */ +- (void)popLimit:(size_t)oldLimit; + +/** + * Verifies that the last call to -readTag returned the given tag value. This + * is used to verify that a nested group ended with the correct end tag. + * + * @exception NSParseErrorException If the value does not match the last tag. + * + * @param expected The tag that was expected. + **/ +- (void)checkLastTagWas:(int32_t)expected; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Pods/Protobuf/objectivec/GPBCodedInputStream.m b/Pods/Protobuf/objectivec/GPBCodedInputStream.m new file mode 100644 index 0000000..0759640 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBCodedInputStream.m @@ -0,0 +1,505 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import "GPBCodedInputStream_PackagePrivate.h" + +#import "GPBDictionary_PackagePrivate.h" +#import "GPBMessage_PackagePrivate.h" +#import "GPBUnknownFieldSet_PackagePrivate.h" +#import "GPBUtilities_PackagePrivate.h" +#import "GPBWireFormat.h" + +NSString *const GPBCodedInputStreamException = + GPBNSStringifySymbol(GPBCodedInputStreamException); + +NSString *const GPBCodedInputStreamUnderlyingErrorKey = + GPBNSStringifySymbol(GPBCodedInputStreamUnderlyingErrorKey); + +NSString *const GPBCodedInputStreamErrorDomain = + GPBNSStringifySymbol(GPBCodedInputStreamErrorDomain); + +// Matching: +// https://github.com/google/protobuf/blob/master/java/core/src/main/java/com/google/protobuf/CodedInputStream.java#L62 +// private static final int DEFAULT_RECURSION_LIMIT = 100; +// https://github.com/google/protobuf/blob/master/src/google/protobuf/io/coded_stream.cc#L86 +// int CodedInputStream::default_recursion_limit_ = 100; +static const NSUInteger kDefaultRecursionLimit = 100; + +static void RaiseException(NSInteger code, NSString *reason) { + NSDictionary *errorInfo = nil; + if ([reason length]) { + errorInfo = @{ GPBErrorReasonKey: reason }; + } + NSError *error = [NSError errorWithDomain:GPBCodedInputStreamErrorDomain + code:code + userInfo:errorInfo]; + + NSDictionary *exceptionInfo = + @{ GPBCodedInputStreamUnderlyingErrorKey: error }; + [[[NSException alloc] initWithName:GPBCodedInputStreamException + reason:reason + userInfo:exceptionInfo] raise]; +} + +static void CheckRecursionLimit(GPBCodedInputStreamState *state) { + if (state->recursionDepth >= kDefaultRecursionLimit) { + RaiseException(GPBCodedInputStreamErrorRecursionDepthExceeded, nil); + } +} + +static void CheckSize(GPBCodedInputStreamState *state, size_t size) { + size_t newSize = state->bufferPos + size; + if (newSize > state->bufferSize) { + RaiseException(GPBCodedInputStreamErrorInvalidSize, nil); + } + if (newSize > state->currentLimit) { + // Fast forward to end of currentLimit; + state->bufferPos = state->currentLimit; + RaiseException(GPBCodedInputStreamErrorSubsectionLimitReached, nil); + } +} + +static int8_t ReadRawByte(GPBCodedInputStreamState *state) { + CheckSize(state, sizeof(int8_t)); + return ((int8_t *)state->bytes)[state->bufferPos++]; +} + +static int32_t ReadRawLittleEndian32(GPBCodedInputStreamState *state) { + CheckSize(state, sizeof(int32_t)); + int32_t value = OSReadLittleInt32(state->bytes, state->bufferPos); + state->bufferPos += sizeof(int32_t); + return value; +} + +static int64_t ReadRawLittleEndian64(GPBCodedInputStreamState *state) { + CheckSize(state, sizeof(int64_t)); + int64_t value = OSReadLittleInt64(state->bytes, state->bufferPos); + state->bufferPos += sizeof(int64_t); + return value; +} + +static int64_t ReadRawVarint64(GPBCodedInputStreamState *state) { + int32_t shift = 0; + int64_t result = 0; + while (shift < 64) { + int8_t b = ReadRawByte(state); + result |= (int64_t)(b & 0x7F) << shift; + if ((b & 0x80) == 0) { + return result; + } + shift += 7; + } + RaiseException(GPBCodedInputStreamErrorInvalidVarInt, @"Invalid VarInt64"); + return 0; +} + +static int32_t ReadRawVarint32(GPBCodedInputStreamState *state) { + return (int32_t)ReadRawVarint64(state); +} + +static void SkipRawData(GPBCodedInputStreamState *state, size_t size) { + CheckSize(state, size); + state->bufferPos += size; +} + +double GPBCodedInputStreamReadDouble(GPBCodedInputStreamState *state) { + int64_t value = ReadRawLittleEndian64(state); + return GPBConvertInt64ToDouble(value); +} + +float GPBCodedInputStreamReadFloat(GPBCodedInputStreamState *state) { + int32_t value = ReadRawLittleEndian32(state); + return GPBConvertInt32ToFloat(value); +} + +uint64_t GPBCodedInputStreamReadUInt64(GPBCodedInputStreamState *state) { + uint64_t value = ReadRawVarint64(state); + return value; +} + +uint32_t GPBCodedInputStreamReadUInt32(GPBCodedInputStreamState *state) { + uint32_t value = ReadRawVarint32(state); + return value; +} + +int64_t GPBCodedInputStreamReadInt64(GPBCodedInputStreamState *state) { + int64_t value = ReadRawVarint64(state); + return value; +} + +int32_t GPBCodedInputStreamReadInt32(GPBCodedInputStreamState *state) { + int32_t value = ReadRawVarint32(state); + return value; +} + +uint64_t GPBCodedInputStreamReadFixed64(GPBCodedInputStreamState *state) { + uint64_t value = ReadRawLittleEndian64(state); + return value; +} + +uint32_t GPBCodedInputStreamReadFixed32(GPBCodedInputStreamState *state) { + uint32_t value = ReadRawLittleEndian32(state); + return value; +} + +int32_t GPBCodedInputStreamReadEnum(GPBCodedInputStreamState *state) { + int32_t value = ReadRawVarint32(state); + return value; +} + +int32_t GPBCodedInputStreamReadSFixed32(GPBCodedInputStreamState *state) { + int32_t value = ReadRawLittleEndian32(state); + return value; +} + +int64_t GPBCodedInputStreamReadSFixed64(GPBCodedInputStreamState *state) { + int64_t value = ReadRawLittleEndian64(state); + return value; +} + +int32_t GPBCodedInputStreamReadSInt32(GPBCodedInputStreamState *state) { + int32_t value = GPBDecodeZigZag32(ReadRawVarint32(state)); + return value; +} + +int64_t GPBCodedInputStreamReadSInt64(GPBCodedInputStreamState *state) { + int64_t value = GPBDecodeZigZag64(ReadRawVarint64(state)); + return value; +} + +BOOL GPBCodedInputStreamReadBool(GPBCodedInputStreamState *state) { + return ReadRawVarint32(state) != 0; +} + +int32_t GPBCodedInputStreamReadTag(GPBCodedInputStreamState *state) { + if (GPBCodedInputStreamIsAtEnd(state)) { + state->lastTag = 0; + return 0; + } + + state->lastTag = ReadRawVarint32(state); + // Tags have to include a valid wireformat. + if (!GPBWireFormatIsValidTag(state->lastTag)) { + RaiseException(GPBCodedInputStreamErrorInvalidTag, + @"Invalid wireformat in tag."); + } + // Zero is not a valid field number. + if (GPBWireFormatGetTagFieldNumber(state->lastTag) == 0) { + RaiseException(GPBCodedInputStreamErrorInvalidTag, + @"A zero field number on the wire is invalid."); + } + return state->lastTag; +} + +NSString *GPBCodedInputStreamReadRetainedString( + GPBCodedInputStreamState *state) { + int32_t size = ReadRawVarint32(state); + NSString *result; + if (size == 0) { + result = @""; + } else { + CheckSize(state, size); + result = [[NSString alloc] initWithBytes:&state->bytes[state->bufferPos] + length:size + encoding:NSUTF8StringEncoding]; + state->bufferPos += size; + if (!result) { +#ifdef DEBUG + // https://developers.google.com/protocol-buffers/docs/proto#scalar + NSLog(@"UTF-8 failure, is some field type 'string' when it should be " + @"'bytes'?"); +#endif + RaiseException(GPBCodedInputStreamErrorInvalidUTF8, nil); + } + } + return result; +} + +NSData *GPBCodedInputStreamReadRetainedBytes(GPBCodedInputStreamState *state) { + int32_t size = ReadRawVarint32(state); + if (size < 0) return nil; + CheckSize(state, size); + NSData *result = [[NSData alloc] initWithBytes:state->bytes + state->bufferPos + length:size]; + state->bufferPos += size; + return result; +} + +NSData *GPBCodedInputStreamReadRetainedBytesNoCopy( + GPBCodedInputStreamState *state) { + int32_t size = ReadRawVarint32(state); + if (size < 0) return nil; + CheckSize(state, size); + // Cast is safe because freeWhenDone is NO. + NSData *result = [[NSData alloc] + initWithBytesNoCopy:(void *)(state->bytes + state->bufferPos) + length:size + freeWhenDone:NO]; + state->bufferPos += size; + return result; +} + +size_t GPBCodedInputStreamPushLimit(GPBCodedInputStreamState *state, + size_t byteLimit) { + byteLimit += state->bufferPos; + size_t oldLimit = state->currentLimit; + if (byteLimit > oldLimit) { + RaiseException(GPBCodedInputStreamErrorInvalidSubsectionLimit, nil); + } + state->currentLimit = byteLimit; + return oldLimit; +} + +void GPBCodedInputStreamPopLimit(GPBCodedInputStreamState *state, + size_t oldLimit) { + state->currentLimit = oldLimit; +} + +size_t GPBCodedInputStreamBytesUntilLimit(GPBCodedInputStreamState *state) { + return state->currentLimit - state->bufferPos; +} + +BOOL GPBCodedInputStreamIsAtEnd(GPBCodedInputStreamState *state) { + return (state->bufferPos == state->bufferSize) || + (state->bufferPos == state->currentLimit); +} + +void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state, + int32_t value) { + if (state->lastTag != value) { + RaiseException(GPBCodedInputStreamErrorInvalidTag, @"Unexpected tag read"); + } +} + +@implementation GPBCodedInputStream + ++ (instancetype)streamWithData:(NSData *)data { + return [[[self alloc] initWithData:data] autorelease]; +} + +- (instancetype)initWithData:(NSData *)data { + if ((self = [super init])) { +#ifdef DEBUG + NSCAssert([self class] == [GPBCodedInputStream class], + @"Subclassing of GPBCodedInputStream is not allowed."); +#endif + buffer_ = [data retain]; + state_.bytes = (const uint8_t *)[data bytes]; + state_.bufferSize = [data length]; + state_.currentLimit = state_.bufferSize; + } + return self; +} + +- (void)dealloc { + [buffer_ release]; + [super dealloc]; +} + +// Direct access is use for speed, to avoid even internally declaring things +// read/write, etc. The warning is enabled in the project to ensure code calling +// protos can turn on -Wdirect-ivar-access without issues. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdirect-ivar-access" + +- (int32_t)readTag { + return GPBCodedInputStreamReadTag(&state_); +} + +- (void)checkLastTagWas:(int32_t)value { + GPBCodedInputStreamCheckLastTagWas(&state_, value); +} + +- (BOOL)skipField:(int32_t)tag { + NSAssert(GPBWireFormatIsValidTag(tag), @"Invalid tag"); + switch (GPBWireFormatGetTagWireType(tag)) { + case GPBWireFormatVarint: + GPBCodedInputStreamReadInt32(&state_); + return YES; + case GPBWireFormatFixed64: + SkipRawData(&state_, sizeof(int64_t)); + return YES; + case GPBWireFormatLengthDelimited: + SkipRawData(&state_, ReadRawVarint32(&state_)); + return YES; + case GPBWireFormatStartGroup: + [self skipMessage]; + GPBCodedInputStreamCheckLastTagWas( + &state_, GPBWireFormatMakeTag(GPBWireFormatGetTagFieldNumber(tag), + GPBWireFormatEndGroup)); + return YES; + case GPBWireFormatEndGroup: + return NO; + case GPBWireFormatFixed32: + SkipRawData(&state_, sizeof(int32_t)); + return YES; + } +} + +- (void)skipMessage { + while (YES) { + int32_t tag = GPBCodedInputStreamReadTag(&state_); + if (tag == 0 || ![self skipField:tag]) { + return; + } + } +} + +- (BOOL)isAtEnd { + return GPBCodedInputStreamIsAtEnd(&state_); +} + +- (size_t)position { + return state_.bufferPos; +} + +- (size_t)pushLimit:(size_t)byteLimit { + return GPBCodedInputStreamPushLimit(&state_, byteLimit); +} + +- (void)popLimit:(size_t)oldLimit { + GPBCodedInputStreamPopLimit(&state_, oldLimit); +} + +- (double)readDouble { + return GPBCodedInputStreamReadDouble(&state_); +} + +- (float)readFloat { + return GPBCodedInputStreamReadFloat(&state_); +} + +- (uint64_t)readUInt64 { + return GPBCodedInputStreamReadUInt64(&state_); +} + +- (int64_t)readInt64 { + return GPBCodedInputStreamReadInt64(&state_); +} + +- (int32_t)readInt32 { + return GPBCodedInputStreamReadInt32(&state_); +} + +- (uint64_t)readFixed64 { + return GPBCodedInputStreamReadFixed64(&state_); +} + +- (uint32_t)readFixed32 { + return GPBCodedInputStreamReadFixed32(&state_); +} + +- (BOOL)readBool { + return GPBCodedInputStreamReadBool(&state_); +} + +- (NSString *)readString { + return [GPBCodedInputStreamReadRetainedString(&state_) autorelease]; +} + +- (void)readGroup:(int32_t)fieldNumber + message:(GPBMessage *)message + extensionRegistry:(GPBExtensionRegistry *)extensionRegistry { + CheckRecursionLimit(&state_); + ++state_.recursionDepth; + [message mergeFromCodedInputStream:self extensionRegistry:extensionRegistry]; + GPBCodedInputStreamCheckLastTagWas( + &state_, GPBWireFormatMakeTag(fieldNumber, GPBWireFormatEndGroup)); + --state_.recursionDepth; +} + +- (void)readUnknownGroup:(int32_t)fieldNumber + message:(GPBUnknownFieldSet *)message { + CheckRecursionLimit(&state_); + ++state_.recursionDepth; + [message mergeFromCodedInputStream:self]; + GPBCodedInputStreamCheckLastTagWas( + &state_, GPBWireFormatMakeTag(fieldNumber, GPBWireFormatEndGroup)); + --state_.recursionDepth; +} + +- (void)readMessage:(GPBMessage *)message + extensionRegistry:(GPBExtensionRegistry *)extensionRegistry { + CheckRecursionLimit(&state_); + int32_t length = ReadRawVarint32(&state_); + size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length); + ++state_.recursionDepth; + [message mergeFromCodedInputStream:self extensionRegistry:extensionRegistry]; + GPBCodedInputStreamCheckLastTagWas(&state_, 0); + --state_.recursionDepth; + GPBCodedInputStreamPopLimit(&state_, oldLimit); +} + +- (void)readMapEntry:(id)mapDictionary + extensionRegistry:(GPBExtensionRegistry *)extensionRegistry + field:(GPBFieldDescriptor *)field + parentMessage:(GPBMessage *)parentMessage { + CheckRecursionLimit(&state_); + int32_t length = ReadRawVarint32(&state_); + size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length); + ++state_.recursionDepth; + GPBDictionaryReadEntry(mapDictionary, self, extensionRegistry, field, + parentMessage); + GPBCodedInputStreamCheckLastTagWas(&state_, 0); + --state_.recursionDepth; + GPBCodedInputStreamPopLimit(&state_, oldLimit); +} + +- (NSData *)readBytes { + return [GPBCodedInputStreamReadRetainedBytes(&state_) autorelease]; +} + +- (uint32_t)readUInt32 { + return GPBCodedInputStreamReadUInt32(&state_); +} + +- (int32_t)readEnum { + return GPBCodedInputStreamReadEnum(&state_); +} + +- (int32_t)readSFixed32 { + return GPBCodedInputStreamReadSFixed32(&state_); +} + +- (int64_t)readSFixed64 { + return GPBCodedInputStreamReadSFixed64(&state_); +} + +- (int32_t)readSInt32 { + return GPBCodedInputStreamReadSInt32(&state_); +} + +- (int64_t)readSInt64 { + return GPBCodedInputStreamReadSInt64(&state_); +} + +#pragma clang diagnostic pop + +@end diff --git a/Pods/Protobuf/objectivec/GPBCodedInputStream_PackagePrivate.h b/Pods/Protobuf/objectivec/GPBCodedInputStream_PackagePrivate.h new file mode 100644 index 0000000..90bd0c9 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBCodedInputStream_PackagePrivate.h @@ -0,0 +1,114 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// This header is private to the ProtobolBuffers library and must NOT be +// included by any sources outside this library. The contents of this file are +// subject to change at any time without notice. + +#import "GPBCodedInputStream.h" + +#import + +@class GPBUnknownFieldSet; +@class GPBFieldDescriptor; + +typedef struct GPBCodedInputStreamState { + const uint8_t *bytes; + size_t bufferSize; + size_t bufferPos; + + // For parsing subsections of an input stream you can put a hard limit on + // how much should be read. Normally the limit is the end of the stream, + // but you can adjust it to anywhere, and if you hit it you will be at the + // end of the stream, until you adjust the limit. + size_t currentLimit; + int32_t lastTag; + NSUInteger recursionDepth; +} GPBCodedInputStreamState; + +@interface GPBCodedInputStream () { + @package + struct GPBCodedInputStreamState state_; + NSData *buffer_; +} + +// Group support is deprecated, so we hide this interface from users, but +// support for older data. +- (void)readGroup:(int32_t)fieldNumber + message:(GPBMessage *)message + extensionRegistry:(GPBExtensionRegistry *)extensionRegistry; + +// Reads a group field value from the stream and merges it into the given +// UnknownFieldSet. +- (void)readUnknownGroup:(int32_t)fieldNumber + message:(GPBUnknownFieldSet *)message; + +// Reads a map entry. +- (void)readMapEntry:(id)mapDictionary + extensionRegistry:(GPBExtensionRegistry *)extensionRegistry + field:(GPBFieldDescriptor *)field + parentMessage:(GPBMessage *)parentMessage; +@end + +CF_EXTERN_C_BEGIN + +int32_t GPBCodedInputStreamReadTag(GPBCodedInputStreamState *state); + +double GPBCodedInputStreamReadDouble(GPBCodedInputStreamState *state); +float GPBCodedInputStreamReadFloat(GPBCodedInputStreamState *state); +uint64_t GPBCodedInputStreamReadUInt64(GPBCodedInputStreamState *state); +uint32_t GPBCodedInputStreamReadUInt32(GPBCodedInputStreamState *state); +int64_t GPBCodedInputStreamReadInt64(GPBCodedInputStreamState *state); +int32_t GPBCodedInputStreamReadInt32(GPBCodedInputStreamState *state); +uint64_t GPBCodedInputStreamReadFixed64(GPBCodedInputStreamState *state); +uint32_t GPBCodedInputStreamReadFixed32(GPBCodedInputStreamState *state); +int32_t GPBCodedInputStreamReadEnum(GPBCodedInputStreamState *state); +int32_t GPBCodedInputStreamReadSFixed32(GPBCodedInputStreamState *state); +int64_t GPBCodedInputStreamReadSFixed64(GPBCodedInputStreamState *state); +int32_t GPBCodedInputStreamReadSInt32(GPBCodedInputStreamState *state); +int64_t GPBCodedInputStreamReadSInt64(GPBCodedInputStreamState *state); +BOOL GPBCodedInputStreamReadBool(GPBCodedInputStreamState *state); +NSString *GPBCodedInputStreamReadRetainedString(GPBCodedInputStreamState *state) + __attribute((ns_returns_retained)); +NSData *GPBCodedInputStreamReadRetainedBytes(GPBCodedInputStreamState *state) + __attribute((ns_returns_retained)); +NSData *GPBCodedInputStreamReadRetainedBytesNoCopy( + GPBCodedInputStreamState *state) __attribute((ns_returns_retained)); + +size_t GPBCodedInputStreamPushLimit(GPBCodedInputStreamState *state, + size_t byteLimit); +void GPBCodedInputStreamPopLimit(GPBCodedInputStreamState *state, + size_t oldLimit); +size_t GPBCodedInputStreamBytesUntilLimit(GPBCodedInputStreamState *state); +BOOL GPBCodedInputStreamIsAtEnd(GPBCodedInputStreamState *state); +void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state, + int32_t value); + +CF_EXTERN_C_END diff --git a/Pods/Protobuf/objectivec/GPBCodedOutputStream.h b/Pods/Protobuf/objectivec/GPBCodedOutputStream.h new file mode 100644 index 0000000..23c404b --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBCodedOutputStream.h @@ -0,0 +1,748 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import + +#import "GPBRuntimeTypes.h" +#import "GPBWireFormat.h" + +@class GPBBoolArray; +@class GPBDoubleArray; +@class GPBEnumArray; +@class GPBFloatArray; +@class GPBMessage; +@class GPBInt32Array; +@class GPBInt64Array; +@class GPBUInt32Array; +@class GPBUInt64Array; +@class GPBUnknownFieldSet; + +NS_ASSUME_NONNULL_BEGIN + +/** + * @c GPBCodedOutputStream exception names. + **/ +extern NSString *const GPBCodedOutputStreamException_OutOfSpace; +extern NSString *const GPBCodedOutputStreamException_WriteFailed; + +/** + * Writes out protocol message fields. + * + * The common uses of protocol buffers shouldn't need to use this class. + * GPBMessage's provide a -data method that will serialize the message for you. + * + * @note Any -write* api can raise the GPBCodedOutputStreamException_* + * exceptions. + * + * @note Subclassing of GPBCodedOutputStream is NOT supported. + **/ +@interface GPBCodedOutputStream : NSObject + +/** + * Creates a stream to fill in the given data. Data must be sized to fit or + * an error will be raised when out of space. + * + * @param data The data where the stream will be written to. + * + * @return A newly instanced GPBCodedOutputStream. + **/ ++ (instancetype)streamWithData:(NSMutableData *)data; + +/** + * Creates a stream to write into the given NSOutputStream. + * + * @param output The output stream where the stream will be written to. + * + * @return A newly instanced GPBCodedOutputStream. + **/ ++ (instancetype)streamWithOutputStream:(NSOutputStream *)output; + +/** + * Initializes a stream to fill in the given data. Data must be sized to fit + * or an error will be raised when out of space. + * + * @param data The data where the stream will be written to. + * + * @return A newly initialized GPBCodedOutputStream. + **/ +- (instancetype)initWithData:(NSMutableData *)data; + +/** + * Initializes a stream to write into the given @c NSOutputStream. + * + * @param output The output stream where the stream will be written to. + * + * @return A newly initialized GPBCodedOutputStream. + **/ +- (instancetype)initWithOutputStream:(NSOutputStream *)output; + +/** + * Flush any buffered data out. + **/ +- (void)flush; + +/** + * Write the raw byte out. + * + * @param value The value to write out. + **/ +- (void)writeRawByte:(uint8_t)value; + +/** + * Write the tag for the given field number and wire format. + * + * @param fieldNumber The field number. + * @param format The wire format the data for the field will be in. + **/ +- (void)writeTag:(uint32_t)fieldNumber format:(GPBWireFormat)format; + +/** + * Write a 32bit value out in little endian format. + * + * @param value The value to write out. + **/ +- (void)writeRawLittleEndian32:(int32_t)value; +/** + * Write a 64bit value out in little endian format. + * + * @param value The value to write out. + **/ +- (void)writeRawLittleEndian64:(int64_t)value; + +/** + * Write a 32bit value out in varint format. + * + * @param value The value to write out. + **/ +- (void)writeRawVarint32:(int32_t)value; +/** + * Write a 64bit value out in varint format. + * + * @param value The value to write out. + **/ +- (void)writeRawVarint64:(int64_t)value; + +/** + * Write a size_t out as a 32bit varint value. + * + * @note This will truncate 64 bit values to 32. + * + * @param value The value to write out. + **/ +- (void)writeRawVarintSizeTAs32:(size_t)value; + +/** + * Writes the contents of an NSData out. + * + * @param data The data to write out. + **/ +- (void)writeRawData:(NSData *)data; +/** + * Writes out the given data. + * + * @param data The data blob to write out. + * @param offset The offset into the blob to start writing out. + * @param length The number of bytes from the blob to write out. + **/ +- (void)writeRawPtr:(const void *)data + offset:(size_t)offset + length:(size_t)length; + +//%PDDM-EXPAND _WRITE_DECLS() +// This block of code is generated, do not edit it directly. + +/** + * Write a double for the given field number. + * + * @param fieldNumber The field number assigned to the value. + * @param value The value to write out. + **/ +- (void)writeDouble:(int32_t)fieldNumber value:(double)value; +/** + * Write a packed array of double for the given field number. + * + * @param fieldNumber The field number assigned to the values. + * @param values The values to write out. + * @param tag The tag assigned to the values. + **/ +- (void)writeDoubleArray:(int32_t)fieldNumber + values:(GPBDoubleArray *)values + tag:(uint32_t)tag; +/** + * Write a double without any tag. + * + * @param value The value to write out. + **/ +- (void)writeDoubleNoTag:(double)value; + +/** + * Write a float for the given field number. + * + * @param fieldNumber The field number assigned to the value. + * @param value The value to write out. + **/ +- (void)writeFloat:(int32_t)fieldNumber value:(float)value; +/** + * Write a packed array of float for the given field number. + * + * @param fieldNumber The field number assigned to the values. + * @param values The values to write out. + * @param tag The tag assigned to the values. + **/ +- (void)writeFloatArray:(int32_t)fieldNumber + values:(GPBFloatArray *)values + tag:(uint32_t)tag; +/** + * Write a float without any tag. + * + * @param value The value to write out. + **/ +- (void)writeFloatNoTag:(float)value; + +/** + * Write a uint64_t for the given field number. + * + * @param fieldNumber The field number assigned to the value. + * @param value The value to write out. + **/ +- (void)writeUInt64:(int32_t)fieldNumber value:(uint64_t)value; +/** + * Write a packed array of uint64_t for the given field number. + * + * @param fieldNumber The field number assigned to the values. + * @param values The values to write out. + * @param tag The tag assigned to the values. + **/ +- (void)writeUInt64Array:(int32_t)fieldNumber + values:(GPBUInt64Array *)values + tag:(uint32_t)tag; +/** + * Write a uint64_t without any tag. + * + * @param value The value to write out. + **/ +- (void)writeUInt64NoTag:(uint64_t)value; + +/** + * Write a int64_t for the given field number. + * + * @param fieldNumber The field number assigned to the value. + * @param value The value to write out. + **/ +- (void)writeInt64:(int32_t)fieldNumber value:(int64_t)value; +/** + * Write a packed array of int64_t for the given field number. + * + * @param fieldNumber The field number assigned to the values. + * @param values The values to write out. + * @param tag The tag assigned to the values. + **/ +- (void)writeInt64Array:(int32_t)fieldNumber + values:(GPBInt64Array *)values + tag:(uint32_t)tag; +/** + * Write a int64_t without any tag. + * + * @param value The value to write out. + **/ +- (void)writeInt64NoTag:(int64_t)value; + +/** + * Write a int32_t for the given field number. + * + * @param fieldNumber The field number assigned to the value. + * @param value The value to write out. + **/ +- (void)writeInt32:(int32_t)fieldNumber value:(int32_t)value; +/** + * Write a packed array of int32_t for the given field number. + * + * @param fieldNumber The field number assigned to the values. + * @param values The values to write out. + * @param tag The tag assigned to the values. + **/ +- (void)writeInt32Array:(int32_t)fieldNumber + values:(GPBInt32Array *)values + tag:(uint32_t)tag; +/** + * Write a int32_t without any tag. + * + * @param value The value to write out. + **/ +- (void)writeInt32NoTag:(int32_t)value; + +/** + * Write a uint32_t for the given field number. + * + * @param fieldNumber The field number assigned to the value. + * @param value The value to write out. + **/ +- (void)writeUInt32:(int32_t)fieldNumber value:(uint32_t)value; +/** + * Write a packed array of uint32_t for the given field number. + * + * @param fieldNumber The field number assigned to the values. + * @param values The values to write out. + * @param tag The tag assigned to the values. + **/ +- (void)writeUInt32Array:(int32_t)fieldNumber + values:(GPBUInt32Array *)values + tag:(uint32_t)tag; +/** + * Write a uint32_t without any tag. + * + * @param value The value to write out. + **/ +- (void)writeUInt32NoTag:(uint32_t)value; + +/** + * Write a uint64_t for the given field number. + * + * @param fieldNumber The field number assigned to the value. + * @param value The value to write out. + **/ +- (void)writeFixed64:(int32_t)fieldNumber value:(uint64_t)value; +/** + * Write a packed array of uint64_t for the given field number. + * + * @param fieldNumber The field number assigned to the values. + * @param values The values to write out. + * @param tag The tag assigned to the values. + **/ +- (void)writeFixed64Array:(int32_t)fieldNumber + values:(GPBUInt64Array *)values + tag:(uint32_t)tag; +/** + * Write a uint64_t without any tag. + * + * @param value The value to write out. + **/ +- (void)writeFixed64NoTag:(uint64_t)value; + +/** + * Write a uint32_t for the given field number. + * + * @param fieldNumber The field number assigned to the value. + * @param value The value to write out. + **/ +- (void)writeFixed32:(int32_t)fieldNumber value:(uint32_t)value; +/** + * Write a packed array of uint32_t for the given field number. + * + * @param fieldNumber The field number assigned to the values. + * @param values The values to write out. + * @param tag The tag assigned to the values. + **/ +- (void)writeFixed32Array:(int32_t)fieldNumber + values:(GPBUInt32Array *)values + tag:(uint32_t)tag; +/** + * Write a uint32_t without any tag. + * + * @param value The value to write out. + **/ +- (void)writeFixed32NoTag:(uint32_t)value; + +/** + * Write a int32_t for the given field number. + * + * @param fieldNumber The field number assigned to the value. + * @param value The value to write out. + **/ +- (void)writeSInt32:(int32_t)fieldNumber value:(int32_t)value; +/** + * Write a packed array of int32_t for the given field number. + * + * @param fieldNumber The field number assigned to the values. + * @param values The values to write out. + * @param tag The tag assigned to the values. + **/ +- (void)writeSInt32Array:(int32_t)fieldNumber + values:(GPBInt32Array *)values + tag:(uint32_t)tag; +/** + * Write a int32_t without any tag. + * + * @param value The value to write out. + **/ +- (void)writeSInt32NoTag:(int32_t)value; + +/** + * Write a int64_t for the given field number. + * + * @param fieldNumber The field number assigned to the value. + * @param value The value to write out. + **/ +- (void)writeSInt64:(int32_t)fieldNumber value:(int64_t)value; +/** + * Write a packed array of int64_t for the given field number. + * + * @param fieldNumber The field number assigned to the values. + * @param values The values to write out. + * @param tag The tag assigned to the values. + **/ +- (void)writeSInt64Array:(int32_t)fieldNumber + values:(GPBInt64Array *)values + tag:(uint32_t)tag; +/** + * Write a int64_t without any tag. + * + * @param value The value to write out. + **/ +- (void)writeSInt64NoTag:(int64_t)value; + +/** + * Write a int64_t for the given field number. + * + * @param fieldNumber The field number assigned to the value. + * @param value The value to write out. + **/ +- (void)writeSFixed64:(int32_t)fieldNumber value:(int64_t)value; +/** + * Write a packed array of int64_t for the given field number. + * + * @param fieldNumber The field number assigned to the values. + * @param values The values to write out. + * @param tag The tag assigned to the values. + **/ +- (void)writeSFixed64Array:(int32_t)fieldNumber + values:(GPBInt64Array *)values + tag:(uint32_t)tag; +/** + * Write a int64_t without any tag. + * + * @param value The value to write out. + **/ +- (void)writeSFixed64NoTag:(int64_t)value; + +/** + * Write a int32_t for the given field number. + * + * @param fieldNumber The field number assigned to the value. + * @param value The value to write out. + **/ +- (void)writeSFixed32:(int32_t)fieldNumber value:(int32_t)value; +/** + * Write a packed array of int32_t for the given field number. + * + * @param fieldNumber The field number assigned to the values. + * @param values The values to write out. + * @param tag The tag assigned to the values. + **/ +- (void)writeSFixed32Array:(int32_t)fieldNumber + values:(GPBInt32Array *)values + tag:(uint32_t)tag; +/** + * Write a int32_t without any tag. + * + * @param value The value to write out. + **/ +- (void)writeSFixed32NoTag:(int32_t)value; + +/** + * Write a BOOL for the given field number. + * + * @param fieldNumber The field number assigned to the value. + * @param value The value to write out. + **/ +- (void)writeBool:(int32_t)fieldNumber value:(BOOL)value; +/** + * Write a packed array of BOOL for the given field number. + * + * @param fieldNumber The field number assigned to the values. + * @param values The values to write out. + * @param tag The tag assigned to the values. + **/ +- (void)writeBoolArray:(int32_t)fieldNumber + values:(GPBBoolArray *)values + tag:(uint32_t)tag; +/** + * Write a BOOL without any tag. + * + * @param value The value to write out. + **/ +- (void)writeBoolNoTag:(BOOL)value; + +/** + * Write a int32_t for the given field number. + * + * @param fieldNumber The field number assigned to the value. + * @param value The value to write out. + **/ +- (void)writeEnum:(int32_t)fieldNumber value:(int32_t)value; +/** + * Write a packed array of int32_t for the given field number. + * + * @param fieldNumber The field number assigned to the values. + * @param values The values to write out. + * @param tag The tag assigned to the values. + **/ +- (void)writeEnumArray:(int32_t)fieldNumber + values:(GPBEnumArray *)values + tag:(uint32_t)tag; +/** + * Write a int32_t without any tag. + * + * @param value The value to write out. + **/ +- (void)writeEnumNoTag:(int32_t)value; + +/** + * Write a NSString for the given field number. + * + * @param fieldNumber The field number assigned to the value. + * @param value The value to write out. + **/ +- (void)writeString:(int32_t)fieldNumber value:(NSString *)value; +/** + * Write an array of NSString for the given field number. + * + * @param fieldNumber The field number assigned to the values. + * @param values The values to write out. + **/ +- (void)writeStringArray:(int32_t)fieldNumber values:(NSArray *)values; +/** + * Write a NSString without any tag. + * + * @param value The value to write out. + **/ +- (void)writeStringNoTag:(NSString *)value; + +/** + * Write a GPBMessage for the given field number. + * + * @param fieldNumber The field number assigned to the value. + * @param value The value to write out. + **/ +- (void)writeMessage:(int32_t)fieldNumber value:(GPBMessage *)value; +/** + * Write an array of GPBMessage for the given field number. + * + * @param fieldNumber The field number assigned to the values. + * @param values The values to write out. + **/ +- (void)writeMessageArray:(int32_t)fieldNumber values:(NSArray *)values; +/** + * Write a GPBMessage without any tag. + * + * @param value The value to write out. + **/ +- (void)writeMessageNoTag:(GPBMessage *)value; + +/** + * Write a NSData for the given field number. + * + * @param fieldNumber The field number assigned to the value. + * @param value The value to write out. + **/ +- (void)writeBytes:(int32_t)fieldNumber value:(NSData *)value; +/** + * Write an array of NSData for the given field number. + * + * @param fieldNumber The field number assigned to the values. + * @param values The values to write out. + **/ +- (void)writeBytesArray:(int32_t)fieldNumber values:(NSArray *)values; +/** + * Write a NSData without any tag. + * + * @param value The value to write out. + **/ +- (void)writeBytesNoTag:(NSData *)value; + +/** + * Write a GPBMessage for the given field number. + * + * @param fieldNumber The field number assigned to the value. + * @param value The value to write out. + **/ +- (void)writeGroup:(int32_t)fieldNumber + value:(GPBMessage *)value; +/** + * Write an array of GPBMessage for the given field number. + * + * @param fieldNumber The field number assigned to the values. + * @param values The values to write out. + **/ +- (void)writeGroupArray:(int32_t)fieldNumber values:(NSArray *)values; +/** + * Write a GPBMessage without any tag (but does write the endGroup tag). + * + * @param fieldNumber The field number assigned to the value. + * @param value The value to write out. + **/ +- (void)writeGroupNoTag:(int32_t)fieldNumber + value:(GPBMessage *)value; + +/** + * Write a GPBUnknownFieldSet for the given field number. + * + * @param fieldNumber The field number assigned to the value. + * @param value The value to write out. + **/ +- (void)writeUnknownGroup:(int32_t)fieldNumber + value:(GPBUnknownFieldSet *)value; +/** + * Write an array of GPBUnknownFieldSet for the given field number. + * + * @param fieldNumber The field number assigned to the values. + * @param values The values to write out. + **/ +- (void)writeUnknownGroupArray:(int32_t)fieldNumber values:(NSArray *)values; +/** + * Write a GPBUnknownFieldSet without any tag (but does write the endGroup tag). + * + * @param fieldNumber The field number assigned to the value. + * @param value The value to write out. + **/ +- (void)writeUnknownGroupNoTag:(int32_t)fieldNumber + value:(GPBUnknownFieldSet *)value; + +//%PDDM-EXPAND-END _WRITE_DECLS() + +/** +Write a MessageSet extension field to the stream. For historical reasons, +the wire format differs from normal fields. + +@param fieldNumber The extension field number to write out. +@param value The message from where to get the extension. +*/ +- (void)writeMessageSetExtension:(int32_t)fieldNumber value:(GPBMessage *)value; + +/** +Write an unparsed MessageSet extension field to the stream. For historical +reasons, the wire format differs from normal fields. + +@param fieldNumber The extension field number to write out. +@param value The raw message from where to get the extension. +*/ +- (void)writeRawMessageSetExtension:(int32_t)fieldNumber value:(NSData *)value; + +@end + +NS_ASSUME_NONNULL_END + +// Write methods for types that can be in packed arrays. +//%PDDM-DEFINE _WRITE_PACKABLE_DECLS(NAME, ARRAY_TYPE, TYPE) +//%/** +//% * Write a TYPE for the given field number. +//% * +//% * @param fieldNumber The field number assigned to the value. +//% * @param value The value to write out. +//% **/ +//%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE)value; +//%/** +//% * Write a packed array of TYPE for the given field number. +//% * +//% * @param fieldNumber The field number assigned to the values. +//% * @param values The values to write out. +//% * @param tag The tag assigned to the values. +//% **/ +//%- (void)write##NAME##Array:(int32_t)fieldNumber +//% NAME$S values:(GPB##ARRAY_TYPE##Array *)values +//% NAME$S tag:(uint32_t)tag; +//%/** +//% * Write a TYPE without any tag. +//% * +//% * @param value The value to write out. +//% **/ +//%- (void)write##NAME##NoTag:(TYPE)value; +//% +// Write methods for types that aren't in packed arrays. +//%PDDM-DEFINE _WRITE_UNPACKABLE_DECLS(NAME, TYPE) +//%/** +//% * Write a TYPE for the given field number. +//% * +//% * @param fieldNumber The field number assigned to the value. +//% * @param value The value to write out. +//% **/ +//%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE *)value; +//%/** +//% * Write an array of TYPE for the given field number. +//% * +//% * @param fieldNumber The field number assigned to the values. +//% * @param values The values to write out. +//% **/ +//%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray<##TYPE##*> *)values; +//%/** +//% * Write a TYPE without any tag. +//% * +//% * @param value The value to write out. +//% **/ +//%- (void)write##NAME##NoTag:(TYPE *)value; +//% +// Special write methods for Groups. +//%PDDM-DEFINE _WRITE_GROUP_DECLS(NAME, TYPE) +//%/** +//% * Write a TYPE for the given field number. +//% * +//% * @param fieldNumber The field number assigned to the value. +//% * @param value The value to write out. +//% **/ +//%- (void)write##NAME:(int32_t)fieldNumber +//% NAME$S value:(TYPE *)value; +//%/** +//% * Write an array of TYPE for the given field number. +//% * +//% * @param fieldNumber The field number assigned to the values. +//% * @param values The values to write out. +//% **/ +//%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray<##TYPE##*> *)values; +//%/** +//% * Write a TYPE without any tag (but does write the endGroup tag). +//% * +//% * @param fieldNumber The field number assigned to the value. +//% * @param value The value to write out. +//% **/ +//%- (void)write##NAME##NoTag:(int32_t)fieldNumber +//% NAME$S value:(TYPE *)value; +//% + +// One macro to hide it all up above. +//%PDDM-DEFINE _WRITE_DECLS() +//%_WRITE_PACKABLE_DECLS(Double, Double, double) +//%_WRITE_PACKABLE_DECLS(Float, Float, float) +//%_WRITE_PACKABLE_DECLS(UInt64, UInt64, uint64_t) +//%_WRITE_PACKABLE_DECLS(Int64, Int64, int64_t) +//%_WRITE_PACKABLE_DECLS(Int32, Int32, int32_t) +//%_WRITE_PACKABLE_DECLS(UInt32, UInt32, uint32_t) +//%_WRITE_PACKABLE_DECLS(Fixed64, UInt64, uint64_t) +//%_WRITE_PACKABLE_DECLS(Fixed32, UInt32, uint32_t) +//%_WRITE_PACKABLE_DECLS(SInt32, Int32, int32_t) +//%_WRITE_PACKABLE_DECLS(SInt64, Int64, int64_t) +//%_WRITE_PACKABLE_DECLS(SFixed64, Int64, int64_t) +//%_WRITE_PACKABLE_DECLS(SFixed32, Int32, int32_t) +//%_WRITE_PACKABLE_DECLS(Bool, Bool, BOOL) +//%_WRITE_PACKABLE_DECLS(Enum, Enum, int32_t) +//%_WRITE_UNPACKABLE_DECLS(String, NSString) +//%_WRITE_UNPACKABLE_DECLS(Message, GPBMessage) +//%_WRITE_UNPACKABLE_DECLS(Bytes, NSData) +//%_WRITE_GROUP_DECLS(Group, GPBMessage) +//%_WRITE_GROUP_DECLS(UnknownGroup, GPBUnknownFieldSet) diff --git a/Pods/Protobuf/objectivec/GPBCodedOutputStream.m b/Pods/Protobuf/objectivec/GPBCodedOutputStream.m new file mode 100644 index 0000000..c299040 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBCodedOutputStream.m @@ -0,0 +1,1207 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import "GPBCodedOutputStream_PackagePrivate.h" + +#import + +#import "GPBArray.h" +#import "GPBUnknownFieldSet_PackagePrivate.h" +#import "GPBUtilities_PackagePrivate.h" + +// These values are the existing values so as not to break any code that might +// have already been inspecting them when they weren't documented/exposed. +NSString *const GPBCodedOutputStreamException_OutOfSpace = @"OutOfSpace"; +NSString *const GPBCodedOutputStreamException_WriteFailed = @"WriteFailed"; + +// Structure for containing state of a GPBCodedInputStream. Brought out into +// a struct so that we can inline several common functions instead of dealing +// with overhead of ObjC dispatch. +typedef struct GPBOutputBufferState { + uint8_t *bytes; + size_t size; + size_t position; + NSOutputStream *output; +} GPBOutputBufferState; + +@implementation GPBCodedOutputStream { + GPBOutputBufferState state_; + NSMutableData *buffer_; +} + +static const int32_t LITTLE_ENDIAN_32_SIZE = sizeof(uint32_t); +static const int32_t LITTLE_ENDIAN_64_SIZE = sizeof(uint64_t); + +// Internal helper that writes the current buffer to the output. The +// buffer position is reset to its initial value when this returns. +static void GPBRefreshBuffer(GPBOutputBufferState *state) { + if (state->output == nil) { + // We're writing to a single buffer. + [NSException raise:GPBCodedOutputStreamException_OutOfSpace format:@""]; + } + if (state->position != 0) { + NSInteger written = + [state->output write:state->bytes maxLength:state->position]; + if (written != (NSInteger)state->position) { + [NSException raise:GPBCodedOutputStreamException_WriteFailed format:@""]; + } + state->position = 0; + } +} + +static void GPBWriteRawByte(GPBOutputBufferState *state, uint8_t value) { + if (state->position == state->size) { + GPBRefreshBuffer(state); + } + state->bytes[state->position++] = value; +} + +static void GPBWriteRawVarint32(GPBOutputBufferState *state, int32_t value) { + while (YES) { + if ((value & ~0x7F) == 0) { + uint8_t val = (uint8_t)value; + GPBWriteRawByte(state, val); + return; + } else { + GPBWriteRawByte(state, (value & 0x7F) | 0x80); + value = GPBLogicalRightShift32(value, 7); + } + } +} + +static void GPBWriteRawVarint64(GPBOutputBufferState *state, int64_t value) { + while (YES) { + if ((value & ~0x7FL) == 0) { + uint8_t val = (uint8_t)value; + GPBWriteRawByte(state, val); + return; + } else { + GPBWriteRawByte(state, ((int32_t)value & 0x7F) | 0x80); + value = GPBLogicalRightShift64(value, 7); + } + } +} + +static void GPBWriteInt32NoTag(GPBOutputBufferState *state, int32_t value) { + if (value >= 0) { + GPBWriteRawVarint32(state, value); + } else { + // Must sign-extend + GPBWriteRawVarint64(state, value); + } +} + +static void GPBWriteUInt32(GPBOutputBufferState *state, int32_t fieldNumber, + uint32_t value) { + GPBWriteTagWithFormat(state, fieldNumber, GPBWireFormatVarint); + GPBWriteRawVarint32(state, value); +} + +static void GPBWriteTagWithFormat(GPBOutputBufferState *state, + uint32_t fieldNumber, GPBWireFormat format) { + GPBWriteRawVarint32(state, GPBWireFormatMakeTag(fieldNumber, format)); +} + +static void GPBWriteRawLittleEndian32(GPBOutputBufferState *state, + int32_t value) { + GPBWriteRawByte(state, (value)&0xFF); + GPBWriteRawByte(state, (value >> 8) & 0xFF); + GPBWriteRawByte(state, (value >> 16) & 0xFF); + GPBWriteRawByte(state, (value >> 24) & 0xFF); +} + +static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state, + int64_t value) { + GPBWriteRawByte(state, (int32_t)(value)&0xFF); + GPBWriteRawByte(state, (int32_t)(value >> 8) & 0xFF); + GPBWriteRawByte(state, (int32_t)(value >> 16) & 0xFF); + GPBWriteRawByte(state, (int32_t)(value >> 24) & 0xFF); + GPBWriteRawByte(state, (int32_t)(value >> 32) & 0xFF); + GPBWriteRawByte(state, (int32_t)(value >> 40) & 0xFF); + GPBWriteRawByte(state, (int32_t)(value >> 48) & 0xFF); + GPBWriteRawByte(state, (int32_t)(value >> 56) & 0xFF); +} + +- (void)dealloc { + [self flush]; + [state_.output close]; + [state_.output release]; + [buffer_ release]; + + [super dealloc]; +} + +- (instancetype)initWithOutputStream:(NSOutputStream *)output { + NSMutableData *data = [NSMutableData dataWithLength:PAGE_SIZE]; + return [self initWithOutputStream:output data:data]; +} + +- (instancetype)initWithData:(NSMutableData *)data { + return [self initWithOutputStream:nil data:data]; +} + +// This initializer isn't exposed, but it is the designated initializer. +// Setting OutputStream and NSData is to control the buffering behavior/size +// of the work, but that is more obvious via the bufferSize: version. +- (instancetype)initWithOutputStream:(NSOutputStream *)output + data:(NSMutableData *)data { + if ((self = [super init])) { + buffer_ = [data retain]; + [output open]; + state_.bytes = [data mutableBytes]; + state_.size = [data length]; + state_.output = [output retain]; + } + return self; +} + ++ (instancetype)streamWithOutputStream:(NSOutputStream *)output { + NSMutableData *data = [NSMutableData dataWithLength:PAGE_SIZE]; + return [[[self alloc] initWithOutputStream:output + data:data] autorelease]; +} + ++ (instancetype)streamWithData:(NSMutableData *)data { + return [[[self alloc] initWithData:data] autorelease]; +} + +// Direct access is use for speed, to avoid even internally declaring things +// read/write, etc. The warning is enabled in the project to ensure code calling +// protos can turn on -Wdirect-ivar-access without issues. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdirect-ivar-access" + +- (void)writeDoubleNoTag:(double)value { + GPBWriteRawLittleEndian64(&state_, GPBConvertDoubleToInt64(value)); +} + +- (void)writeDouble:(int32_t)fieldNumber value:(double)value { + GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatFixed64); + GPBWriteRawLittleEndian64(&state_, GPBConvertDoubleToInt64(value)); +} + +- (void)writeFloatNoTag:(float)value { + GPBWriteRawLittleEndian32(&state_, GPBConvertFloatToInt32(value)); +} + +- (void)writeFloat:(int32_t)fieldNumber value:(float)value { + GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatFixed32); + GPBWriteRawLittleEndian32(&state_, GPBConvertFloatToInt32(value)); +} + +- (void)writeUInt64NoTag:(uint64_t)value { + GPBWriteRawVarint64(&state_, value); +} + +- (void)writeUInt64:(int32_t)fieldNumber value:(uint64_t)value { + GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatVarint); + GPBWriteRawVarint64(&state_, value); +} + +- (void)writeInt64NoTag:(int64_t)value { + GPBWriteRawVarint64(&state_, value); +} + +- (void)writeInt64:(int32_t)fieldNumber value:(int64_t)value { + GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatVarint); + GPBWriteRawVarint64(&state_, value); +} + +- (void)writeInt32NoTag:(int32_t)value { + GPBWriteInt32NoTag(&state_, value); +} + +- (void)writeInt32:(int32_t)fieldNumber value:(int32_t)value { + GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatVarint); + GPBWriteInt32NoTag(&state_, value); +} + +- (void)writeFixed64NoTag:(uint64_t)value { + GPBWriteRawLittleEndian64(&state_, value); +} + +- (void)writeFixed64:(int32_t)fieldNumber value:(uint64_t)value { + GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatFixed64); + GPBWriteRawLittleEndian64(&state_, value); +} + +- (void)writeFixed32NoTag:(uint32_t)value { + GPBWriteRawLittleEndian32(&state_, value); +} + +- (void)writeFixed32:(int32_t)fieldNumber value:(uint32_t)value { + GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatFixed32); + GPBWriteRawLittleEndian32(&state_, value); +} + +- (void)writeBoolNoTag:(BOOL)value { + GPBWriteRawByte(&state_, (value ? 1 : 0)); +} + +- (void)writeBool:(int32_t)fieldNumber value:(BOOL)value { + GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatVarint); + GPBWriteRawByte(&state_, (value ? 1 : 0)); +} + +- (void)writeStringNoTag:(const NSString *)value { + size_t length = [value lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; + GPBWriteRawVarint32(&state_, (int32_t)length); + if (length == 0) { + return; + } + + const char *quickString = + CFStringGetCStringPtr((CFStringRef)value, kCFStringEncodingUTF8); + + // Fast path: Most strings are short, if the buffer already has space, + // add to it directly. + NSUInteger bufferBytesLeft = state_.size - state_.position; + if (bufferBytesLeft >= length) { + NSUInteger usedBufferLength = 0; + BOOL result; + if (quickString != NULL) { + memcpy(state_.bytes + state_.position, quickString, length); + usedBufferLength = length; + result = YES; + } else { + result = [value getBytes:state_.bytes + state_.position + maxLength:bufferBytesLeft + usedLength:&usedBufferLength + encoding:NSUTF8StringEncoding + options:(NSStringEncodingConversionOptions)0 + range:NSMakeRange(0, [value length]) + remainingRange:NULL]; + } + if (result) { + NSAssert2((usedBufferLength == length), + @"Our UTF8 calc was wrong? %tu vs %zd", usedBufferLength, + length); + state_.position += usedBufferLength; + return; + } + } else if (quickString != NULL) { + [self writeRawPtr:quickString offset:0 length:length]; + } else { + // Slow path: just get it as data and write it out. + NSData *utf8Data = [value dataUsingEncoding:NSUTF8StringEncoding]; + NSAssert2(([utf8Data length] == length), + @"Strings UTF8 length was wrong? %tu vs %zd", [utf8Data length], + length); + [self writeRawData:utf8Data]; + } +} + +- (void)writeString:(int32_t)fieldNumber value:(NSString *)value { + GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatLengthDelimited); + [self writeStringNoTag:value]; +} + +- (void)writeGroupNoTag:(int32_t)fieldNumber value:(GPBMessage *)value { + [value writeToCodedOutputStream:self]; + GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatEndGroup); +} + +- (void)writeGroup:(int32_t)fieldNumber value:(GPBMessage *)value { + GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatStartGroup); + [self writeGroupNoTag:fieldNumber value:value]; +} + +- (void)writeUnknownGroupNoTag:(int32_t)fieldNumber + value:(const GPBUnknownFieldSet *)value { + [value writeToCodedOutputStream:self]; + GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatEndGroup); +} + +- (void)writeUnknownGroup:(int32_t)fieldNumber + value:(GPBUnknownFieldSet *)value { + GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatStartGroup); + [self writeUnknownGroupNoTag:fieldNumber value:value]; +} + +- (void)writeMessageNoTag:(GPBMessage *)value { + GPBWriteRawVarint32(&state_, (int32_t)[value serializedSize]); + [value writeToCodedOutputStream:self]; +} + +- (void)writeMessage:(int32_t)fieldNumber value:(GPBMessage *)value { + GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatLengthDelimited); + [self writeMessageNoTag:value]; +} + +- (void)writeBytesNoTag:(NSData *)value { + GPBWriteRawVarint32(&state_, (int32_t)[value length]); + [self writeRawData:value]; +} + +- (void)writeBytes:(int32_t)fieldNumber value:(NSData *)value { + GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatLengthDelimited); + [self writeBytesNoTag:value]; +} + +- (void)writeUInt32NoTag:(uint32_t)value { + GPBWriteRawVarint32(&state_, value); +} + +- (void)writeUInt32:(int32_t)fieldNumber value:(uint32_t)value { + GPBWriteUInt32(&state_, fieldNumber, value); +} + +- (void)writeEnumNoTag:(int32_t)value { + GPBWriteRawVarint32(&state_, value); +} + +- (void)writeEnum:(int32_t)fieldNumber value:(int32_t)value { + GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatVarint); + GPBWriteRawVarint32(&state_, value); +} + +- (void)writeSFixed32NoTag:(int32_t)value { + GPBWriteRawLittleEndian32(&state_, value); +} + +- (void)writeSFixed32:(int32_t)fieldNumber value:(int32_t)value { + GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatFixed32); + GPBWriteRawLittleEndian32(&state_, value); +} + +- (void)writeSFixed64NoTag:(int64_t)value { + GPBWriteRawLittleEndian64(&state_, value); +} + +- (void)writeSFixed64:(int32_t)fieldNumber value:(int64_t)value { + GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatFixed64); + GPBWriteRawLittleEndian64(&state_, value); +} + +- (void)writeSInt32NoTag:(int32_t)value { + GPBWriteRawVarint32(&state_, GPBEncodeZigZag32(value)); +} + +- (void)writeSInt32:(int32_t)fieldNumber value:(int32_t)value { + GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatVarint); + GPBWriteRawVarint32(&state_, GPBEncodeZigZag32(value)); +} + +- (void)writeSInt64NoTag:(int64_t)value { + GPBWriteRawVarint64(&state_, GPBEncodeZigZag64(value)); +} + +- (void)writeSInt64:(int32_t)fieldNumber value:(int64_t)value { + GPBWriteTagWithFormat(&state_, fieldNumber, GPBWireFormatVarint); + GPBWriteRawVarint64(&state_, GPBEncodeZigZag64(value)); +} + +//%PDDM-DEFINE WRITE_PACKABLE_DEFNS(NAME, ARRAY_TYPE, TYPE, ACCESSOR_NAME) +//%- (void)write##NAME##Array:(int32_t)fieldNumber +//% NAME$S values:(GPB##ARRAY_TYPE##Array *)values +//% NAME$S tag:(uint32_t)tag { +//% if (tag != 0) { +//% if (values.count == 0) return; +//% __block size_t dataSize = 0; +//% [values enumerate##ACCESSOR_NAME##ValuesWithBlock:^(TYPE value, NSUInteger idx, BOOL *stop) { +//%#pragma unused(idx, stop) +//% dataSize += GPBCompute##NAME##SizeNoTag(value); +//% }]; +//% GPBWriteRawVarint32(&state_, tag); +//% GPBWriteRawVarint32(&state_, (int32_t)dataSize); +//% [values enumerate##ACCESSOR_NAME##ValuesWithBlock:^(TYPE value, NSUInteger idx, BOOL *stop) { +//%#pragma unused(idx, stop) +//% [self write##NAME##NoTag:value]; +//% }]; +//% } else { +//% [values enumerate##ACCESSOR_NAME##ValuesWithBlock:^(TYPE value, NSUInteger idx, BOOL *stop) { +//%#pragma unused(idx, stop) +//% [self write##NAME:fieldNumber value:value]; +//% }]; +//% } +//%} +//% +//%PDDM-DEFINE WRITE_UNPACKABLE_DEFNS(NAME, TYPE) +//%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray *)values { +//% for (TYPE *value in values) { +//% [self write##NAME:fieldNumber value:value]; +//% } +//%} +//% +//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(Double, Double, double, ) +// This block of code is generated, do not edit it directly. + +- (void)writeDoubleArray:(int32_t)fieldNumber + values:(GPBDoubleArray *)values + tag:(uint32_t)tag { + if (tag != 0) { + if (values.count == 0) return; + __block size_t dataSize = 0; + [values enumerateValuesWithBlock:^(double value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + dataSize += GPBComputeDoubleSizeNoTag(value); + }]; + GPBWriteRawVarint32(&state_, tag); + GPBWriteRawVarint32(&state_, (int32_t)dataSize); + [values enumerateValuesWithBlock:^(double value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeDoubleNoTag:value]; + }]; + } else { + [values enumerateValuesWithBlock:^(double value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeDouble:fieldNumber value:value]; + }]; + } +} + +//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(Float, Float, float, ) +// This block of code is generated, do not edit it directly. + +- (void)writeFloatArray:(int32_t)fieldNumber + values:(GPBFloatArray *)values + tag:(uint32_t)tag { + if (tag != 0) { + if (values.count == 0) return; + __block size_t dataSize = 0; + [values enumerateValuesWithBlock:^(float value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + dataSize += GPBComputeFloatSizeNoTag(value); + }]; + GPBWriteRawVarint32(&state_, tag); + GPBWriteRawVarint32(&state_, (int32_t)dataSize); + [values enumerateValuesWithBlock:^(float value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeFloatNoTag:value]; + }]; + } else { + [values enumerateValuesWithBlock:^(float value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeFloat:fieldNumber value:value]; + }]; + } +} + +//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(UInt64, UInt64, uint64_t, ) +// This block of code is generated, do not edit it directly. + +- (void)writeUInt64Array:(int32_t)fieldNumber + values:(GPBUInt64Array *)values + tag:(uint32_t)tag { + if (tag != 0) { + if (values.count == 0) return; + __block size_t dataSize = 0; + [values enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + dataSize += GPBComputeUInt64SizeNoTag(value); + }]; + GPBWriteRawVarint32(&state_, tag); + GPBWriteRawVarint32(&state_, (int32_t)dataSize); + [values enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeUInt64NoTag:value]; + }]; + } else { + [values enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeUInt64:fieldNumber value:value]; + }]; + } +} + +//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(Int64, Int64, int64_t, ) +// This block of code is generated, do not edit it directly. + +- (void)writeInt64Array:(int32_t)fieldNumber + values:(GPBInt64Array *)values + tag:(uint32_t)tag { + if (tag != 0) { + if (values.count == 0) return; + __block size_t dataSize = 0; + [values enumerateValuesWithBlock:^(int64_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + dataSize += GPBComputeInt64SizeNoTag(value); + }]; + GPBWriteRawVarint32(&state_, tag); + GPBWriteRawVarint32(&state_, (int32_t)dataSize); + [values enumerateValuesWithBlock:^(int64_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeInt64NoTag:value]; + }]; + } else { + [values enumerateValuesWithBlock:^(int64_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeInt64:fieldNumber value:value]; + }]; + } +} + +//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(Int32, Int32, int32_t, ) +// This block of code is generated, do not edit it directly. + +- (void)writeInt32Array:(int32_t)fieldNumber + values:(GPBInt32Array *)values + tag:(uint32_t)tag { + if (tag != 0) { + if (values.count == 0) return; + __block size_t dataSize = 0; + [values enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + dataSize += GPBComputeInt32SizeNoTag(value); + }]; + GPBWriteRawVarint32(&state_, tag); + GPBWriteRawVarint32(&state_, (int32_t)dataSize); + [values enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeInt32NoTag:value]; + }]; + } else { + [values enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeInt32:fieldNumber value:value]; + }]; + } +} + +//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(UInt32, UInt32, uint32_t, ) +// This block of code is generated, do not edit it directly. + +- (void)writeUInt32Array:(int32_t)fieldNumber + values:(GPBUInt32Array *)values + tag:(uint32_t)tag { + if (tag != 0) { + if (values.count == 0) return; + __block size_t dataSize = 0; + [values enumerateValuesWithBlock:^(uint32_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + dataSize += GPBComputeUInt32SizeNoTag(value); + }]; + GPBWriteRawVarint32(&state_, tag); + GPBWriteRawVarint32(&state_, (int32_t)dataSize); + [values enumerateValuesWithBlock:^(uint32_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeUInt32NoTag:value]; + }]; + } else { + [values enumerateValuesWithBlock:^(uint32_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeUInt32:fieldNumber value:value]; + }]; + } +} + +//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(Fixed64, UInt64, uint64_t, ) +// This block of code is generated, do not edit it directly. + +- (void)writeFixed64Array:(int32_t)fieldNumber + values:(GPBUInt64Array *)values + tag:(uint32_t)tag { + if (tag != 0) { + if (values.count == 0) return; + __block size_t dataSize = 0; + [values enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + dataSize += GPBComputeFixed64SizeNoTag(value); + }]; + GPBWriteRawVarint32(&state_, tag); + GPBWriteRawVarint32(&state_, (int32_t)dataSize); + [values enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeFixed64NoTag:value]; + }]; + } else { + [values enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeFixed64:fieldNumber value:value]; + }]; + } +} + +//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(Fixed32, UInt32, uint32_t, ) +// This block of code is generated, do not edit it directly. + +- (void)writeFixed32Array:(int32_t)fieldNumber + values:(GPBUInt32Array *)values + tag:(uint32_t)tag { + if (tag != 0) { + if (values.count == 0) return; + __block size_t dataSize = 0; + [values enumerateValuesWithBlock:^(uint32_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + dataSize += GPBComputeFixed32SizeNoTag(value); + }]; + GPBWriteRawVarint32(&state_, tag); + GPBWriteRawVarint32(&state_, (int32_t)dataSize); + [values enumerateValuesWithBlock:^(uint32_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeFixed32NoTag:value]; + }]; + } else { + [values enumerateValuesWithBlock:^(uint32_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeFixed32:fieldNumber value:value]; + }]; + } +} + +//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(SInt32, Int32, int32_t, ) +// This block of code is generated, do not edit it directly. + +- (void)writeSInt32Array:(int32_t)fieldNumber + values:(GPBInt32Array *)values + tag:(uint32_t)tag { + if (tag != 0) { + if (values.count == 0) return; + __block size_t dataSize = 0; + [values enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + dataSize += GPBComputeSInt32SizeNoTag(value); + }]; + GPBWriteRawVarint32(&state_, tag); + GPBWriteRawVarint32(&state_, (int32_t)dataSize); + [values enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeSInt32NoTag:value]; + }]; + } else { + [values enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeSInt32:fieldNumber value:value]; + }]; + } +} + +//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(SInt64, Int64, int64_t, ) +// This block of code is generated, do not edit it directly. + +- (void)writeSInt64Array:(int32_t)fieldNumber + values:(GPBInt64Array *)values + tag:(uint32_t)tag { + if (tag != 0) { + if (values.count == 0) return; + __block size_t dataSize = 0; + [values enumerateValuesWithBlock:^(int64_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + dataSize += GPBComputeSInt64SizeNoTag(value); + }]; + GPBWriteRawVarint32(&state_, tag); + GPBWriteRawVarint32(&state_, (int32_t)dataSize); + [values enumerateValuesWithBlock:^(int64_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeSInt64NoTag:value]; + }]; + } else { + [values enumerateValuesWithBlock:^(int64_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeSInt64:fieldNumber value:value]; + }]; + } +} + +//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(SFixed64, Int64, int64_t, ) +// This block of code is generated, do not edit it directly. + +- (void)writeSFixed64Array:(int32_t)fieldNumber + values:(GPBInt64Array *)values + tag:(uint32_t)tag { + if (tag != 0) { + if (values.count == 0) return; + __block size_t dataSize = 0; + [values enumerateValuesWithBlock:^(int64_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + dataSize += GPBComputeSFixed64SizeNoTag(value); + }]; + GPBWriteRawVarint32(&state_, tag); + GPBWriteRawVarint32(&state_, (int32_t)dataSize); + [values enumerateValuesWithBlock:^(int64_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeSFixed64NoTag:value]; + }]; + } else { + [values enumerateValuesWithBlock:^(int64_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeSFixed64:fieldNumber value:value]; + }]; + } +} + +//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(SFixed32, Int32, int32_t, ) +// This block of code is generated, do not edit it directly. + +- (void)writeSFixed32Array:(int32_t)fieldNumber + values:(GPBInt32Array *)values + tag:(uint32_t)tag { + if (tag != 0) { + if (values.count == 0) return; + __block size_t dataSize = 0; + [values enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + dataSize += GPBComputeSFixed32SizeNoTag(value); + }]; + GPBWriteRawVarint32(&state_, tag); + GPBWriteRawVarint32(&state_, (int32_t)dataSize); + [values enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeSFixed32NoTag:value]; + }]; + } else { + [values enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeSFixed32:fieldNumber value:value]; + }]; + } +} + +//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(Bool, Bool, BOOL, ) +// This block of code is generated, do not edit it directly. + +- (void)writeBoolArray:(int32_t)fieldNumber + values:(GPBBoolArray *)values + tag:(uint32_t)tag { + if (tag != 0) { + if (values.count == 0) return; + __block size_t dataSize = 0; + [values enumerateValuesWithBlock:^(BOOL value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + dataSize += GPBComputeBoolSizeNoTag(value); + }]; + GPBWriteRawVarint32(&state_, tag); + GPBWriteRawVarint32(&state_, (int32_t)dataSize); + [values enumerateValuesWithBlock:^(BOOL value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeBoolNoTag:value]; + }]; + } else { + [values enumerateValuesWithBlock:^(BOOL value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeBool:fieldNumber value:value]; + }]; + } +} + +//%PDDM-EXPAND WRITE_PACKABLE_DEFNS(Enum, Enum, int32_t, Raw) +// This block of code is generated, do not edit it directly. + +- (void)writeEnumArray:(int32_t)fieldNumber + values:(GPBEnumArray *)values + tag:(uint32_t)tag { + if (tag != 0) { + if (values.count == 0) return; + __block size_t dataSize = 0; + [values enumerateRawValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + dataSize += GPBComputeEnumSizeNoTag(value); + }]; + GPBWriteRawVarint32(&state_, tag); + GPBWriteRawVarint32(&state_, (int32_t)dataSize); + [values enumerateRawValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeEnumNoTag:value]; + }]; + } else { + [values enumerateRawValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [self writeEnum:fieldNumber value:value]; + }]; + } +} + +//%PDDM-EXPAND WRITE_UNPACKABLE_DEFNS(String, NSString) +// This block of code is generated, do not edit it directly. + +- (void)writeStringArray:(int32_t)fieldNumber values:(NSArray *)values { + for (NSString *value in values) { + [self writeString:fieldNumber value:value]; + } +} + +//%PDDM-EXPAND WRITE_UNPACKABLE_DEFNS(Message, GPBMessage) +// This block of code is generated, do not edit it directly. + +- (void)writeMessageArray:(int32_t)fieldNumber values:(NSArray *)values { + for (GPBMessage *value in values) { + [self writeMessage:fieldNumber value:value]; + } +} + +//%PDDM-EXPAND WRITE_UNPACKABLE_DEFNS(Bytes, NSData) +// This block of code is generated, do not edit it directly. + +- (void)writeBytesArray:(int32_t)fieldNumber values:(NSArray *)values { + for (NSData *value in values) { + [self writeBytes:fieldNumber value:value]; + } +} + +//%PDDM-EXPAND WRITE_UNPACKABLE_DEFNS(Group, GPBMessage) +// This block of code is generated, do not edit it directly. + +- (void)writeGroupArray:(int32_t)fieldNumber values:(NSArray *)values { + for (GPBMessage *value in values) { + [self writeGroup:fieldNumber value:value]; + } +} + +//%PDDM-EXPAND WRITE_UNPACKABLE_DEFNS(UnknownGroup, GPBUnknownFieldSet) +// This block of code is generated, do not edit it directly. + +- (void)writeUnknownGroupArray:(int32_t)fieldNumber values:(NSArray *)values { + for (GPBUnknownFieldSet *value in values) { + [self writeUnknownGroup:fieldNumber value:value]; + } +} + +//%PDDM-EXPAND-END (19 expansions) + +- (void)writeMessageSetExtension:(int32_t)fieldNumber + value:(GPBMessage *)value { + GPBWriteTagWithFormat(&state_, GPBWireFormatMessageSetItem, + GPBWireFormatStartGroup); + GPBWriteUInt32(&state_, GPBWireFormatMessageSetTypeId, fieldNumber); + [self writeMessage:GPBWireFormatMessageSetMessage value:value]; + GPBWriteTagWithFormat(&state_, GPBWireFormatMessageSetItem, + GPBWireFormatEndGroup); +} + +- (void)writeRawMessageSetExtension:(int32_t)fieldNumber value:(NSData *)value { + GPBWriteTagWithFormat(&state_, GPBWireFormatMessageSetItem, + GPBWireFormatStartGroup); + GPBWriteUInt32(&state_, GPBWireFormatMessageSetTypeId, fieldNumber); + [self writeBytes:GPBWireFormatMessageSetMessage value:value]; + GPBWriteTagWithFormat(&state_, GPBWireFormatMessageSetItem, + GPBWireFormatEndGroup); +} + +- (void)flush { + if (state_.output != nil) { + GPBRefreshBuffer(&state_); + } +} + +- (void)writeRawByte:(uint8_t)value { + GPBWriteRawByte(&state_, value); +} + +- (void)writeRawData:(const NSData *)data { + [self writeRawPtr:[data bytes] offset:0 length:[data length]]; +} + +- (void)writeRawPtr:(const void *)value + offset:(size_t)offset + length:(size_t)length { + if (value == nil || length == 0) { + return; + } + + NSUInteger bufferLength = state_.size; + NSUInteger bufferBytesLeft = bufferLength - state_.position; + if (bufferBytesLeft >= length) { + // We have room in the current buffer. + memcpy(state_.bytes + state_.position, ((uint8_t *)value) + offset, length); + state_.position += length; + } else { + // Write extends past current buffer. Fill the rest of this buffer and + // flush. + size_t bytesWritten = bufferBytesLeft; + memcpy(state_.bytes + state_.position, ((uint8_t *)value) + offset, + bytesWritten); + offset += bytesWritten; + length -= bytesWritten; + state_.position = bufferLength; + GPBRefreshBuffer(&state_); + bufferLength = state_.size; + + // Now deal with the rest. + // Since we have an output stream, this is our buffer + // and buffer offset == 0 + if (length <= bufferLength) { + // Fits in new buffer. + memcpy(state_.bytes, ((uint8_t *)value) + offset, length); + state_.position = length; + } else { + // Write is very big. Let's do it all at once. + [state_.output write:((uint8_t *)value) + offset maxLength:length]; + } + } +} + +- (void)writeTag:(uint32_t)fieldNumber format:(GPBWireFormat)format { + GPBWriteTagWithFormat(&state_, fieldNumber, format); +} + +- (void)writeRawVarint32:(int32_t)value { + GPBWriteRawVarint32(&state_, value); +} + +- (void)writeRawVarintSizeTAs32:(size_t)value { + // Note the truncation. + GPBWriteRawVarint32(&state_, (int32_t)value); +} + +- (void)writeRawVarint64:(int64_t)value { + GPBWriteRawVarint64(&state_, value); +} + +- (void)writeRawLittleEndian32:(int32_t)value { + GPBWriteRawLittleEndian32(&state_, value); +} + +- (void)writeRawLittleEndian64:(int64_t)value { + GPBWriteRawLittleEndian64(&state_, value); +} + +#pragma clang diagnostic pop + +@end + +size_t GPBComputeDoubleSizeNoTag(Float64 value) { +#pragma unused(value) + return LITTLE_ENDIAN_64_SIZE; +} + +size_t GPBComputeFloatSizeNoTag(Float32 value) { +#pragma unused(value) + return LITTLE_ENDIAN_32_SIZE; +} + +size_t GPBComputeUInt64SizeNoTag(uint64_t value) { + return GPBComputeRawVarint64Size(value); +} + +size_t GPBComputeInt64SizeNoTag(int64_t value) { + return GPBComputeRawVarint64Size(value); +} + +size_t GPBComputeInt32SizeNoTag(int32_t value) { + if (value >= 0) { + return GPBComputeRawVarint32Size(value); + } else { + // Must sign-extend. + return 10; + } +} + +size_t GPBComputeSizeTSizeAsInt32NoTag(size_t value) { + return GPBComputeInt32SizeNoTag((int32_t)value); +} + +size_t GPBComputeFixed64SizeNoTag(uint64_t value) { +#pragma unused(value) + return LITTLE_ENDIAN_64_SIZE; +} + +size_t GPBComputeFixed32SizeNoTag(uint32_t value) { +#pragma unused(value) + return LITTLE_ENDIAN_32_SIZE; +} + +size_t GPBComputeBoolSizeNoTag(BOOL value) { +#pragma unused(value) + return 1; +} + +size_t GPBComputeStringSizeNoTag(NSString *value) { + NSUInteger length = [value lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; + return GPBComputeRawVarint32SizeForInteger(length) + length; +} + +size_t GPBComputeGroupSizeNoTag(GPBMessage *value) { + return [value serializedSize]; +} + +size_t GPBComputeUnknownGroupSizeNoTag(GPBUnknownFieldSet *value) { + return value.serializedSize; +} + +size_t GPBComputeMessageSizeNoTag(GPBMessage *value) { + size_t size = [value serializedSize]; + return GPBComputeRawVarint32SizeForInteger(size) + size; +} + +size_t GPBComputeBytesSizeNoTag(NSData *value) { + NSUInteger valueLength = [value length]; + return GPBComputeRawVarint32SizeForInteger(valueLength) + valueLength; +} + +size_t GPBComputeUInt32SizeNoTag(int32_t value) { + return GPBComputeRawVarint32Size(value); +} + +size_t GPBComputeEnumSizeNoTag(int32_t value) { + return GPBComputeRawVarint32Size(value); +} + +size_t GPBComputeSFixed32SizeNoTag(int32_t value) { +#pragma unused(value) + return LITTLE_ENDIAN_32_SIZE; +} + +size_t GPBComputeSFixed64SizeNoTag(int64_t value) { +#pragma unused(value) + return LITTLE_ENDIAN_64_SIZE; +} + +size_t GPBComputeSInt32SizeNoTag(int32_t value) { + return GPBComputeRawVarint32Size(GPBEncodeZigZag32(value)); +} + +size_t GPBComputeSInt64SizeNoTag(int64_t value) { + return GPBComputeRawVarint64Size(GPBEncodeZigZag64(value)); +} + +size_t GPBComputeDoubleSize(int32_t fieldNumber, double value) { + return GPBComputeTagSize(fieldNumber) + GPBComputeDoubleSizeNoTag(value); +} + +size_t GPBComputeFloatSize(int32_t fieldNumber, float value) { + return GPBComputeTagSize(fieldNumber) + GPBComputeFloatSizeNoTag(value); +} + +size_t GPBComputeUInt64Size(int32_t fieldNumber, uint64_t value) { + return GPBComputeTagSize(fieldNumber) + GPBComputeUInt64SizeNoTag(value); +} + +size_t GPBComputeInt64Size(int32_t fieldNumber, int64_t value) { + return GPBComputeTagSize(fieldNumber) + GPBComputeInt64SizeNoTag(value); +} + +size_t GPBComputeInt32Size(int32_t fieldNumber, int32_t value) { + return GPBComputeTagSize(fieldNumber) + GPBComputeInt32SizeNoTag(value); +} + +size_t GPBComputeFixed64Size(int32_t fieldNumber, uint64_t value) { + return GPBComputeTagSize(fieldNumber) + GPBComputeFixed64SizeNoTag(value); +} + +size_t GPBComputeFixed32Size(int32_t fieldNumber, uint32_t value) { + return GPBComputeTagSize(fieldNumber) + GPBComputeFixed32SizeNoTag(value); +} + +size_t GPBComputeBoolSize(int32_t fieldNumber, BOOL value) { + return GPBComputeTagSize(fieldNumber) + GPBComputeBoolSizeNoTag(value); +} + +size_t GPBComputeStringSize(int32_t fieldNumber, NSString *value) { + return GPBComputeTagSize(fieldNumber) + GPBComputeStringSizeNoTag(value); +} + +size_t GPBComputeGroupSize(int32_t fieldNumber, GPBMessage *value) { + return GPBComputeTagSize(fieldNumber) * 2 + GPBComputeGroupSizeNoTag(value); +} + +size_t GPBComputeUnknownGroupSize(int32_t fieldNumber, + GPBUnknownFieldSet *value) { + return GPBComputeTagSize(fieldNumber) * 2 + + GPBComputeUnknownGroupSizeNoTag(value); +} + +size_t GPBComputeMessageSize(int32_t fieldNumber, GPBMessage *value) { + return GPBComputeTagSize(fieldNumber) + GPBComputeMessageSizeNoTag(value); +} + +size_t GPBComputeBytesSize(int32_t fieldNumber, NSData *value) { + return GPBComputeTagSize(fieldNumber) + GPBComputeBytesSizeNoTag(value); +} + +size_t GPBComputeUInt32Size(int32_t fieldNumber, uint32_t value) { + return GPBComputeTagSize(fieldNumber) + GPBComputeUInt32SizeNoTag(value); +} + +size_t GPBComputeEnumSize(int32_t fieldNumber, int32_t value) { + return GPBComputeTagSize(fieldNumber) + GPBComputeEnumSizeNoTag(value); +} + +size_t GPBComputeSFixed32Size(int32_t fieldNumber, int32_t value) { + return GPBComputeTagSize(fieldNumber) + GPBComputeSFixed32SizeNoTag(value); +} + +size_t GPBComputeSFixed64Size(int32_t fieldNumber, int64_t value) { + return GPBComputeTagSize(fieldNumber) + GPBComputeSFixed64SizeNoTag(value); +} + +size_t GPBComputeSInt32Size(int32_t fieldNumber, int32_t value) { + return GPBComputeTagSize(fieldNumber) + GPBComputeSInt32SizeNoTag(value); +} + +size_t GPBComputeSInt64Size(int32_t fieldNumber, int64_t value) { + return GPBComputeTagSize(fieldNumber) + + GPBComputeRawVarint64Size(GPBEncodeZigZag64(value)); +} + +size_t GPBComputeMessageSetExtensionSize(int32_t fieldNumber, + GPBMessage *value) { + return GPBComputeTagSize(GPBWireFormatMessageSetItem) * 2 + + GPBComputeUInt32Size(GPBWireFormatMessageSetTypeId, fieldNumber) + + GPBComputeMessageSize(GPBWireFormatMessageSetMessage, value); +} + +size_t GPBComputeRawMessageSetExtensionSize(int32_t fieldNumber, + NSData *value) { + return GPBComputeTagSize(GPBWireFormatMessageSetItem) * 2 + + GPBComputeUInt32Size(GPBWireFormatMessageSetTypeId, fieldNumber) + + GPBComputeBytesSize(GPBWireFormatMessageSetMessage, value); +} + +size_t GPBComputeTagSize(int32_t fieldNumber) { + return GPBComputeRawVarint32Size( + GPBWireFormatMakeTag(fieldNumber, GPBWireFormatVarint)); +} + +size_t GPBComputeWireFormatTagSize(int field_number, GPBDataType dataType) { + size_t result = GPBComputeTagSize(field_number); + if (dataType == GPBDataTypeGroup) { + // Groups have both a start and an end tag. + return result * 2; + } else { + return result; + } +} + +size_t GPBComputeRawVarint32Size(int32_t value) { + // value is treated as unsigned, so it won't be sign-extended if negative. + if ((value & (0xffffffff << 7)) == 0) return 1; + if ((value & (0xffffffff << 14)) == 0) return 2; + if ((value & (0xffffffff << 21)) == 0) return 3; + if ((value & (0xffffffff << 28)) == 0) return 4; + return 5; +} + +size_t GPBComputeRawVarint32SizeForInteger(NSInteger value) { + // Note the truncation. + return GPBComputeRawVarint32Size((int32_t)value); +} + +size_t GPBComputeRawVarint64Size(int64_t value) { + if ((value & (0xffffffffffffffffL << 7)) == 0) return 1; + if ((value & (0xffffffffffffffffL << 14)) == 0) return 2; + if ((value & (0xffffffffffffffffL << 21)) == 0) return 3; + if ((value & (0xffffffffffffffffL << 28)) == 0) return 4; + if ((value & (0xffffffffffffffffL << 35)) == 0) return 5; + if ((value & (0xffffffffffffffffL << 42)) == 0) return 6; + if ((value & (0xffffffffffffffffL << 49)) == 0) return 7; + if ((value & (0xffffffffffffffffL << 56)) == 0) return 8; + if ((value & (0xffffffffffffffffL << 63)) == 0) return 9; + return 10; +} diff --git a/Pods/Protobuf/objectivec/GPBCodedOutputStream_PackagePrivate.h b/Pods/Protobuf/objectivec/GPBCodedOutputStream_PackagePrivate.h new file mode 100644 index 0000000..2e7bb4c --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBCodedOutputStream_PackagePrivate.h @@ -0,0 +1,126 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2016 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import "GPBCodedOutputStream.h" + +NS_ASSUME_NONNULL_BEGIN + +CF_EXTERN_C_BEGIN + +size_t GPBComputeDoubleSize(int32_t fieldNumber, double value) + __attribute__((const)); +size_t GPBComputeFloatSize(int32_t fieldNumber, float value) + __attribute__((const)); +size_t GPBComputeUInt64Size(int32_t fieldNumber, uint64_t value) + __attribute__((const)); +size_t GPBComputeInt64Size(int32_t fieldNumber, int64_t value) + __attribute__((const)); +size_t GPBComputeInt32Size(int32_t fieldNumber, int32_t value) + __attribute__((const)); +size_t GPBComputeFixed64Size(int32_t fieldNumber, uint64_t value) + __attribute__((const)); +size_t GPBComputeFixed32Size(int32_t fieldNumber, uint32_t value) + __attribute__((const)); +size_t GPBComputeBoolSize(int32_t fieldNumber, BOOL value) + __attribute__((const)); +size_t GPBComputeStringSize(int32_t fieldNumber, NSString *value) + __attribute__((const)); +size_t GPBComputeGroupSize(int32_t fieldNumber, GPBMessage *value) + __attribute__((const)); +size_t GPBComputeUnknownGroupSize(int32_t fieldNumber, + GPBUnknownFieldSet *value) + __attribute__((const)); +size_t GPBComputeMessageSize(int32_t fieldNumber, GPBMessage *value) + __attribute__((const)); +size_t GPBComputeBytesSize(int32_t fieldNumber, NSData *value) + __attribute__((const)); +size_t GPBComputeUInt32Size(int32_t fieldNumber, uint32_t value) + __attribute__((const)); +size_t GPBComputeSFixed32Size(int32_t fieldNumber, int32_t value) + __attribute__((const)); +size_t GPBComputeSFixed64Size(int32_t fieldNumber, int64_t value) + __attribute__((const)); +size_t GPBComputeSInt32Size(int32_t fieldNumber, int32_t value) + __attribute__((const)); +size_t GPBComputeSInt64Size(int32_t fieldNumber, int64_t value) + __attribute__((const)); +size_t GPBComputeTagSize(int32_t fieldNumber) __attribute__((const)); +size_t GPBComputeWireFormatTagSize(int field_number, GPBDataType dataType) + __attribute__((const)); + +size_t GPBComputeDoubleSizeNoTag(double value) __attribute__((const)); +size_t GPBComputeFloatSizeNoTag(float value) __attribute__((const)); +size_t GPBComputeUInt64SizeNoTag(uint64_t value) __attribute__((const)); +size_t GPBComputeInt64SizeNoTag(int64_t value) __attribute__((const)); +size_t GPBComputeInt32SizeNoTag(int32_t value) __attribute__((const)); +size_t GPBComputeFixed64SizeNoTag(uint64_t value) __attribute__((const)); +size_t GPBComputeFixed32SizeNoTag(uint32_t value) __attribute__((const)); +size_t GPBComputeBoolSizeNoTag(BOOL value) __attribute__((const)); +size_t GPBComputeStringSizeNoTag(NSString *value) __attribute__((const)); +size_t GPBComputeGroupSizeNoTag(GPBMessage *value) __attribute__((const)); +size_t GPBComputeUnknownGroupSizeNoTag(GPBUnknownFieldSet *value) + __attribute__((const)); +size_t GPBComputeMessageSizeNoTag(GPBMessage *value) __attribute__((const)); +size_t GPBComputeBytesSizeNoTag(NSData *value) __attribute__((const)); +size_t GPBComputeUInt32SizeNoTag(int32_t value) __attribute__((const)); +size_t GPBComputeEnumSizeNoTag(int32_t value) __attribute__((const)); +size_t GPBComputeSFixed32SizeNoTag(int32_t value) __attribute__((const)); +size_t GPBComputeSFixed64SizeNoTag(int64_t value) __attribute__((const)); +size_t GPBComputeSInt32SizeNoTag(int32_t value) __attribute__((const)); +size_t GPBComputeSInt64SizeNoTag(int64_t value) __attribute__((const)); + +// Note that this will calculate the size of 64 bit values truncated to 32. +size_t GPBComputeSizeTSizeAsInt32NoTag(size_t value) __attribute__((const)); + +size_t GPBComputeRawVarint32Size(int32_t value) __attribute__((const)); +size_t GPBComputeRawVarint64Size(int64_t value) __attribute__((const)); + +// Note that this will calculate the size of 64 bit values truncated to 32. +size_t GPBComputeRawVarint32SizeForInteger(NSInteger value) + __attribute__((const)); + +// Compute the number of bytes that would be needed to encode a +// MessageSet extension to the stream. For historical reasons, +// the wire format differs from normal fields. +size_t GPBComputeMessageSetExtensionSize(int32_t fieldNumber, GPBMessage *value) + __attribute__((const)); + +// Compute the number of bytes that would be needed to encode an +// unparsed MessageSet extension field to the stream. For +// historical reasons, the wire format differs from normal fields. +size_t GPBComputeRawMessageSetExtensionSize(int32_t fieldNumber, NSData *value) + __attribute__((const)); + +size_t GPBComputeEnumSize(int32_t fieldNumber, int32_t value) + __attribute__((const)); + +CF_EXTERN_C_END + +NS_ASSUME_NONNULL_END diff --git a/Pods/Protobuf/objectivec/GPBDescriptor.h b/Pods/Protobuf/objectivec/GPBDescriptor.h new file mode 100644 index 0000000..651f4de --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBDescriptor.h @@ -0,0 +1,288 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import + +#import "GPBRuntimeTypes.h" + +@class GPBEnumDescriptor; +@class GPBFieldDescriptor; +@class GPBFileDescriptor; +@class GPBOneofDescriptor; + +NS_ASSUME_NONNULL_BEGIN + +/** Syntax used in the proto file. */ +typedef NS_ENUM(uint8_t, GPBFileSyntax) { + /** Unknown syntax. */ + GPBFileSyntaxUnknown = 0, + /** Proto2 syntax. */ + GPBFileSyntaxProto2 = 2, + /** Proto3 syntax. */ + GPBFileSyntaxProto3 = 3, +}; + +/** Type of proto field. */ +typedef NS_ENUM(uint8_t, GPBFieldType) { + /** Optional/required field. Only valid for proto2 fields. */ + GPBFieldTypeSingle, + /** Repeated field. */ + GPBFieldTypeRepeated, + /** Map field. */ + GPBFieldTypeMap, +}; + +/** + * Describes a proto message. + **/ +@interface GPBDescriptor : NSObject + +/** Name of the message. */ +@property(nonatomic, readonly, copy) NSString *name; +/** Fields declared in the message. */ +@property(nonatomic, readonly, strong, nullable) NSArray *fields; +/** Oneofs declared in the message. */ +@property(nonatomic, readonly, strong, nullable) NSArray *oneofs; +/** Extension range declared for the message. */ +@property(nonatomic, readonly, nullable) const GPBExtensionRange *extensionRanges; +/** Number of extension ranges declared for the message. */ +@property(nonatomic, readonly) uint32_t extensionRangesCount; +/** Descriptor for the file where the message was defined. */ +@property(nonatomic, readonly, assign) GPBFileDescriptor *file; + +/** Whether the message is in wire format or not. */ +@property(nonatomic, readonly, getter=isWireFormat) BOOL wireFormat; +/** The class of this message. */ +@property(nonatomic, readonly) Class messageClass; +/** Containing message descriptor if this message is nested, or nil otherwise. */ +@property(readonly, nullable) GPBDescriptor *containingType; +/** + * Fully qualified name for this message (package.message). Can be nil if the + * value is unable to be computed. + */ +@property(readonly, nullable) NSString *fullName; + +/** + * Gets the field for the given number. + * + * @param fieldNumber The number for the field to get. + * + * @return The field descriptor for the given number, or nil if not found. + **/ +- (nullable GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber; + +/** + * Gets the field for the given name. + * + * @param name The name for the field to get. + * + * @return The field descriptor for the given name, or nil if not found. + **/ +- (nullable GPBFieldDescriptor *)fieldWithName:(NSString *)name; + +/** + * Gets the oneof for the given name. + * + * @param name The name for the oneof to get. + * + * @return The oneof descriptor for the given name, or nil if not found. + **/ +- (nullable GPBOneofDescriptor *)oneofWithName:(NSString *)name; + +@end + +/** + * Describes a proto file. + **/ +@interface GPBFileDescriptor : NSObject + +/** The package declared in the proto file. */ +@property(nonatomic, readonly, copy) NSString *package; +/** The objc prefix declared in the proto file. */ +@property(nonatomic, readonly, copy, nullable) NSString *objcPrefix; +/** The syntax of the proto file. */ +@property(nonatomic, readonly) GPBFileSyntax syntax; + +@end + +/** + * Describes a oneof field. + **/ +@interface GPBOneofDescriptor : NSObject +/** Name of the oneof field. */ +@property(nonatomic, readonly) NSString *name; +/** Fields declared in the oneof. */ +@property(nonatomic, readonly) NSArray *fields; + +/** + * Gets the field for the given number. + * + * @param fieldNumber The number for the field to get. + * + * @return The field descriptor for the given number, or nil if not found. + **/ +- (nullable GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber; + +/** + * Gets the field for the given name. + * + * @param name The name for the field to get. + * + * @return The field descriptor for the given name, or nil if not found. + **/ +- (nullable GPBFieldDescriptor *)fieldWithName:(NSString *)name; + +@end + +/** + * Describes a proto field. + **/ +@interface GPBFieldDescriptor : NSObject + +/** Name of the field. */ +@property(nonatomic, readonly, copy) NSString *name; +/** Number associated with the field. */ +@property(nonatomic, readonly) uint32_t number; +/** Data type contained in the field. */ +@property(nonatomic, readonly) GPBDataType dataType; +/** Whether it has a default value or not. */ +@property(nonatomic, readonly) BOOL hasDefaultValue; +/** Default value for the field. */ +@property(nonatomic, readonly) GPBGenericValue defaultValue; +/** Whether this field is required. Only valid for proto2 fields. */ +@property(nonatomic, readonly, getter=isRequired) BOOL required; +/** Whether this field is optional. */ +@property(nonatomic, readonly, getter=isOptional) BOOL optional; +/** Type of field (single, repeated, map). */ +@property(nonatomic, readonly) GPBFieldType fieldType; +/** Type of the key if the field is a map. The value's type is -fieldType. */ +@property(nonatomic, readonly) GPBDataType mapKeyDataType; +/** Whether the field is packable. */ +@property(nonatomic, readonly, getter=isPackable) BOOL packable; + +/** The containing oneof if this field is part of one, nil otherwise. */ +@property(nonatomic, readonly, assign, nullable) GPBOneofDescriptor *containingOneof; + +/** Class of the message if the field is of message type. */ +@property(nonatomic, readonly, assign, nullable) Class msgClass; + +/** Descriptor for the enum if this field is an enum. */ +@property(nonatomic, readonly, strong, nullable) GPBEnumDescriptor *enumDescriptor; + +/** + * Checks whether the given enum raw value is a valid enum value. + * + * @param value The raw enum value to check. + * + * @return YES if value is a valid enum raw value. + **/ +- (BOOL)isValidEnumValue:(int32_t)value; + +/** @return Name for the text format, or nil if not known. */ +- (nullable NSString *)textFormatName; + +@end + +/** + * Describes a proto enum. + **/ +@interface GPBEnumDescriptor : NSObject + +/** Name of the enum. */ +@property(nonatomic, readonly, copy) NSString *name; +/** Function that validates that raw values are valid enum values. */ +@property(nonatomic, readonly) GPBEnumValidationFunc enumVerifier; + +/** + * Returns the enum value name for the given raw enum. + * + * @param number The raw enum value. + * + * @return The name of the enum value passed, or nil if not valid. + **/ +- (nullable NSString *)enumNameForValue:(int32_t)number; + +/** + * Gets the enum raw value for the given enum name. + * + * @param outValue A pointer where the value will be set. + * @param name The enum name for which to get the raw value. + * + * @return YES if a value was copied into the pointer, NO otherwise. + **/ +- (BOOL)getValue:(nullable int32_t *)outValue forEnumName:(NSString *)name; + +/** + * Returns the text format for the given raw enum value. + * + * @param number The raw enum value. + * + * @return The text format name for the raw enum value, or nil if not valid. + **/ +- (nullable NSString *)textFormatNameForValue:(int32_t)number; + +/** + * Gets the enum raw value for the given text format name. + * + * @param outValue A pointer where the value will be set. + * @param textFormatName The text format name for which to get the raw value. + * + * @return YES if a value was copied into the pointer, NO otherwise. + **/ +- (BOOL)getValue:(nullable int32_t *)outValue forEnumTextFormatName:(NSString *)textFormatName; + +@end + +/** + * Describes a proto extension. + **/ +@interface GPBExtensionDescriptor : NSObject +/** Field number under which the extension is stored. */ +@property(nonatomic, readonly) uint32_t fieldNumber; +/** The containing message class, i.e. the class extended by this extension. */ +@property(nonatomic, readonly) Class containingMessageClass; +/** Data type contained in the extension. */ +@property(nonatomic, readonly) GPBDataType dataType; +/** Whether the extension is repeated. */ +@property(nonatomic, readonly, getter=isRepeated) BOOL repeated; +/** Whether the extension is packable. */ +@property(nonatomic, readonly, getter=isPackable) BOOL packable; +/** The class of the message if the extension is of message type. */ +@property(nonatomic, readonly, assign) Class msgClass; +/** The singleton name for the extension. */ +@property(nonatomic, readonly) NSString *singletonName; +/** The enum descriptor if the extension is of enum type. */ +@property(nonatomic, readonly, strong, nullable) GPBEnumDescriptor *enumDescriptor; +/** The default value for the extension. */ +@property(nonatomic, readonly, nullable) id defaultValue; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Pods/Protobuf/objectivec/GPBDescriptor.m b/Pods/Protobuf/objectivec/GPBDescriptor.m new file mode 100644 index 0000000..3c3844d --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBDescriptor.m @@ -0,0 +1,1100 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import "GPBDescriptor_PackagePrivate.h" + +#import + +#import "GPBUtilities_PackagePrivate.h" +#import "GPBWireFormat.h" +#import "GPBMessage_PackagePrivate.h" + +// Direct access is use for speed, to avoid even internally declaring things +// read/write, etc. The warning is enabled in the project to ensure code calling +// protos can turn on -Wdirect-ivar-access without issues. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdirect-ivar-access" + +// The addresses of these variables are used as keys for objc_getAssociatedObject. +static const char kTextFormatExtraValueKey = 0; +static const char kParentClassNameValueKey = 0; +static const char kClassNameSuffixKey = 0; + +// Utility function to generate selectors on the fly. +static SEL SelFromStrings(const char *prefix, const char *middle, + const char *suffix, BOOL takesArg) { + if (prefix == NULL && suffix == NULL && !takesArg) { + return sel_getUid(middle); + } + const size_t prefixLen = prefix != NULL ? strlen(prefix) : 0; + const size_t middleLen = strlen(middle); + const size_t suffixLen = suffix != NULL ? strlen(suffix) : 0; + size_t totalLen = + prefixLen + middleLen + suffixLen + 1; // include space for null on end. + if (takesArg) { + totalLen += 1; + } + char buffer[totalLen]; + if (prefix != NULL) { + memcpy(buffer, prefix, prefixLen); + memcpy(buffer + prefixLen, middle, middleLen); + buffer[prefixLen] = (char)toupper(buffer[prefixLen]); + } else { + memcpy(buffer, middle, middleLen); + } + if (suffix != NULL) { + memcpy(buffer + prefixLen + middleLen, suffix, suffixLen); + } + if (takesArg) { + buffer[totalLen - 2] = ':'; + } + // Always null terminate it. + buffer[totalLen - 1] = 0; + + SEL result = sel_getUid(buffer); + return result; +} + +static NSArray *NewFieldsArrayForHasIndex(int hasIndex, + NSArray *allMessageFields) + __attribute__((ns_returns_retained)); + +static NSArray *NewFieldsArrayForHasIndex(int hasIndex, + NSArray *allMessageFields) { + NSMutableArray *result = [[NSMutableArray alloc] init]; + for (GPBFieldDescriptor *fieldDesc in allMessageFields) { + if (fieldDesc->description_->hasIndex == hasIndex) { + [result addObject:fieldDesc]; + } + } + return result; +} + +@implementation GPBDescriptor { + Class messageClass_; + GPBFileDescriptor *file_; + BOOL wireFormat_; +} + +@synthesize messageClass = messageClass_; +@synthesize fields = fields_; +@synthesize oneofs = oneofs_; +@synthesize extensionRanges = extensionRanges_; +@synthesize extensionRangesCount = extensionRangesCount_; +@synthesize file = file_; +@synthesize wireFormat = wireFormat_; + ++ (instancetype) + allocDescriptorForClass:(Class)messageClass + rootClass:(Class)rootClass + file:(GPBFileDescriptor *)file + fields:(void *)fieldDescriptions + fieldCount:(uint32_t)fieldCount + storageSize:(uint32_t)storageSize + flags:(GPBDescriptorInitializationFlags)flags { + // The rootClass is no longer used, but it is passed in to ensure it + // was started up during initialization also. + (void)rootClass; + NSMutableArray *fields = nil; + GPBFileSyntax syntax = file.syntax; + BOOL fieldsIncludeDefault = + (flags & GPBDescriptorInitializationFlag_FieldsWithDefault) != 0; + + void *desc; + for (uint32_t i = 0; i < fieldCount; ++i) { + if (fields == nil) { + fields = [[NSMutableArray alloc] initWithCapacity:fieldCount]; + } + // Need correctly typed pointer for array indexing below to work. + if (fieldsIncludeDefault) { + GPBMessageFieldDescriptionWithDefault *fieldDescWithDefault = fieldDescriptions; + desc = &(fieldDescWithDefault[i]); + } else { + GPBMessageFieldDescription *fieldDesc = fieldDescriptions; + desc = &(fieldDesc[i]); + } + GPBFieldDescriptor *fieldDescriptor = + [[GPBFieldDescriptor alloc] initWithFieldDescription:desc + includesDefault:fieldsIncludeDefault + syntax:syntax]; + [fields addObject:fieldDescriptor]; + [fieldDescriptor release]; + } + + BOOL wireFormat = (flags & GPBDescriptorInitializationFlag_WireFormat) != 0; + GPBDescriptor *descriptor = [[self alloc] initWithClass:messageClass + file:file + fields:fields + storageSize:storageSize + wireFormat:wireFormat]; + [fields release]; + return descriptor; +} + +- (instancetype)initWithClass:(Class)messageClass + file:(GPBFileDescriptor *)file + fields:(NSArray *)fields + storageSize:(uint32_t)storageSize + wireFormat:(BOOL)wireFormat { + if ((self = [super init])) { + messageClass_ = messageClass; + file_ = file; + fields_ = [fields retain]; + storageSize_ = storageSize; + wireFormat_ = wireFormat; + } + return self; +} + +- (void)dealloc { + [fields_ release]; + [oneofs_ release]; + [super dealloc]; +} + +- (void)setupOneofs:(const char **)oneofNames + count:(uint32_t)count + firstHasIndex:(int32_t)firstHasIndex { + NSCAssert(firstHasIndex < 0, @"Should always be <0"); + NSMutableArray *oneofs = [[NSMutableArray alloc] initWithCapacity:count]; + for (uint32_t i = 0, hasIndex = firstHasIndex; i < count; ++i, --hasIndex) { + const char *name = oneofNames[i]; + NSArray *fieldsForOneof = NewFieldsArrayForHasIndex(hasIndex, fields_); + NSCAssert(fieldsForOneof.count > 0, + @"No fields for this oneof? (%s:%d)", name, hasIndex); + GPBOneofDescriptor *oneofDescriptor = + [[GPBOneofDescriptor alloc] initWithName:name fields:fieldsForOneof]; + [oneofs addObject:oneofDescriptor]; + [oneofDescriptor release]; + [fieldsForOneof release]; + } + oneofs_ = oneofs; +} + +- (void)setupExtraTextInfo:(const char *)extraTextFormatInfo { + // Extra info is a compile time option, so skip the work if not needed. + if (extraTextFormatInfo) { + NSValue *extraInfoValue = [NSValue valueWithPointer:extraTextFormatInfo]; + for (GPBFieldDescriptor *fieldDescriptor in fields_) { + if (fieldDescriptor->description_->flags & GPBFieldTextFormatNameCustom) { + objc_setAssociatedObject(fieldDescriptor, &kTextFormatExtraValueKey, + extraInfoValue, + OBJC_ASSOCIATION_RETAIN_NONATOMIC); + } + } + } +} + +- (void)setupExtensionRanges:(const GPBExtensionRange *)ranges count:(int32_t)count { + extensionRanges_ = ranges; + extensionRangesCount_ = count; +} + +- (void)setupContainingMessageClassName:(const char *)msgClassName { + // Note: Only fetch the class here, can't send messages to it because + // that could cause cycles back to this class within +initialize if + // two messages have each other in fields (i.e. - they build a graph). + NSAssert(objc_getClass(msgClassName), @"Class %s not defined", msgClassName); + NSValue *parentNameValue = [NSValue valueWithPointer:msgClassName]; + objc_setAssociatedObject(self, &kParentClassNameValueKey, + parentNameValue, + OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +- (void)setupMessageClassNameSuffix:(NSString *)suffix { + if (suffix.length) { + objc_setAssociatedObject(self, &kClassNameSuffixKey, + suffix, + OBJC_ASSOCIATION_RETAIN_NONATOMIC); + } +} + +- (NSString *)name { + return NSStringFromClass(messageClass_); +} + +- (GPBDescriptor *)containingType { + NSValue *parentNameValue = + objc_getAssociatedObject(self, &kParentClassNameValueKey); + if (!parentNameValue) { + return nil; + } + const char *parentName = [parentNameValue pointerValue]; + Class parentClass = objc_getClass(parentName); + NSAssert(parentClass, @"Class %s not defined", parentName); + return [parentClass descriptor]; +} + +- (NSString *)fullName { + NSString *className = NSStringFromClass(self.messageClass); + GPBFileDescriptor *file = self.file; + NSString *objcPrefix = file.objcPrefix; + if (objcPrefix && ![className hasPrefix:objcPrefix]) { + NSAssert(0, + @"Class didn't have correct prefix? (%@ - %@)", + className, objcPrefix); + return nil; + } + GPBDescriptor *parent = self.containingType; + + NSString *name = nil; + if (parent) { + NSString *parentClassName = NSStringFromClass(parent.messageClass); + // The generator will add _Class to avoid reserved words, drop it. + NSString *suffix = objc_getAssociatedObject(parent, &kClassNameSuffixKey); + if (suffix) { + if (![parentClassName hasSuffix:suffix]) { + NSAssert(0, + @"ParentMessage class didn't have correct suffix? (%@ - %@)", + className, suffix); + return nil; + } + parentClassName = + [parentClassName substringToIndex:(parentClassName.length - suffix.length)]; + } + NSString *parentPrefix = [parentClassName stringByAppendingString:@"_"]; + if (![className hasPrefix:parentPrefix]) { + NSAssert(0, + @"Class didn't have the correct parent name prefix? (%@ - %@)", + parentPrefix, className); + return nil; + } + name = [className substringFromIndex:parentPrefix.length]; + } else { + name = [className substringFromIndex:objcPrefix.length]; + } + + // The generator will add _Class to avoid reserved words, drop it. + NSString *suffix = objc_getAssociatedObject(self, &kClassNameSuffixKey); + if (suffix) { + if (![name hasSuffix:suffix]) { + NSAssert(0, + @"Message class didn't have correct suffix? (%@ - %@)", + name, suffix); + return nil; + } + name = [name substringToIndex:(name.length - suffix.length)]; + } + + NSString *prefix = (parent != nil ? parent.fullName : file.package); + NSString *result; + if (prefix.length > 0) { + result = [NSString stringWithFormat:@"%@.%@", prefix, name]; + } else { + result = name; + } + return result; +} + +- (id)copyWithZone:(NSZone *)zone { +#pragma unused(zone) + return [self retain]; +} + +- (GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber { + for (GPBFieldDescriptor *descriptor in fields_) { + if (GPBFieldNumber(descriptor) == fieldNumber) { + return descriptor; + } + } + return nil; +} + +- (GPBFieldDescriptor *)fieldWithName:(NSString *)name { + for (GPBFieldDescriptor *descriptor in fields_) { + if ([descriptor.name isEqual:name]) { + return descriptor; + } + } + return nil; +} + +- (GPBOneofDescriptor *)oneofWithName:(NSString *)name { + for (GPBOneofDescriptor *descriptor in oneofs_) { + if ([descriptor.name isEqual:name]) { + return descriptor; + } + } + return nil; +} + +@end + +@implementation GPBFileDescriptor { + NSString *package_; + NSString *objcPrefix_; + GPBFileSyntax syntax_; +} + +@synthesize package = package_; +@synthesize objcPrefix = objcPrefix_; +@synthesize syntax = syntax_; + +- (instancetype)initWithPackage:(NSString *)package + objcPrefix:(NSString *)objcPrefix + syntax:(GPBFileSyntax)syntax { + self = [super init]; + if (self) { + package_ = [package copy]; + objcPrefix_ = [objcPrefix copy]; + syntax_ = syntax; + } + return self; +} + +- (instancetype)initWithPackage:(NSString *)package + syntax:(GPBFileSyntax)syntax { + self = [super init]; + if (self) { + package_ = [package copy]; + syntax_ = syntax; + } + return self; +} + +- (void)dealloc { + [package_ release]; + [objcPrefix_ release]; + [super dealloc]; +} + +@end + +@implementation GPBOneofDescriptor + +@synthesize fields = fields_; + +- (instancetype)initWithName:(const char *)name fields:(NSArray *)fields { + self = [super init]; + if (self) { + name_ = name; + fields_ = [fields retain]; + for (GPBFieldDescriptor *fieldDesc in fields) { + fieldDesc->containingOneof_ = self; + } + + caseSel_ = SelFromStrings(NULL, name, "OneOfCase", NO); + } + return self; +} + +- (void)dealloc { + [fields_ release]; + [super dealloc]; +} + +- (NSString *)name { + return @(name_); +} + +- (GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber { + for (GPBFieldDescriptor *descriptor in fields_) { + if (GPBFieldNumber(descriptor) == fieldNumber) { + return descriptor; + } + } + return nil; +} + +- (GPBFieldDescriptor *)fieldWithName:(NSString *)name { + for (GPBFieldDescriptor *descriptor in fields_) { + if ([descriptor.name isEqual:name]) { + return descriptor; + } + } + return nil; +} + +@end + +uint32_t GPBFieldTag(GPBFieldDescriptor *self) { + GPBMessageFieldDescription *description = self->description_; + GPBWireFormat format; + if ((description->flags & GPBFieldMapKeyMask) != 0) { + // Maps are repeated messages on the wire. + format = GPBWireFormatForType(GPBDataTypeMessage, NO); + } else { + format = GPBWireFormatForType(description->dataType, + ((description->flags & GPBFieldPacked) != 0)); + } + return GPBWireFormatMakeTag(description->number, format); +} + +uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) { + GPBMessageFieldDescription *description = self->description_; + NSCAssert((description->flags & GPBFieldRepeated) != 0, + @"Only valid on repeated fields"); + GPBWireFormat format = + GPBWireFormatForType(description->dataType, + ((description->flags & GPBFieldPacked) == 0)); + return GPBWireFormatMakeTag(description->number, format); +} + +@implementation GPBFieldDescriptor { + GPBGenericValue defaultValue_; + + // Message ivars + Class msgClass_; + + // Enum ivars. + // If protos are generated with GenerateEnumDescriptors on then it will + // be a enumDescriptor, otherwise it will be a enumVerifier. + union { + GPBEnumDescriptor *enumDescriptor_; + GPBEnumValidationFunc enumVerifier_; + } enumHandling_; +} + +@synthesize msgClass = msgClass_; +@synthesize containingOneof = containingOneof_; + +- (instancetype)init { + // Throw an exception if people attempt to not use the designated initializer. + self = [super init]; + if (self != nil) { + [self doesNotRecognizeSelector:_cmd]; + self = nil; + } + return self; +} + +- (instancetype)initWithFieldDescription:(void *)description + includesDefault:(BOOL)includesDefault + syntax:(GPBFileSyntax)syntax { + if ((self = [super init])) { + GPBMessageFieldDescription *coreDesc; + if (includesDefault) { + coreDesc = &(((GPBMessageFieldDescriptionWithDefault *)description)->core); + } else { + coreDesc = description; + } + description_ = coreDesc; + getSel_ = sel_getUid(coreDesc->name); + setSel_ = SelFromStrings("set", coreDesc->name, NULL, YES); + + GPBDataType dataType = coreDesc->dataType; + BOOL isMessage = GPBDataTypeIsMessage(dataType); + BOOL isMapOrArray = GPBFieldIsMapOrArray(self); + + if (isMapOrArray) { + // map<>/repeated fields get a *Count property (inplace of a has*) to + // support checking if there are any entries without triggering + // autocreation. + hasOrCountSel_ = SelFromStrings(NULL, coreDesc->name, "_Count", NO); + } else { + // If there is a positive hasIndex, then: + // - All fields types for proto2 messages get has* selectors. + // - Only message fields for proto3 messages get has* selectors. + // Note: the positive check is to handle oneOfs, we can't check + // containingOneof_ because it isn't set until after initialization. + if ((coreDesc->hasIndex >= 0) && + (coreDesc->hasIndex != GPBNoHasBit) && + ((syntax != GPBFileSyntaxProto3) || isMessage)) { + hasOrCountSel_ = SelFromStrings("has", coreDesc->name, NULL, NO); + setHasSel_ = SelFromStrings("setHas", coreDesc->name, NULL, YES); + } + } + + // Extra type specific data. + if (isMessage) { + const char *className = coreDesc->dataTypeSpecific.className; + // Note: Only fetch the class here, can't send messages to it because + // that could cause cycles back to this class within +initialize if + // two messages have each other in fields (i.e. - they build a graph). + msgClass_ = objc_getClass(className); + NSAssert(msgClass_, @"Class %s not defined", className); + } else if (dataType == GPBDataTypeEnum) { + if ((coreDesc->flags & GPBFieldHasEnumDescriptor) != 0) { + enumHandling_.enumDescriptor_ = + coreDesc->dataTypeSpecific.enumDescFunc(); + } else { + enumHandling_.enumVerifier_ = + coreDesc->dataTypeSpecific.enumVerifier; + } + } + + // Non map<>/repeated fields can have defaults in proto2 syntax. + if (!isMapOrArray && includesDefault) { + defaultValue_ = ((GPBMessageFieldDescriptionWithDefault *)description)->defaultValue; + if (dataType == GPBDataTypeBytes) { + // Data stored as a length prefixed (network byte order) c-string in + // descriptor structure. + const uint8_t *bytes = (const uint8_t *)defaultValue_.valueData; + if (bytes) { + uint32_t length = *((uint32_t *)bytes); + length = ntohl(length); + bytes += sizeof(length); + defaultValue_.valueData = + [[NSData alloc] initWithBytes:bytes length:length]; + } + } + } + } + return self; +} + +- (void)dealloc { + if (description_->dataType == GPBDataTypeBytes && + !(description_->flags & GPBFieldRepeated)) { + [defaultValue_.valueData release]; + } + [super dealloc]; +} + +- (GPBDataType)dataType { + return description_->dataType; +} + +- (BOOL)hasDefaultValue { + return (description_->flags & GPBFieldHasDefaultValue) != 0; +} + +- (uint32_t)number { + return description_->number; +} + +- (NSString *)name { + return @(description_->name); +} + +- (BOOL)isRequired { + return (description_->flags & GPBFieldRequired) != 0; +} + +- (BOOL)isOptional { + return (description_->flags & GPBFieldOptional) != 0; +} + +- (GPBFieldType)fieldType { + GPBFieldFlags flags = description_->flags; + if ((flags & GPBFieldRepeated) != 0) { + return GPBFieldTypeRepeated; + } else if ((flags & GPBFieldMapKeyMask) != 0) { + return GPBFieldTypeMap; + } else { + return GPBFieldTypeSingle; + } +} + +- (GPBDataType)mapKeyDataType { + switch (description_->flags & GPBFieldMapKeyMask) { + case GPBFieldMapKeyInt32: + return GPBDataTypeInt32; + case GPBFieldMapKeyInt64: + return GPBDataTypeInt64; + case GPBFieldMapKeyUInt32: + return GPBDataTypeUInt32; + case GPBFieldMapKeyUInt64: + return GPBDataTypeUInt64; + case GPBFieldMapKeySInt32: + return GPBDataTypeSInt32; + case GPBFieldMapKeySInt64: + return GPBDataTypeSInt64; + case GPBFieldMapKeyFixed32: + return GPBDataTypeFixed32; + case GPBFieldMapKeyFixed64: + return GPBDataTypeFixed64; + case GPBFieldMapKeySFixed32: + return GPBDataTypeSFixed32; + case GPBFieldMapKeySFixed64: + return GPBDataTypeSFixed64; + case GPBFieldMapKeyBool: + return GPBDataTypeBool; + case GPBFieldMapKeyString: + return GPBDataTypeString; + + default: + NSAssert(0, @"Not a map type"); + return GPBDataTypeInt32; // For lack of anything better. + } +} + +- (BOOL)isPackable { + return (description_->flags & GPBFieldPacked) != 0; +} + +- (BOOL)isValidEnumValue:(int32_t)value { + NSAssert(description_->dataType == GPBDataTypeEnum, + @"Field Must be of type GPBDataTypeEnum"); + if (description_->flags & GPBFieldHasEnumDescriptor) { + return enumHandling_.enumDescriptor_.enumVerifier(value); + } else { + return enumHandling_.enumVerifier_(value); + } +} + +- (GPBEnumDescriptor *)enumDescriptor { + if (description_->flags & GPBFieldHasEnumDescriptor) { + return enumHandling_.enumDescriptor_; + } else { + return nil; + } +} + +- (GPBGenericValue)defaultValue { + // Depends on the fact that defaultValue_ is initialized either to "0/nil" or + // to an actual defaultValue in our initializer. + GPBGenericValue value = defaultValue_; + + if (!(description_->flags & GPBFieldRepeated)) { + // We special handle data and strings. If they are nil, we replace them + // with empty string/empty data. + GPBDataType type = description_->dataType; + if (type == GPBDataTypeBytes && value.valueData == nil) { + value.valueData = GPBEmptyNSData(); + } else if (type == GPBDataTypeString && value.valueString == nil) { + value.valueString = @""; + } + } + return value; +} + +- (NSString *)textFormatName { + if ((description_->flags & GPBFieldTextFormatNameCustom) != 0) { + NSValue *extraInfoValue = + objc_getAssociatedObject(self, &kTextFormatExtraValueKey); + // Support can be left out at generation time. + if (!extraInfoValue) { + return nil; + } + const uint8_t *extraTextFormatInfo = [extraInfoValue pointerValue]; + return GPBDecodeTextFormatName(extraTextFormatInfo, GPBFieldNumber(self), + self.name); + } + + // The logic here has to match SetCommonFieldVariables() from + // objectivec_field.cc in the proto compiler. + NSString *name = self.name; + NSUInteger len = [name length]; + + // Remove the "_p" added to reserved names. + if ([name hasSuffix:@"_p"]) { + name = [name substringToIndex:(len - 2)]; + len = [name length]; + } + + // Remove "Array" from the end for repeated fields. + if (((description_->flags & GPBFieldRepeated) != 0) && + [name hasSuffix:@"Array"]) { + name = [name substringToIndex:(len - 5)]; + len = [name length]; + } + + // Groups vs. other fields. + if (description_->dataType == GPBDataTypeGroup) { + // Just capitalize the first letter. + unichar firstChar = [name characterAtIndex:0]; + if (firstChar >= 'a' && firstChar <= 'z') { + NSString *firstCharString = + [NSString stringWithFormat:@"%C", (unichar)(firstChar - 'a' + 'A')]; + NSString *result = + [name stringByReplacingCharactersInRange:NSMakeRange(0, 1) + withString:firstCharString]; + return result; + } + return name; + + } else { + // Undo the CamelCase. + NSMutableString *result = [NSMutableString stringWithCapacity:len]; + for (uint32_t i = 0; i < len; i++) { + unichar c = [name characterAtIndex:i]; + if (c >= 'A' && c <= 'Z') { + if (i > 0) { + [result appendFormat:@"_%C", (unichar)(c - 'A' + 'a')]; + } else { + [result appendFormat:@"%C", c]; + } + } else { + [result appendFormat:@"%C", c]; + } + } + return result; + } +} + +@end + +@implementation GPBEnumDescriptor { + NSString *name_; + // valueNames_ is a single c string with all of the value names appended + // together, each null terminated. -calcValueNameOffsets fills in + // nameOffsets_ with the offsets to allow quicker access to the individual + // names. + const char *valueNames_; + const int32_t *values_; + GPBEnumValidationFunc enumVerifier_; + const uint8_t *extraTextFormatInfo_; + uint32_t *nameOffsets_; + uint32_t valueCount_; +} + +@synthesize name = name_; +@synthesize enumVerifier = enumVerifier_; + ++ (instancetype) + allocDescriptorForName:(NSString *)name + valueNames:(const char *)valueNames + values:(const int32_t *)values + count:(uint32_t)valueCount + enumVerifier:(GPBEnumValidationFunc)enumVerifier { + GPBEnumDescriptor *descriptor = [[self alloc] initWithName:name + valueNames:valueNames + values:values + count:valueCount + enumVerifier:enumVerifier]; + return descriptor; +} + ++ (instancetype) + allocDescriptorForName:(NSString *)name + valueNames:(const char *)valueNames + values:(const int32_t *)values + count:(uint32_t)valueCount + enumVerifier:(GPBEnumValidationFunc)enumVerifier + extraTextFormatInfo:(const char *)extraTextFormatInfo { + // Call the common case. + GPBEnumDescriptor *descriptor = [self allocDescriptorForName:name + valueNames:valueNames + values:values + count:valueCount + enumVerifier:enumVerifier]; + // Set the extra info. + descriptor->extraTextFormatInfo_ = (const uint8_t *)extraTextFormatInfo; + return descriptor; +} + +- (instancetype)initWithName:(NSString *)name + valueNames:(const char *)valueNames + values:(const int32_t *)values + count:(uint32_t)valueCount + enumVerifier:(GPBEnumValidationFunc)enumVerifier { + if ((self = [super init])) { + name_ = [name copy]; + valueNames_ = valueNames; + values_ = values; + valueCount_ = valueCount; + enumVerifier_ = enumVerifier; + } + return self; +} + +- (void)dealloc { + [name_ release]; + if (nameOffsets_) free(nameOffsets_); + [super dealloc]; +} + +- (void)calcValueNameOffsets { + @synchronized(self) { + if (nameOffsets_ != NULL) { + return; + } + uint32_t *offsets = malloc(valueCount_ * sizeof(uint32_t)); + const char *scan = valueNames_; + for (uint32_t i = 0; i < valueCount_; ++i) { + offsets[i] = (uint32_t)(scan - valueNames_); + while (*scan != '\0') ++scan; + ++scan; // Step over the null. + } + nameOffsets_ = offsets; + } +} + +- (NSString *)enumNameForValue:(int32_t)number { + if (nameOffsets_ == NULL) [self calcValueNameOffsets]; + + for (uint32_t i = 0; i < valueCount_; ++i) { + if (values_[i] == number) { + const char *valueName = valueNames_ + nameOffsets_[i]; + NSString *fullName = [NSString stringWithFormat:@"%@_%s", name_, valueName]; + return fullName; + } + } + return nil; +} + +- (BOOL)getValue:(int32_t *)outValue forEnumName:(NSString *)name { + // Must have the prefix. + NSUInteger prefixLen = name_.length + 1; + if ((name.length <= prefixLen) || ![name hasPrefix:name_] || + ([name characterAtIndex:prefixLen - 1] != '_')) { + return NO; + } + + // Skip over the prefix. + const char *nameAsCStr = [name UTF8String]; + nameAsCStr += prefixLen; + + if (nameOffsets_ == NULL) [self calcValueNameOffsets]; + + // Find it. + for (uint32_t i = 0; i < valueCount_; ++i) { + const char *valueName = valueNames_ + nameOffsets_[i]; + if (strcmp(nameAsCStr, valueName) == 0) { + if (outValue) { + *outValue = values_[i]; + } + return YES; + } + } + return NO; +} + +- (BOOL)getValue:(int32_t *)outValue forEnumTextFormatName:(NSString *)textFormatName { + if (nameOffsets_ == NULL) [self calcValueNameOffsets]; + + for (uint32_t i = 0; i < valueCount_; ++i) { + int32_t value = values_[i]; + NSString *valueTextFormatName = [self textFormatNameForValue:value]; + if ([valueTextFormatName isEqual:textFormatName]) { + if (outValue) { + *outValue = value; + } + return YES; + } + } + return NO; +} + +- (NSString *)textFormatNameForValue:(int32_t)number { + if (nameOffsets_ == NULL) [self calcValueNameOffsets]; + + // Find the EnumValue descriptor and its index. + BOOL foundIt = NO; + uint32_t valueDescriptorIndex; + for (valueDescriptorIndex = 0; valueDescriptorIndex < valueCount_; + ++valueDescriptorIndex) { + if (values_[valueDescriptorIndex] == number) { + foundIt = YES; + break; + } + } + + if (!foundIt) { + return nil; + } + + NSString *result = nil; + // Naming adds an underscore between enum name and value name, skip that also. + const char *valueName = valueNames_ + nameOffsets_[valueDescriptorIndex]; + NSString *shortName = @(valueName); + + // See if it is in the map of special format handling. + if (extraTextFormatInfo_) { + result = GPBDecodeTextFormatName(extraTextFormatInfo_, + (int32_t)valueDescriptorIndex, shortName); + } + // Logic here needs to match what objectivec_enum.cc does in the proto + // compiler. + if (result == nil) { + NSUInteger len = [shortName length]; + NSMutableString *worker = [NSMutableString stringWithCapacity:len]; + for (NSUInteger i = 0; i < len; i++) { + unichar c = [shortName characterAtIndex:i]; + if (i > 0 && c >= 'A' && c <= 'Z') { + [worker appendString:@"_"]; + } + [worker appendFormat:@"%c", toupper((char)c)]; + } + result = worker; + } + return result; +} + +@end + +@implementation GPBExtensionDescriptor { + GPBGenericValue defaultValue_; +} + +@synthesize containingMessageClass = containingMessageClass_; + +- (instancetype)initWithExtensionDescription: + (GPBExtensionDescription *)description { + if ((self = [super init])) { + description_ = description; + +#if defined(DEBUG) && DEBUG + const char *className = description->messageOrGroupClassName; + if (className) { + NSAssert(objc_lookUpClass(className) != Nil, + @"Class %s not defined", className); + } +#endif + + if (description->extendedClass) { + Class containingClass = objc_lookUpClass(description->extendedClass); + NSAssert(containingClass, @"Class %s not defined", + description->extendedClass); + containingMessageClass_ = containingClass; + } + + GPBDataType type = description_->dataType; + if (type == GPBDataTypeBytes) { + // Data stored as a length prefixed c-string in descriptor records. + const uint8_t *bytes = + (const uint8_t *)description->defaultValue.valueData; + if (bytes) { + uint32_t length = *((uint32_t *)bytes); + // The length is stored in network byte order. + length = ntohl(length); + bytes += sizeof(length); + defaultValue_.valueData = + [[NSData alloc] initWithBytes:bytes length:length]; + } + } else if (type == GPBDataTypeMessage || type == GPBDataTypeGroup) { + // The default is looked up in -defaultValue instead since extensions + // aren't common, we avoid the hit startup hit and it avoid initialization + // order issues. + } else { + defaultValue_ = description->defaultValue; + } + } + return self; +} + +- (void)dealloc { + if ((description_->dataType == GPBDataTypeBytes) && + !GPBExtensionIsRepeated(description_)) { + [defaultValue_.valueData release]; + } + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { +#pragma unused(zone) + // Immutable. + return [self retain]; +} + +- (NSString *)singletonName { + return @(description_->singletonName); +} + +- (const char *)singletonNameC { + return description_->singletonName; +} + +- (uint32_t)fieldNumber { + return description_->fieldNumber; +} + +- (GPBDataType)dataType { + return description_->dataType; +} + +- (GPBWireFormat)wireType { + return GPBWireFormatForType(description_->dataType, + GPBExtensionIsPacked(description_)); +} + +- (GPBWireFormat)alternateWireType { + NSAssert(GPBExtensionIsRepeated(description_), + @"Only valid on repeated extensions"); + return GPBWireFormatForType(description_->dataType, + !GPBExtensionIsPacked(description_)); +} + +- (BOOL)isRepeated { + return GPBExtensionIsRepeated(description_); +} + +- (BOOL)isPackable { + return GPBExtensionIsPacked(description_); +} + +- (Class)msgClass { + return objc_getClass(description_->messageOrGroupClassName); +} + +- (GPBEnumDescriptor *)enumDescriptor { + if (description_->dataType == GPBDataTypeEnum) { + GPBEnumDescriptor *enumDescriptor = description_->enumDescriptorFunc(); + return enumDescriptor; + } + return nil; +} + +- (id)defaultValue { + if (GPBExtensionIsRepeated(description_)) { + return nil; + } + + switch (description_->dataType) { + case GPBDataTypeBool: + return @(defaultValue_.valueBool); + case GPBDataTypeFloat: + return @(defaultValue_.valueFloat); + case GPBDataTypeDouble: + return @(defaultValue_.valueDouble); + case GPBDataTypeInt32: + case GPBDataTypeSInt32: + case GPBDataTypeEnum: + case GPBDataTypeSFixed32: + return @(defaultValue_.valueInt32); + case GPBDataTypeInt64: + case GPBDataTypeSInt64: + case GPBDataTypeSFixed64: + return @(defaultValue_.valueInt64); + case GPBDataTypeUInt32: + case GPBDataTypeFixed32: + return @(defaultValue_.valueUInt32); + case GPBDataTypeUInt64: + case GPBDataTypeFixed64: + return @(defaultValue_.valueUInt64); + case GPBDataTypeBytes: + // Like message fields, the default is zero length data. + return (defaultValue_.valueData ? defaultValue_.valueData + : GPBEmptyNSData()); + case GPBDataTypeString: + // Like message fields, the default is zero length string. + return (defaultValue_.valueString ? defaultValue_.valueString : @""); + case GPBDataTypeGroup: + case GPBDataTypeMessage: + return nil; + } +} + +- (NSComparisonResult)compareByFieldNumber:(GPBExtensionDescriptor *)other { + int32_t selfNumber = description_->fieldNumber; + int32_t otherNumber = other->description_->fieldNumber; + if (selfNumber < otherNumber) { + return NSOrderedAscending; + } else if (selfNumber == otherNumber) { + return NSOrderedSame; + } else { + return NSOrderedDescending; + } +} + +@end + +#pragma clang diagnostic pop diff --git a/Pods/Protobuf/objectivec/GPBDescriptor_PackagePrivate.h b/Pods/Protobuf/objectivec/GPBDescriptor_PackagePrivate.h new file mode 100644 index 0000000..452b3f8 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBDescriptor_PackagePrivate.h @@ -0,0 +1,325 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// This header is private to the ProtobolBuffers library and must NOT be +// included by any sources outside this library. The contents of this file are +// subject to change at any time without notice. + +#import "GPBDescriptor.h" +#import "GPBWireFormat.h" + +// Describes attributes of the field. +typedef NS_OPTIONS(uint16_t, GPBFieldFlags) { + GPBFieldNone = 0, + // These map to standard protobuf concepts. + GPBFieldRequired = 1 << 0, + GPBFieldRepeated = 1 << 1, + GPBFieldPacked = 1 << 2, + GPBFieldOptional = 1 << 3, + GPBFieldHasDefaultValue = 1 << 4, + + // Indicates the field needs custom handling for the TextFormat name, if not + // set, the name can be derived from the ObjC name. + GPBFieldTextFormatNameCustom = 1 << 6, + // Indicates the field has an enum descriptor. + GPBFieldHasEnumDescriptor = 1 << 7, + + // These are not standard protobuf concepts, they are specific to the + // Objective C runtime. + + // These bits are used to mark the field as a map and what the key + // type is. + GPBFieldMapKeyMask = 0xF << 8, + GPBFieldMapKeyInt32 = 1 << 8, + GPBFieldMapKeyInt64 = 2 << 8, + GPBFieldMapKeyUInt32 = 3 << 8, + GPBFieldMapKeyUInt64 = 4 << 8, + GPBFieldMapKeySInt32 = 5 << 8, + GPBFieldMapKeySInt64 = 6 << 8, + GPBFieldMapKeyFixed32 = 7 << 8, + GPBFieldMapKeyFixed64 = 8 << 8, + GPBFieldMapKeySFixed32 = 9 << 8, + GPBFieldMapKeySFixed64 = 10 << 8, + GPBFieldMapKeyBool = 11 << 8, + GPBFieldMapKeyString = 12 << 8, +}; + +// NOTE: The structures defined here have their members ordered to minimize +// their size. This directly impacts the size of apps since these exist per +// field/extension. + +// Describes a single field in a protobuf as it is represented as an ivar. +typedef struct GPBMessageFieldDescription { + // Name of ivar. + const char *name; + union { + const char *className; // Name for message class. + // For enums only: If EnumDescriptors are compiled in, it will be that, + // otherwise it will be the verifier. + GPBEnumDescriptorFunc enumDescFunc; + GPBEnumValidationFunc enumVerifier; + } dataTypeSpecific; + // The field number for the ivar. + uint32_t number; + // The index (in bits) into _has_storage_. + // >= 0: the bit to use for a value being set. + // = GPBNoHasBit(INT32_MAX): no storage used. + // < 0: in a oneOf, use a full int32 to record the field active. + int32_t hasIndex; + // Offset of the variable into it's structure struct. + uint32_t offset; + // Field flags. Use accessor functions below. + GPBFieldFlags flags; + // Data type of the ivar. + GPBDataType dataType; +} GPBMessageFieldDescription; + +// Fields in messages defined in a 'proto2' syntax file can provide a default +// value. This struct provides the default along with the field info. +typedef struct GPBMessageFieldDescriptionWithDefault { + // Default value for the ivar. + GPBGenericValue defaultValue; + + GPBMessageFieldDescription core; +} GPBMessageFieldDescriptionWithDefault; + +// Describes attributes of the extension. +typedef NS_OPTIONS(uint8_t, GPBExtensionOptions) { + GPBExtensionNone = 0, + // These map to standard protobuf concepts. + GPBExtensionRepeated = 1 << 0, + GPBExtensionPacked = 1 << 1, + GPBExtensionSetWireFormat = 1 << 2, +}; + +// An extension +typedef struct GPBExtensionDescription { + GPBGenericValue defaultValue; + const char *singletonName; + const char *extendedClass; + const char *messageOrGroupClassName; + GPBEnumDescriptorFunc enumDescriptorFunc; + int32_t fieldNumber; + GPBDataType dataType; + GPBExtensionOptions options; +} GPBExtensionDescription; + +typedef NS_OPTIONS(uint32_t, GPBDescriptorInitializationFlags) { + GPBDescriptorInitializationFlag_None = 0, + GPBDescriptorInitializationFlag_FieldsWithDefault = 1 << 0, + GPBDescriptorInitializationFlag_WireFormat = 1 << 1, +}; + +@interface GPBDescriptor () { + @package + NSArray *fields_; + NSArray *oneofs_; + uint32_t storageSize_; +} + +// fieldDescriptions have to be long lived, they are held as raw pointers. ++ (instancetype) + allocDescriptorForClass:(Class)messageClass + rootClass:(Class)rootClass + file:(GPBFileDescriptor *)file + fields:(void *)fieldDescriptions + fieldCount:(uint32_t)fieldCount + storageSize:(uint32_t)storageSize + flags:(GPBDescriptorInitializationFlags)flags; + +- (instancetype)initWithClass:(Class)messageClass + file:(GPBFileDescriptor *)file + fields:(NSArray *)fields + storageSize:(uint32_t)storage + wireFormat:(BOOL)wireFormat; + +// Called right after init to provide extra information to avoid init having +// an explosion of args. These pointers are recorded, so they are expected +// to live for the lifetime of the app. +- (void)setupOneofs:(const char **)oneofNames + count:(uint32_t)count + firstHasIndex:(int32_t)firstHasIndex; +- (void)setupExtraTextInfo:(const char *)extraTextFormatInfo; +- (void)setupExtensionRanges:(const GPBExtensionRange *)ranges count:(int32_t)count; +- (void)setupContainingMessageClassName:(const char *)msgClassName; +- (void)setupMessageClassNameSuffix:(NSString *)suffix; + +@end + +@interface GPBFileDescriptor () +- (instancetype)initWithPackage:(NSString *)package + objcPrefix:(NSString *)objcPrefix + syntax:(GPBFileSyntax)syntax; +- (instancetype)initWithPackage:(NSString *)package + syntax:(GPBFileSyntax)syntax; +@end + +@interface GPBOneofDescriptor () { + @package + const char *name_; + NSArray *fields_; + SEL caseSel_; +} +// name must be long lived. +- (instancetype)initWithName:(const char *)name fields:(NSArray *)fields; +@end + +@interface GPBFieldDescriptor () { + @package + GPBMessageFieldDescription *description_; + GPB_UNSAFE_UNRETAINED GPBOneofDescriptor *containingOneof_; + + SEL getSel_; + SEL setSel_; + SEL hasOrCountSel_; // *Count for map<>/repeated fields, has* otherwise. + SEL setHasSel_; +} + +// Single initializer +// description has to be long lived, it is held as a raw pointer. +- (instancetype)initWithFieldDescription:(void *)description + includesDefault:(BOOL)includesDefault + syntax:(GPBFileSyntax)syntax; +@end + +@interface GPBEnumDescriptor () +// valueNames, values and extraTextFormatInfo have to be long lived, they are +// held as raw pointers. ++ (instancetype) + allocDescriptorForName:(NSString *)name + valueNames:(const char *)valueNames + values:(const int32_t *)values + count:(uint32_t)valueCount + enumVerifier:(GPBEnumValidationFunc)enumVerifier; ++ (instancetype) + allocDescriptorForName:(NSString *)name + valueNames:(const char *)valueNames + values:(const int32_t *)values + count:(uint32_t)valueCount + enumVerifier:(GPBEnumValidationFunc)enumVerifier + extraTextFormatInfo:(const char *)extraTextFormatInfo; + +- (instancetype)initWithName:(NSString *)name + valueNames:(const char *)valueNames + values:(const int32_t *)values + count:(uint32_t)valueCount + enumVerifier:(GPBEnumValidationFunc)enumVerifier; +@end + +@interface GPBExtensionDescriptor () { + @package + GPBExtensionDescription *description_; +} +@property(nonatomic, readonly) GPBWireFormat wireType; + +// For repeated extensions, alternateWireType is the wireType with the opposite +// value for the packable property. i.e. - if the extension was marked packed +// it would be the wire type for unpacked; if the extension was marked unpacked, +// it would be the wire type for packed. +@property(nonatomic, readonly) GPBWireFormat alternateWireType; + +// description has to be long lived, it is held as a raw pointer. +- (instancetype)initWithExtensionDescription: + (GPBExtensionDescription *)description; +- (NSComparisonResult)compareByFieldNumber:(GPBExtensionDescriptor *)other; +@end + +CF_EXTERN_C_BEGIN + +// Direct access is use for speed, to avoid even internally declaring things +// read/write, etc. The warning is enabled in the project to ensure code calling +// protos can turn on -Wdirect-ivar-access without issues. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdirect-ivar-access" + +GPB_INLINE BOOL GPBFieldIsMapOrArray(GPBFieldDescriptor *field) { + return (field->description_->flags & + (GPBFieldRepeated | GPBFieldMapKeyMask)) != 0; +} + +GPB_INLINE GPBDataType GPBGetFieldDataType(GPBFieldDescriptor *field) { + return field->description_->dataType; +} + +GPB_INLINE int32_t GPBFieldHasIndex(GPBFieldDescriptor *field) { + return field->description_->hasIndex; +} + +GPB_INLINE uint32_t GPBFieldNumber(GPBFieldDescriptor *field) { + return field->description_->number; +} + +#pragma clang diagnostic pop + +uint32_t GPBFieldTag(GPBFieldDescriptor *self); + +// For repeated fields, alternateWireType is the wireType with the opposite +// value for the packable property. i.e. - if the field was marked packed it +// would be the wire type for unpacked; if the field was marked unpacked, it +// would be the wire type for packed. +uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self); + +GPB_INLINE BOOL GPBHasPreservingUnknownEnumSemantics(GPBFileSyntax syntax) { + return syntax == GPBFileSyntaxProto3; +} + +GPB_INLINE BOOL GPBExtensionIsRepeated(GPBExtensionDescription *description) { + return (description->options & GPBExtensionRepeated) != 0; +} + +GPB_INLINE BOOL GPBExtensionIsPacked(GPBExtensionDescription *description) { + return (description->options & GPBExtensionPacked) != 0; +} + +GPB_INLINE BOOL GPBExtensionIsWireFormat(GPBExtensionDescription *description) { + return (description->options & GPBExtensionSetWireFormat) != 0; +} + +// Helper for compile time assets. +#ifndef GPBInternalCompileAssert + #if __has_feature(c_static_assert) || __has_extension(c_static_assert) + #define GPBInternalCompileAssert(test, msg) _Static_assert((test), #msg) + #else + // Pre-Xcode 7 support. + #define GPBInternalCompileAssertSymbolInner(line, msg) GPBInternalCompileAssert ## line ## __ ## msg + #define GPBInternalCompileAssertSymbol(line, msg) GPBInternalCompileAssertSymbolInner(line, msg) + #define GPBInternalCompileAssert(test, msg) \ + typedef char GPBInternalCompileAssertSymbol(__LINE__, msg) [ ((test) ? 1 : -1) ] + #endif // __has_feature(c_static_assert) || __has_extension(c_static_assert) +#endif // GPBInternalCompileAssert + +// Sanity check that there isn't padding between the field description +// structures with and without a default. +GPBInternalCompileAssert(sizeof(GPBMessageFieldDescriptionWithDefault) == + (sizeof(GPBGenericValue) + + sizeof(GPBMessageFieldDescription)), + DescriptionsWithDefault_different_size_than_expected); + +CF_EXTERN_C_END diff --git a/Pods/Protobuf/objectivec/GPBDictionary.h b/Pods/Protobuf/objectivec/GPBDictionary.h new file mode 100644 index 0000000..9d67415 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBDictionary.h @@ -0,0 +1,8570 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import + +#import "GPBRuntimeTypes.h" + +// Note on naming: for the classes holding numeric values, a more natural +// naming of the method might be things like "-valueForKey:", +// "-setValue:forKey:"; etc. But those selectors are also defined by Key Value +// Coding (KVC) as categories on NSObject. So "overloading" the selectors with +// other meanings can cause warnings (based on compiler settings), but more +// importantly, some of those selector get called as KVC breaks up keypaths. +// So if those selectors are used, using KVC will compile cleanly, but could +// crash as it invokes those selectors with the wrong types of arguments. + +NS_ASSUME_NONNULL_BEGIN + +//%PDDM-EXPAND DECLARE_DICTIONARIES() +// This block of code is generated, do not edit it directly. + +#pragma mark - UInt32 -> UInt32 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBUInt32UInt32Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithUInt32:(uint32_t)value + forKey:(uint32_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithUInt32s:(const uint32_t [__nullable])values + forKeys:(const uint32_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBUInt32UInt32Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values + forKeys:(const uint32_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBUInt32UInt32Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(uint32_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndUInt32sUsingBlock: + (void (^)(uint32_t key, uint32_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBUInt32UInt32Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setUInt32:(uint32_t)value forKey:(uint32_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeUInt32ForKey:(uint32_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - UInt32 -> Int32 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBUInt32Int32Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithInt32:(int32_t)value + forKey:(uint32_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithInt32s:(const int32_t [__nullable])values + forKeys:(const uint32_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBUInt32Int32Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithInt32s:(const int32_t [__nullable])values + forKeys:(const uint32_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBUInt32Int32Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getInt32:(nullable int32_t *)value forKey:(uint32_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndInt32sUsingBlock: + (void (^)(uint32_t key, int32_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBUInt32Int32Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setInt32:(int32_t)value forKey:(uint32_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeInt32ForKey:(uint32_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - UInt32 -> UInt64 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBUInt32UInt64Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithUInt64:(uint64_t)value + forKey:(uint32_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithUInt64s:(const uint64_t [__nullable])values + forKeys:(const uint32_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBUInt32UInt64Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values + forKeys:(const uint32_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBUInt32UInt64Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(uint32_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndUInt64sUsingBlock: + (void (^)(uint32_t key, uint64_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBUInt32UInt64Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setUInt64:(uint64_t)value forKey:(uint32_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeUInt64ForKey:(uint32_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - UInt32 -> Int64 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBUInt32Int64Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithInt64:(int64_t)value + forKey:(uint32_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithInt64s:(const int64_t [__nullable])values + forKeys:(const uint32_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBUInt32Int64Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithInt64s:(const int64_t [__nullable])values + forKeys:(const uint32_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBUInt32Int64Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getInt64:(nullable int64_t *)value forKey:(uint32_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndInt64sUsingBlock: + (void (^)(uint32_t key, int64_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBUInt32Int64Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setInt64:(int64_t)value forKey:(uint32_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeInt64ForKey:(uint32_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - UInt32 -> Bool + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBUInt32BoolDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithBool:(BOOL)value + forKey:(uint32_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithBools:(const BOOL [__nullable])values + forKeys:(const uint32_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBUInt32BoolDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithBools:(const BOOL [__nullable])values + forKeys:(const uint32_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBUInt32BoolDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getBool:(nullable BOOL *)value forKey:(uint32_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndBoolsUsingBlock: + (void (^)(uint32_t key, BOOL value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBUInt32BoolDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setBool:(BOOL)value forKey:(uint32_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeBoolForKey:(uint32_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - UInt32 -> Float + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBUInt32FloatDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithFloat:(float)value + forKey:(uint32_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithFloats:(const float [__nullable])values + forKeys:(const uint32_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBUInt32FloatDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithFloats:(const float [__nullable])values + forKeys:(const uint32_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBUInt32FloatDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getFloat:(nullable float *)value forKey:(uint32_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndFloatsUsingBlock: + (void (^)(uint32_t key, float value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBUInt32FloatDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setFloat:(float)value forKey:(uint32_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeFloatForKey:(uint32_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - UInt32 -> Double + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBUInt32DoubleDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithDouble:(double)value + forKey:(uint32_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithDoubles:(const double [__nullable])values + forKeys:(const uint32_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBUInt32DoubleDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithDoubles:(const double [__nullable])values + forKeys:(const uint32_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBUInt32DoubleDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getDouble:(nullable double *)value forKey:(uint32_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndDoublesUsingBlock: + (void (^)(uint32_t key, double value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBUInt32DoubleDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setDouble:(double)value forKey:(uint32_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeDoubleForKey:(uint32_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - UInt32 -> Enum + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBUInt32EnumDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; +/** The validation function to check if the enums are valid. */ +@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the given validation function. + * + * @param func The enum validation function for the dictionary. + * + * @return A newly instanced dictionary. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param func The enum validation function for the dictionary. + * @param rawValue The raw enum value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func + rawValue:(int32_t)rawValue + forKey:(uint32_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param func The enum validation function for the dictionary. + * @param values The raw enum values values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func + rawValues:(const int32_t [__nullable])values + forKeys:(const uint32_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBUInt32EnumDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param func The enum validation function for the dictionary. + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems; + +/** + * Initializes a dictionary with the given validation function. + * + * @param func The enum validation function for the dictionary. + * + * @return A newly initialized dictionary. + **/ +- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func; + +/** + * Initializes a dictionary with the entries given. + * + * @param func The enum validation function for the dictionary. + * @param values The raw enum values values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly initialized dictionary with the keys and values in it. + **/ +- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func + rawValues:(const int32_t [__nullable])values + forKeys:(const uint32_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly initialized dictionary with the entries from the given + * dictionary in it. + **/ +- (instancetype)initWithDictionary:(GPBUInt32EnumDictionary *)dictionary; + +/** + * Initializes a dictionary with the given capacity. + * + * @param func The enum validation function for the dictionary. + * @param numItems Capacity needed for the dictionary. + * + * @return A newly initialized dictionary with the given capacity. + **/ +- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems; + +// These will return kGPBUnrecognizedEnumeratorValue if the value for the key +// is not a valid enumerator as defined by validationFunc. If the actual value is +// desired, use "raw" version of the method. + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getEnum:(nullable int32_t *)value forKey:(uint32_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndEnumsUsingBlock: + (void (^)(uint32_t key, int32_t value, BOOL *stop))block; + +/** + * Gets the raw enum value for the given key. + * + * @note This method bypass the validationFunc to enable the access of values that + * were not known at the time the binary was compiled. + * + * @param rawValue Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(uint32_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @note This method bypass the validationFunc to enable the access of values that + * were not known at the time the binary was compiled. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **rawValue**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndRawValuesUsingBlock: + (void (^)(uint32_t key, int32_t rawValue, BOOL *stop))block; + +/** + * Adds the keys and raw enum values from another dictionary. + * + * @note This method bypass the validationFunc to enable the setting of values that + * were not known at the time the binary was compiled. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addRawEntriesFromDictionary:(GPBUInt32EnumDictionary *)otherDictionary; + +// If value is not a valid enumerator as defined by validationFunc, these +// methods will assert in debug, and will log in release and assign the value +// to the default value. Use the rawValue methods below to assign non enumerator +// values. + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setEnum:(int32_t)value forKey:(uint32_t)key; + +/** + * Sets the raw enum value for the given key. + * + * @note This method bypass the validationFunc to enable the setting of values that + * were not known at the time the binary was compiled. + * + * @param rawValue The raw enum value to set. + * @param key The key under which to store the raw enum value. + **/ +- (void)setRawValue:(int32_t)rawValue forKey:(uint32_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeEnumForKey:(uint32_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - UInt32 -> Object + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBUInt32ObjectDictionary<__covariant ObjectType> : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param object The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithObject:(ObjectType)object + forKey:(uint32_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param objects The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects + forKeys:(const uint32_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBUInt32ObjectDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param objects The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects + forKeys:(const uint32_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBUInt32ObjectDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Fetches the object stored under the given key. + * + * @param key Key under which the value is stored, if present. + * + * @return The object if found, nil otherwise. + **/ +- (ObjectType)objectForKey:(uint32_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **object**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndObjectsUsingBlock: + (void (^)(uint32_t key, ObjectType object, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBUInt32ObjectDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param object The value to set. + * @param key The key under which to store the value. + **/ +- (void)setObject:(ObjectType)object forKey:(uint32_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeObjectForKey:(uint32_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Int32 -> UInt32 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBInt32UInt32Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithUInt32:(uint32_t)value + forKey:(int32_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithUInt32s:(const uint32_t [__nullable])values + forKeys:(const int32_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBInt32UInt32Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values + forKeys:(const int32_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBInt32UInt32Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(int32_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndUInt32sUsingBlock: + (void (^)(int32_t key, uint32_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBInt32UInt32Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setUInt32:(uint32_t)value forKey:(int32_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeUInt32ForKey:(int32_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Int32 -> Int32 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBInt32Int32Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithInt32:(int32_t)value + forKey:(int32_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithInt32s:(const int32_t [__nullable])values + forKeys:(const int32_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBInt32Int32Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithInt32s:(const int32_t [__nullable])values + forKeys:(const int32_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBInt32Int32Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getInt32:(nullable int32_t *)value forKey:(int32_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndInt32sUsingBlock: + (void (^)(int32_t key, int32_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBInt32Int32Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setInt32:(int32_t)value forKey:(int32_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeInt32ForKey:(int32_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Int32 -> UInt64 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBInt32UInt64Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithUInt64:(uint64_t)value + forKey:(int32_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithUInt64s:(const uint64_t [__nullable])values + forKeys:(const int32_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBInt32UInt64Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values + forKeys:(const int32_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBInt32UInt64Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(int32_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndUInt64sUsingBlock: + (void (^)(int32_t key, uint64_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBInt32UInt64Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setUInt64:(uint64_t)value forKey:(int32_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeUInt64ForKey:(int32_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Int32 -> Int64 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBInt32Int64Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithInt64:(int64_t)value + forKey:(int32_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithInt64s:(const int64_t [__nullable])values + forKeys:(const int32_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBInt32Int64Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithInt64s:(const int64_t [__nullable])values + forKeys:(const int32_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBInt32Int64Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getInt64:(nullable int64_t *)value forKey:(int32_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndInt64sUsingBlock: + (void (^)(int32_t key, int64_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBInt32Int64Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setInt64:(int64_t)value forKey:(int32_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeInt64ForKey:(int32_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Int32 -> Bool + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBInt32BoolDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithBool:(BOOL)value + forKey:(int32_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithBools:(const BOOL [__nullable])values + forKeys:(const int32_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBInt32BoolDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithBools:(const BOOL [__nullable])values + forKeys:(const int32_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBInt32BoolDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getBool:(nullable BOOL *)value forKey:(int32_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndBoolsUsingBlock: + (void (^)(int32_t key, BOOL value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBInt32BoolDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setBool:(BOOL)value forKey:(int32_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeBoolForKey:(int32_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Int32 -> Float + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBInt32FloatDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithFloat:(float)value + forKey:(int32_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithFloats:(const float [__nullable])values + forKeys:(const int32_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBInt32FloatDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithFloats:(const float [__nullable])values + forKeys:(const int32_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBInt32FloatDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getFloat:(nullable float *)value forKey:(int32_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndFloatsUsingBlock: + (void (^)(int32_t key, float value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBInt32FloatDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setFloat:(float)value forKey:(int32_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeFloatForKey:(int32_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Int32 -> Double + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBInt32DoubleDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithDouble:(double)value + forKey:(int32_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithDoubles:(const double [__nullable])values + forKeys:(const int32_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBInt32DoubleDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithDoubles:(const double [__nullable])values + forKeys:(const int32_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBInt32DoubleDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getDouble:(nullable double *)value forKey:(int32_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndDoublesUsingBlock: + (void (^)(int32_t key, double value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBInt32DoubleDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setDouble:(double)value forKey:(int32_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeDoubleForKey:(int32_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Int32 -> Enum + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBInt32EnumDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; +/** The validation function to check if the enums are valid. */ +@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the given validation function. + * + * @param func The enum validation function for the dictionary. + * + * @return A newly instanced dictionary. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param func The enum validation function for the dictionary. + * @param rawValue The raw enum value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func + rawValue:(int32_t)rawValue + forKey:(int32_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param func The enum validation function for the dictionary. + * @param values The raw enum values values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func + rawValues:(const int32_t [__nullable])values + forKeys:(const int32_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBInt32EnumDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param func The enum validation function for the dictionary. + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems; + +/** + * Initializes a dictionary with the given validation function. + * + * @param func The enum validation function for the dictionary. + * + * @return A newly initialized dictionary. + **/ +- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func; + +/** + * Initializes a dictionary with the entries given. + * + * @param func The enum validation function for the dictionary. + * @param values The raw enum values values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly initialized dictionary with the keys and values in it. + **/ +- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func + rawValues:(const int32_t [__nullable])values + forKeys:(const int32_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly initialized dictionary with the entries from the given + * dictionary in it. + **/ +- (instancetype)initWithDictionary:(GPBInt32EnumDictionary *)dictionary; + +/** + * Initializes a dictionary with the given capacity. + * + * @param func The enum validation function for the dictionary. + * @param numItems Capacity needed for the dictionary. + * + * @return A newly initialized dictionary with the given capacity. + **/ +- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems; + +// These will return kGPBUnrecognizedEnumeratorValue if the value for the key +// is not a valid enumerator as defined by validationFunc. If the actual value is +// desired, use "raw" version of the method. + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getEnum:(nullable int32_t *)value forKey:(int32_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndEnumsUsingBlock: + (void (^)(int32_t key, int32_t value, BOOL *stop))block; + +/** + * Gets the raw enum value for the given key. + * + * @note This method bypass the validationFunc to enable the access of values that + * were not known at the time the binary was compiled. + * + * @param rawValue Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(int32_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @note This method bypass the validationFunc to enable the access of values that + * were not known at the time the binary was compiled. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **rawValue**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndRawValuesUsingBlock: + (void (^)(int32_t key, int32_t rawValue, BOOL *stop))block; + +/** + * Adds the keys and raw enum values from another dictionary. + * + * @note This method bypass the validationFunc to enable the setting of values that + * were not known at the time the binary was compiled. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addRawEntriesFromDictionary:(GPBInt32EnumDictionary *)otherDictionary; + +// If value is not a valid enumerator as defined by validationFunc, these +// methods will assert in debug, and will log in release and assign the value +// to the default value. Use the rawValue methods below to assign non enumerator +// values. + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setEnum:(int32_t)value forKey:(int32_t)key; + +/** + * Sets the raw enum value for the given key. + * + * @note This method bypass the validationFunc to enable the setting of values that + * were not known at the time the binary was compiled. + * + * @param rawValue The raw enum value to set. + * @param key The key under which to store the raw enum value. + **/ +- (void)setRawValue:(int32_t)rawValue forKey:(int32_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeEnumForKey:(int32_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Int32 -> Object + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBInt32ObjectDictionary<__covariant ObjectType> : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param object The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithObject:(ObjectType)object + forKey:(int32_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param objects The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects + forKeys:(const int32_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBInt32ObjectDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param objects The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects + forKeys:(const int32_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBInt32ObjectDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Fetches the object stored under the given key. + * + * @param key Key under which the value is stored, if present. + * + * @return The object if found, nil otherwise. + **/ +- (ObjectType)objectForKey:(int32_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **object**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndObjectsUsingBlock: + (void (^)(int32_t key, ObjectType object, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBInt32ObjectDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param object The value to set. + * @param key The key under which to store the value. + **/ +- (void)setObject:(ObjectType)object forKey:(int32_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeObjectForKey:(int32_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - UInt64 -> UInt32 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBUInt64UInt32Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithUInt32:(uint32_t)value + forKey:(uint64_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithUInt32s:(const uint32_t [__nullable])values + forKeys:(const uint64_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBUInt64UInt32Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values + forKeys:(const uint64_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBUInt64UInt32Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(uint64_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndUInt32sUsingBlock: + (void (^)(uint64_t key, uint32_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBUInt64UInt32Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setUInt32:(uint32_t)value forKey:(uint64_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeUInt32ForKey:(uint64_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - UInt64 -> Int32 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBUInt64Int32Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithInt32:(int32_t)value + forKey:(uint64_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithInt32s:(const int32_t [__nullable])values + forKeys:(const uint64_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBUInt64Int32Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithInt32s:(const int32_t [__nullable])values + forKeys:(const uint64_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBUInt64Int32Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getInt32:(nullable int32_t *)value forKey:(uint64_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndInt32sUsingBlock: + (void (^)(uint64_t key, int32_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBUInt64Int32Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setInt32:(int32_t)value forKey:(uint64_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeInt32ForKey:(uint64_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - UInt64 -> UInt64 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBUInt64UInt64Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithUInt64:(uint64_t)value + forKey:(uint64_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithUInt64s:(const uint64_t [__nullable])values + forKeys:(const uint64_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBUInt64UInt64Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values + forKeys:(const uint64_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBUInt64UInt64Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(uint64_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndUInt64sUsingBlock: + (void (^)(uint64_t key, uint64_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBUInt64UInt64Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setUInt64:(uint64_t)value forKey:(uint64_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeUInt64ForKey:(uint64_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - UInt64 -> Int64 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBUInt64Int64Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithInt64:(int64_t)value + forKey:(uint64_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithInt64s:(const int64_t [__nullable])values + forKeys:(const uint64_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBUInt64Int64Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithInt64s:(const int64_t [__nullable])values + forKeys:(const uint64_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBUInt64Int64Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getInt64:(nullable int64_t *)value forKey:(uint64_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndInt64sUsingBlock: + (void (^)(uint64_t key, int64_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBUInt64Int64Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setInt64:(int64_t)value forKey:(uint64_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeInt64ForKey:(uint64_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - UInt64 -> Bool + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBUInt64BoolDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithBool:(BOOL)value + forKey:(uint64_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithBools:(const BOOL [__nullable])values + forKeys:(const uint64_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBUInt64BoolDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithBools:(const BOOL [__nullable])values + forKeys:(const uint64_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBUInt64BoolDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getBool:(nullable BOOL *)value forKey:(uint64_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndBoolsUsingBlock: + (void (^)(uint64_t key, BOOL value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBUInt64BoolDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setBool:(BOOL)value forKey:(uint64_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeBoolForKey:(uint64_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - UInt64 -> Float + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBUInt64FloatDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithFloat:(float)value + forKey:(uint64_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithFloats:(const float [__nullable])values + forKeys:(const uint64_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBUInt64FloatDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithFloats:(const float [__nullable])values + forKeys:(const uint64_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBUInt64FloatDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getFloat:(nullable float *)value forKey:(uint64_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndFloatsUsingBlock: + (void (^)(uint64_t key, float value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBUInt64FloatDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setFloat:(float)value forKey:(uint64_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeFloatForKey:(uint64_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - UInt64 -> Double + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBUInt64DoubleDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithDouble:(double)value + forKey:(uint64_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithDoubles:(const double [__nullable])values + forKeys:(const uint64_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBUInt64DoubleDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithDoubles:(const double [__nullable])values + forKeys:(const uint64_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBUInt64DoubleDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getDouble:(nullable double *)value forKey:(uint64_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndDoublesUsingBlock: + (void (^)(uint64_t key, double value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBUInt64DoubleDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setDouble:(double)value forKey:(uint64_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeDoubleForKey:(uint64_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - UInt64 -> Enum + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBUInt64EnumDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; +/** The validation function to check if the enums are valid. */ +@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the given validation function. + * + * @param func The enum validation function for the dictionary. + * + * @return A newly instanced dictionary. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param func The enum validation function for the dictionary. + * @param rawValue The raw enum value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func + rawValue:(int32_t)rawValue + forKey:(uint64_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param func The enum validation function for the dictionary. + * @param values The raw enum values values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func + rawValues:(const int32_t [__nullable])values + forKeys:(const uint64_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBUInt64EnumDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param func The enum validation function for the dictionary. + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems; + +/** + * Initializes a dictionary with the given validation function. + * + * @param func The enum validation function for the dictionary. + * + * @return A newly initialized dictionary. + **/ +- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func; + +/** + * Initializes a dictionary with the entries given. + * + * @param func The enum validation function for the dictionary. + * @param values The raw enum values values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly initialized dictionary with the keys and values in it. + **/ +- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func + rawValues:(const int32_t [__nullable])values + forKeys:(const uint64_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly initialized dictionary with the entries from the given + * dictionary in it. + **/ +- (instancetype)initWithDictionary:(GPBUInt64EnumDictionary *)dictionary; + +/** + * Initializes a dictionary with the given capacity. + * + * @param func The enum validation function for the dictionary. + * @param numItems Capacity needed for the dictionary. + * + * @return A newly initialized dictionary with the given capacity. + **/ +- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems; + +// These will return kGPBUnrecognizedEnumeratorValue if the value for the key +// is not a valid enumerator as defined by validationFunc. If the actual value is +// desired, use "raw" version of the method. + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getEnum:(nullable int32_t *)value forKey:(uint64_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndEnumsUsingBlock: + (void (^)(uint64_t key, int32_t value, BOOL *stop))block; + +/** + * Gets the raw enum value for the given key. + * + * @note This method bypass the validationFunc to enable the access of values that + * were not known at the time the binary was compiled. + * + * @param rawValue Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(uint64_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @note This method bypass the validationFunc to enable the access of values that + * were not known at the time the binary was compiled. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **rawValue**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndRawValuesUsingBlock: + (void (^)(uint64_t key, int32_t rawValue, BOOL *stop))block; + +/** + * Adds the keys and raw enum values from another dictionary. + * + * @note This method bypass the validationFunc to enable the setting of values that + * were not known at the time the binary was compiled. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addRawEntriesFromDictionary:(GPBUInt64EnumDictionary *)otherDictionary; + +// If value is not a valid enumerator as defined by validationFunc, these +// methods will assert in debug, and will log in release and assign the value +// to the default value. Use the rawValue methods below to assign non enumerator +// values. + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setEnum:(int32_t)value forKey:(uint64_t)key; + +/** + * Sets the raw enum value for the given key. + * + * @note This method bypass the validationFunc to enable the setting of values that + * were not known at the time the binary was compiled. + * + * @param rawValue The raw enum value to set. + * @param key The key under which to store the raw enum value. + **/ +- (void)setRawValue:(int32_t)rawValue forKey:(uint64_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeEnumForKey:(uint64_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - UInt64 -> Object + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBUInt64ObjectDictionary<__covariant ObjectType> : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param object The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithObject:(ObjectType)object + forKey:(uint64_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param objects The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects + forKeys:(const uint64_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBUInt64ObjectDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param objects The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects + forKeys:(const uint64_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBUInt64ObjectDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Fetches the object stored under the given key. + * + * @param key Key under which the value is stored, if present. + * + * @return The object if found, nil otherwise. + **/ +- (ObjectType)objectForKey:(uint64_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **object**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndObjectsUsingBlock: + (void (^)(uint64_t key, ObjectType object, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBUInt64ObjectDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param object The value to set. + * @param key The key under which to store the value. + **/ +- (void)setObject:(ObjectType)object forKey:(uint64_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeObjectForKey:(uint64_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Int64 -> UInt32 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBInt64UInt32Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithUInt32:(uint32_t)value + forKey:(int64_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithUInt32s:(const uint32_t [__nullable])values + forKeys:(const int64_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBInt64UInt32Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values + forKeys:(const int64_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBInt64UInt32Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(int64_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndUInt32sUsingBlock: + (void (^)(int64_t key, uint32_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBInt64UInt32Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setUInt32:(uint32_t)value forKey:(int64_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeUInt32ForKey:(int64_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Int64 -> Int32 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBInt64Int32Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithInt32:(int32_t)value + forKey:(int64_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithInt32s:(const int32_t [__nullable])values + forKeys:(const int64_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBInt64Int32Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithInt32s:(const int32_t [__nullable])values + forKeys:(const int64_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBInt64Int32Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getInt32:(nullable int32_t *)value forKey:(int64_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndInt32sUsingBlock: + (void (^)(int64_t key, int32_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBInt64Int32Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setInt32:(int32_t)value forKey:(int64_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeInt32ForKey:(int64_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Int64 -> UInt64 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBInt64UInt64Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithUInt64:(uint64_t)value + forKey:(int64_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithUInt64s:(const uint64_t [__nullable])values + forKeys:(const int64_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBInt64UInt64Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values + forKeys:(const int64_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBInt64UInt64Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(int64_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndUInt64sUsingBlock: + (void (^)(int64_t key, uint64_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBInt64UInt64Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setUInt64:(uint64_t)value forKey:(int64_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeUInt64ForKey:(int64_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Int64 -> Int64 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBInt64Int64Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithInt64:(int64_t)value + forKey:(int64_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithInt64s:(const int64_t [__nullable])values + forKeys:(const int64_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBInt64Int64Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithInt64s:(const int64_t [__nullable])values + forKeys:(const int64_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBInt64Int64Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getInt64:(nullable int64_t *)value forKey:(int64_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndInt64sUsingBlock: + (void (^)(int64_t key, int64_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBInt64Int64Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setInt64:(int64_t)value forKey:(int64_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeInt64ForKey:(int64_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Int64 -> Bool + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBInt64BoolDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithBool:(BOOL)value + forKey:(int64_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithBools:(const BOOL [__nullable])values + forKeys:(const int64_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBInt64BoolDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithBools:(const BOOL [__nullable])values + forKeys:(const int64_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBInt64BoolDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getBool:(nullable BOOL *)value forKey:(int64_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndBoolsUsingBlock: + (void (^)(int64_t key, BOOL value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBInt64BoolDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setBool:(BOOL)value forKey:(int64_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeBoolForKey:(int64_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Int64 -> Float + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBInt64FloatDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithFloat:(float)value + forKey:(int64_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithFloats:(const float [__nullable])values + forKeys:(const int64_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBInt64FloatDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithFloats:(const float [__nullable])values + forKeys:(const int64_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBInt64FloatDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getFloat:(nullable float *)value forKey:(int64_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndFloatsUsingBlock: + (void (^)(int64_t key, float value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBInt64FloatDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setFloat:(float)value forKey:(int64_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeFloatForKey:(int64_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Int64 -> Double + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBInt64DoubleDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithDouble:(double)value + forKey:(int64_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithDoubles:(const double [__nullable])values + forKeys:(const int64_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBInt64DoubleDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithDoubles:(const double [__nullable])values + forKeys:(const int64_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBInt64DoubleDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getDouble:(nullable double *)value forKey:(int64_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndDoublesUsingBlock: + (void (^)(int64_t key, double value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBInt64DoubleDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setDouble:(double)value forKey:(int64_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeDoubleForKey:(int64_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Int64 -> Enum + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBInt64EnumDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; +/** The validation function to check if the enums are valid. */ +@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the given validation function. + * + * @param func The enum validation function for the dictionary. + * + * @return A newly instanced dictionary. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param func The enum validation function for the dictionary. + * @param rawValue The raw enum value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func + rawValue:(int32_t)rawValue + forKey:(int64_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param func The enum validation function for the dictionary. + * @param values The raw enum values values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func + rawValues:(const int32_t [__nullable])values + forKeys:(const int64_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBInt64EnumDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param func The enum validation function for the dictionary. + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems; + +/** + * Initializes a dictionary with the given validation function. + * + * @param func The enum validation function for the dictionary. + * + * @return A newly initialized dictionary. + **/ +- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func; + +/** + * Initializes a dictionary with the entries given. + * + * @param func The enum validation function for the dictionary. + * @param values The raw enum values values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly initialized dictionary with the keys and values in it. + **/ +- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func + rawValues:(const int32_t [__nullable])values + forKeys:(const int64_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly initialized dictionary with the entries from the given + * dictionary in it. + **/ +- (instancetype)initWithDictionary:(GPBInt64EnumDictionary *)dictionary; + +/** + * Initializes a dictionary with the given capacity. + * + * @param func The enum validation function for the dictionary. + * @param numItems Capacity needed for the dictionary. + * + * @return A newly initialized dictionary with the given capacity. + **/ +- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems; + +// These will return kGPBUnrecognizedEnumeratorValue if the value for the key +// is not a valid enumerator as defined by validationFunc. If the actual value is +// desired, use "raw" version of the method. + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getEnum:(nullable int32_t *)value forKey:(int64_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndEnumsUsingBlock: + (void (^)(int64_t key, int32_t value, BOOL *stop))block; + +/** + * Gets the raw enum value for the given key. + * + * @note This method bypass the validationFunc to enable the access of values that + * were not known at the time the binary was compiled. + * + * @param rawValue Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(int64_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @note This method bypass the validationFunc to enable the access of values that + * were not known at the time the binary was compiled. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **rawValue**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndRawValuesUsingBlock: + (void (^)(int64_t key, int32_t rawValue, BOOL *stop))block; + +/** + * Adds the keys and raw enum values from another dictionary. + * + * @note This method bypass the validationFunc to enable the setting of values that + * were not known at the time the binary was compiled. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addRawEntriesFromDictionary:(GPBInt64EnumDictionary *)otherDictionary; + +// If value is not a valid enumerator as defined by validationFunc, these +// methods will assert in debug, and will log in release and assign the value +// to the default value. Use the rawValue methods below to assign non enumerator +// values. + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setEnum:(int32_t)value forKey:(int64_t)key; + +/** + * Sets the raw enum value for the given key. + * + * @note This method bypass the validationFunc to enable the setting of values that + * were not known at the time the binary was compiled. + * + * @param rawValue The raw enum value to set. + * @param key The key under which to store the raw enum value. + **/ +- (void)setRawValue:(int32_t)rawValue forKey:(int64_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeEnumForKey:(int64_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Int64 -> Object + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBInt64ObjectDictionary<__covariant ObjectType> : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param object The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithObject:(ObjectType)object + forKey:(int64_t)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param objects The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects + forKeys:(const int64_t [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBInt64ObjectDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param objects The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects + forKeys:(const int64_t [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBInt64ObjectDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Fetches the object stored under the given key. + * + * @param key Key under which the value is stored, if present. + * + * @return The object if found, nil otherwise. + **/ +- (ObjectType)objectForKey:(int64_t)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **object**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndObjectsUsingBlock: + (void (^)(int64_t key, ObjectType object, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBInt64ObjectDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param object The value to set. + * @param key The key under which to store the value. + **/ +- (void)setObject:(ObjectType)object forKey:(int64_t)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeObjectForKey:(int64_t)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Bool -> UInt32 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBBoolUInt32Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithUInt32:(uint32_t)value + forKey:(BOOL)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithUInt32s:(const uint32_t [__nullable])values + forKeys:(const BOOL [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBBoolUInt32Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values + forKeys:(const BOOL [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBBoolUInt32Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(BOOL)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndUInt32sUsingBlock: + (void (^)(BOOL key, uint32_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBBoolUInt32Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setUInt32:(uint32_t)value forKey:(BOOL)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeUInt32ForKey:(BOOL)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Bool -> Int32 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBBoolInt32Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithInt32:(int32_t)value + forKey:(BOOL)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithInt32s:(const int32_t [__nullable])values + forKeys:(const BOOL [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBBoolInt32Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithInt32s:(const int32_t [__nullable])values + forKeys:(const BOOL [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBBoolInt32Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getInt32:(nullable int32_t *)value forKey:(BOOL)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndInt32sUsingBlock: + (void (^)(BOOL key, int32_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBBoolInt32Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setInt32:(int32_t)value forKey:(BOOL)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeInt32ForKey:(BOOL)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Bool -> UInt64 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBBoolUInt64Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithUInt64:(uint64_t)value + forKey:(BOOL)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithUInt64s:(const uint64_t [__nullable])values + forKeys:(const BOOL [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBBoolUInt64Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values + forKeys:(const BOOL [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBBoolUInt64Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(BOOL)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndUInt64sUsingBlock: + (void (^)(BOOL key, uint64_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBBoolUInt64Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setUInt64:(uint64_t)value forKey:(BOOL)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeUInt64ForKey:(BOOL)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Bool -> Int64 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBBoolInt64Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithInt64:(int64_t)value + forKey:(BOOL)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithInt64s:(const int64_t [__nullable])values + forKeys:(const BOOL [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBBoolInt64Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithInt64s:(const int64_t [__nullable])values + forKeys:(const BOOL [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBBoolInt64Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getInt64:(nullable int64_t *)value forKey:(BOOL)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndInt64sUsingBlock: + (void (^)(BOOL key, int64_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBBoolInt64Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setInt64:(int64_t)value forKey:(BOOL)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeInt64ForKey:(BOOL)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Bool -> Bool + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBBoolBoolDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithBool:(BOOL)value + forKey:(BOOL)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithBools:(const BOOL [__nullable])values + forKeys:(const BOOL [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBBoolBoolDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithBools:(const BOOL [__nullable])values + forKeys:(const BOOL [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBBoolBoolDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getBool:(nullable BOOL *)value forKey:(BOOL)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndBoolsUsingBlock: + (void (^)(BOOL key, BOOL value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBBoolBoolDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setBool:(BOOL)value forKey:(BOOL)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeBoolForKey:(BOOL)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Bool -> Float + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBBoolFloatDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithFloat:(float)value + forKey:(BOOL)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithFloats:(const float [__nullable])values + forKeys:(const BOOL [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBBoolFloatDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithFloats:(const float [__nullable])values + forKeys:(const BOOL [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBBoolFloatDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getFloat:(nullable float *)value forKey:(BOOL)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndFloatsUsingBlock: + (void (^)(BOOL key, float value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBBoolFloatDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setFloat:(float)value forKey:(BOOL)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeFloatForKey:(BOOL)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Bool -> Double + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBBoolDoubleDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithDouble:(double)value + forKey:(BOOL)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithDoubles:(const double [__nullable])values + forKeys:(const BOOL [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBBoolDoubleDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithDoubles:(const double [__nullable])values + forKeys:(const BOOL [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBBoolDoubleDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getDouble:(nullable double *)value forKey:(BOOL)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndDoublesUsingBlock: + (void (^)(BOOL key, double value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBBoolDoubleDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setDouble:(double)value forKey:(BOOL)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeDoubleForKey:(BOOL)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Bool -> Enum + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBBoolEnumDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; +/** The validation function to check if the enums are valid. */ +@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the given validation function. + * + * @param func The enum validation function for the dictionary. + * + * @return A newly instanced dictionary. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param func The enum validation function for the dictionary. + * @param rawValue The raw enum value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func + rawValue:(int32_t)rawValue + forKey:(BOOL)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param func The enum validation function for the dictionary. + * @param values The raw enum values values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func + rawValues:(const int32_t [__nullable])values + forKeys:(const BOOL [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBBoolEnumDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param func The enum validation function for the dictionary. + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems; + +/** + * Initializes a dictionary with the given validation function. + * + * @param func The enum validation function for the dictionary. + * + * @return A newly initialized dictionary. + **/ +- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func; + +/** + * Initializes a dictionary with the entries given. + * + * @param func The enum validation function for the dictionary. + * @param values The raw enum values values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly initialized dictionary with the keys and values in it. + **/ +- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func + rawValues:(const int32_t [__nullable])values + forKeys:(const BOOL [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly initialized dictionary with the entries from the given + * dictionary in it. + **/ +- (instancetype)initWithDictionary:(GPBBoolEnumDictionary *)dictionary; + +/** + * Initializes a dictionary with the given capacity. + * + * @param func The enum validation function for the dictionary. + * @param numItems Capacity needed for the dictionary. + * + * @return A newly initialized dictionary with the given capacity. + **/ +- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems; + +// These will return kGPBUnrecognizedEnumeratorValue if the value for the key +// is not a valid enumerator as defined by validationFunc. If the actual value is +// desired, use "raw" version of the method. + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getEnum:(nullable int32_t *)value forKey:(BOOL)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndEnumsUsingBlock: + (void (^)(BOOL key, int32_t value, BOOL *stop))block; + +/** + * Gets the raw enum value for the given key. + * + * @note This method bypass the validationFunc to enable the access of values that + * were not known at the time the binary was compiled. + * + * @param rawValue Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(BOOL)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @note This method bypass the validationFunc to enable the access of values that + * were not known at the time the binary was compiled. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **rawValue**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndRawValuesUsingBlock: + (void (^)(BOOL key, int32_t rawValue, BOOL *stop))block; + +/** + * Adds the keys and raw enum values from another dictionary. + * + * @note This method bypass the validationFunc to enable the setting of values that + * were not known at the time the binary was compiled. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addRawEntriesFromDictionary:(GPBBoolEnumDictionary *)otherDictionary; + +// If value is not a valid enumerator as defined by validationFunc, these +// methods will assert in debug, and will log in release and assign the value +// to the default value. Use the rawValue methods below to assign non enumerator +// values. + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setEnum:(int32_t)value forKey:(BOOL)key; + +/** + * Sets the raw enum value for the given key. + * + * @note This method bypass the validationFunc to enable the setting of values that + * were not known at the time the binary was compiled. + * + * @param rawValue The raw enum value to set. + * @param key The key under which to store the raw enum value. + **/ +- (void)setRawValue:(int32_t)rawValue forKey:(BOOL)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeEnumForKey:(BOOL)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - Bool -> Object + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBBoolObjectDictionary<__covariant ObjectType> : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param object The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithObject:(ObjectType)object + forKey:(BOOL)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param objects The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects + forKeys:(const BOOL [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBBoolObjectDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param objects The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects + forKeys:(const BOOL [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBBoolObjectDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Fetches the object stored under the given key. + * + * @param key Key under which the value is stored, if present. + * + * @return The object if found, nil otherwise. + **/ +- (ObjectType)objectForKey:(BOOL)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **object**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndObjectsUsingBlock: + (void (^)(BOOL key, ObjectType object, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBBoolObjectDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param object The value to set. + * @param key The key under which to store the value. + **/ +- (void)setObject:(ObjectType)object forKey:(BOOL)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeObjectForKey:(BOOL)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - String -> UInt32 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBStringUInt32Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithUInt32:(uint32_t)value + forKey:(NSString *)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithUInt32s:(const uint32_t [__nullable])values + forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBStringUInt32Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values + forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBStringUInt32Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(NSString *)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndUInt32sUsingBlock: + (void (^)(NSString *key, uint32_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBStringUInt32Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setUInt32:(uint32_t)value forKey:(NSString *)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeUInt32ForKey:(NSString *)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - String -> Int32 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBStringInt32Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithInt32:(int32_t)value + forKey:(NSString *)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithInt32s:(const int32_t [__nullable])values + forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBStringInt32Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithInt32s:(const int32_t [__nullable])values + forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBStringInt32Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getInt32:(nullable int32_t *)value forKey:(NSString *)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndInt32sUsingBlock: + (void (^)(NSString *key, int32_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBStringInt32Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setInt32:(int32_t)value forKey:(NSString *)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeInt32ForKey:(NSString *)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - String -> UInt64 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBStringUInt64Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithUInt64:(uint64_t)value + forKey:(NSString *)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithUInt64s:(const uint64_t [__nullable])values + forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBStringUInt64Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values + forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBStringUInt64Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(NSString *)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndUInt64sUsingBlock: + (void (^)(NSString *key, uint64_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBStringUInt64Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setUInt64:(uint64_t)value forKey:(NSString *)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeUInt64ForKey:(NSString *)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - String -> Int64 + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBStringInt64Dictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithInt64:(int64_t)value + forKey:(NSString *)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithInt64s:(const int64_t [__nullable])values + forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBStringInt64Dictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithInt64s:(const int64_t [__nullable])values + forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBStringInt64Dictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getInt64:(nullable int64_t *)value forKey:(NSString *)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndInt64sUsingBlock: + (void (^)(NSString *key, int64_t value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBStringInt64Dictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setInt64:(int64_t)value forKey:(NSString *)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeInt64ForKey:(NSString *)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - String -> Bool + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBStringBoolDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithBool:(BOOL)value + forKey:(NSString *)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithBools:(const BOOL [__nullable])values + forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBStringBoolDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithBools:(const BOOL [__nullable])values + forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBStringBoolDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getBool:(nullable BOOL *)value forKey:(NSString *)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndBoolsUsingBlock: + (void (^)(NSString *key, BOOL value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBStringBoolDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setBool:(BOOL)value forKey:(NSString *)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeBoolForKey:(NSString *)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - String -> Float + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBStringFloatDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithFloat:(float)value + forKey:(NSString *)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithFloats:(const float [__nullable])values + forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBStringFloatDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithFloats:(const float [__nullable])values + forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBStringFloatDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getFloat:(nullable float *)value forKey:(NSString *)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndFloatsUsingBlock: + (void (^)(NSString *key, float value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBStringFloatDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setFloat:(float)value forKey:(NSString *)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeFloatForKey:(NSString *)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - String -> Double + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBStringDoubleDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param value The value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithDouble:(double)value + forKey:(NSString *)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param values The values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithDoubles:(const double [__nullable])values + forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBStringDoubleDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; + +/** + * Initializes this dictionary, copying the given values and keys. + * + * @param values The values to be placed in this dictionary. + * @param keys The keys under which to store the values. + * @param count The number of elements to copy into the dictionary. + * + * @return A newly initialized dictionary with a copy of the values and keys. + **/ +- (instancetype)initWithDoubles:(const double [__nullable])values + forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes this dictionary, copying the entries from the given dictionary. + * + * @param dictionary Dictionary containing the entries to add to this dictionary. + * + * @return A newly initialized dictionary with the entries of the given dictionary. + **/ +- (instancetype)initWithDictionary:(GPBStringDoubleDictionary *)dictionary; + +/** + * Initializes this dictionary with the requested capacity. + * + * @param numItems Number of items needed for this dictionary. + * + * @return A newly initialized dictionary with the requested capacity. + **/ +- (instancetype)initWithCapacity:(NSUInteger)numItems; + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getDouble:(nullable double *)value forKey:(NSString *)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndDoublesUsingBlock: + (void (^)(NSString *key, double value, BOOL *stop))block; + +/** + * Adds the keys and values from another dictionary. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addEntriesFromDictionary:(GPBStringDoubleDictionary *)otherDictionary; + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setDouble:(double)value forKey:(NSString *)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeDoubleForKey:(NSString *)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +#pragma mark - String -> Enum + +/** + * Class used for map fields of + * values. This performs better than boxing into NSNumbers in NSDictionaries. + * + * @note This class is not meant to be subclassed. + **/ +@interface GPBStringEnumDictionary : NSObject + +/** Number of entries stored in this dictionary. */ +@property(nonatomic, readonly) NSUInteger count; +/** The validation function to check if the enums are valid. */ +@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; + +/** + * @return A newly instanced and empty dictionary. + **/ ++ (instancetype)dictionary; + +/** + * Creates and initializes a dictionary with the given validation function. + * + * @param func The enum validation function for the dictionary. + * + * @return A newly instanced dictionary. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func; + +/** + * Creates and initializes a dictionary with the single entry given. + * + * @param func The enum validation function for the dictionary. + * @param rawValue The raw enum value to be placed in the dictionary. + * @param key The key under which to store the value. + * + * @return A newly instanced dictionary with the key and value in it. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func + rawValue:(int32_t)rawValue + forKey:(NSString *)key; + +/** + * Creates and initializes a dictionary with the entries given. + * + * @param func The enum validation function for the dictionary. + * @param values The raw enum values values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly instanced dictionary with the keys and values in it. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func + rawValues:(const int32_t [__nullable])values + forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys + count:(NSUInteger)count; + +/** + * Creates and initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly instanced dictionary with the entries from the given + * dictionary in it. + **/ ++ (instancetype)dictionaryWithDictionary:(GPBStringEnumDictionary *)dictionary; + +/** + * Creates and initializes a dictionary with the given capacity. + * + * @param func The enum validation function for the dictionary. + * @param numItems Capacity needed for the dictionary. + * + * @return A newly instanced dictionary with the given capacity. + **/ ++ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems; + +/** + * Initializes a dictionary with the given validation function. + * + * @param func The enum validation function for the dictionary. + * + * @return A newly initialized dictionary. + **/ +- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func; + +/** + * Initializes a dictionary with the entries given. + * + * @param func The enum validation function for the dictionary. + * @param values The raw enum values values to be placed in the dictionary. + * @param keys The keys under which to store the values. + * @param count The number of entries to store in the dictionary. + * + * @return A newly initialized dictionary with the keys and values in it. + **/ +- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func + rawValues:(const int32_t [__nullable])values + forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys + count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; + +/** + * Initializes a dictionary with the entries from the given. + * dictionary. + * + * @param dictionary Dictionary containing the entries to add to the dictionary. + * + * @return A newly initialized dictionary with the entries from the given + * dictionary in it. + **/ +- (instancetype)initWithDictionary:(GPBStringEnumDictionary *)dictionary; + +/** + * Initializes a dictionary with the given capacity. + * + * @param func The enum validation function for the dictionary. + * @param numItems Capacity needed for the dictionary. + * + * @return A newly initialized dictionary with the given capacity. + **/ +- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems; + +// These will return kGPBUnrecognizedEnumeratorValue if the value for the key +// is not a valid enumerator as defined by validationFunc. If the actual value is +// desired, use "raw" version of the method. + +/** + * Gets the value for the given key. + * + * @param value Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getEnum:(nullable int32_t *)value forKey:(NSString *)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **value**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndEnumsUsingBlock: + (void (^)(NSString *key, int32_t value, BOOL *stop))block; + +/** + * Gets the raw enum value for the given key. + * + * @note This method bypass the validationFunc to enable the access of values that + * were not known at the time the binary was compiled. + * + * @param rawValue Pointer into which the value will be set, if found. + * @param key Key under which the value is stored, if present. + * + * @return YES if the key was found and the value was copied, NO otherwise. + **/ +- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(NSString *)key; + +/** + * Enumerates the keys and values on this dictionary with the given block. + * + * @note This method bypass the validationFunc to enable the access of values that + * were not known at the time the binary was compiled. + * + * @param block The block to enumerate with. + * **key**: The key for the current entry. + * **rawValue**: The value for the current entry + * **stop**: A pointer to a boolean that when set stops the enumeration. + **/ +- (void)enumerateKeysAndRawValuesUsingBlock: + (void (^)(NSString *key, int32_t rawValue, BOOL *stop))block; + +/** + * Adds the keys and raw enum values from another dictionary. + * + * @note This method bypass the validationFunc to enable the setting of values that + * were not known at the time the binary was compiled. + * + * @param otherDictionary Dictionary containing entries to be added to this + * dictionary. + **/ +- (void)addRawEntriesFromDictionary:(GPBStringEnumDictionary *)otherDictionary; + +// If value is not a valid enumerator as defined by validationFunc, these +// methods will assert in debug, and will log in release and assign the value +// to the default value. Use the rawValue methods below to assign non enumerator +// values. + +/** + * Sets the value for the given key. + * + * @param value The value to set. + * @param key The key under which to store the value. + **/ +- (void)setEnum:(int32_t)value forKey:(NSString *)key; + +/** + * Sets the raw enum value for the given key. + * + * @note This method bypass the validationFunc to enable the setting of values that + * were not known at the time the binary was compiled. + * + * @param rawValue The raw enum value to set. + * @param key The key under which to store the raw enum value. + **/ +- (void)setRawValue:(int32_t)rawValue forKey:(NSString *)key; + +/** + * Removes the entry for the given key. + * + * @param aKey Key to be removed from this dictionary. + **/ +- (void)removeEnumForKey:(NSString *)aKey; + +/** + * Removes all entries in this dictionary. + **/ +- (void)removeAll; + +@end + +//%PDDM-EXPAND-END DECLARE_DICTIONARIES() + +NS_ASSUME_NONNULL_END + +//%PDDM-DEFINE DECLARE_DICTIONARIES() +//%DICTIONARY_INTERFACES_FOR_POD_KEY(UInt32, uint32_t) +//%DICTIONARY_INTERFACES_FOR_POD_KEY(Int32, int32_t) +//%DICTIONARY_INTERFACES_FOR_POD_KEY(UInt64, uint64_t) +//%DICTIONARY_INTERFACES_FOR_POD_KEY(Int64, int64_t) +//%DICTIONARY_INTERFACES_FOR_POD_KEY(Bool, BOOL) +//%DICTIONARY_POD_INTERFACES_FOR_KEY(String, NSString, *, OBJECT) +//%PDDM-DEFINE DICTIONARY_INTERFACES_FOR_POD_KEY(KEY_NAME, KEY_TYPE) +//%DICTIONARY_POD_INTERFACES_FOR_KEY(KEY_NAME, KEY_TYPE, , POD) +//%DICTIONARY_POD_KEY_TO_OBJECT_INTERFACE(KEY_NAME, KEY_TYPE, Object, ObjectType) +//%PDDM-DEFINE DICTIONARY_POD_INTERFACES_FOR_KEY(KEY_NAME, KEY_TYPE, KisP, KHELPER) +//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, UInt32, uint32_t) +//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Int32, int32_t) +//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, UInt64, uint64_t) +//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Int64, int64_t) +//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Bool, BOOL) +//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Float, float) +//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Double, double) +//%DICTIONARY_KEY_TO_ENUM_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Enum, int32_t) +//%PDDM-DEFINE DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE) +//%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, POD, VALUE_NAME, value) +//%PDDM-DEFINE DICTIONARY_POD_KEY_TO_OBJECT_INTERFACE(KEY_NAME, KEY_TYPE, VALUE_NAME, VALUE_TYPE) +//%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, , POD, VALUE_NAME, VALUE_TYPE, OBJECT, Object, object) +//%PDDM-DEFINE VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE, VNAME) +//%/** +//% * Gets the value for the given key. +//% * +//% * @param value Pointer into which the value will be set, if found. +//% * @param key Key under which the value is stored, if present. +//% * +//% * @return YES if the key was found and the value was copied, NO otherwise. +//% **/ +//%- (BOOL)get##VNAME##:(nullable VALUE_TYPE *)value forKey:(KEY_TYPE)key; +//%PDDM-DEFINE VALUE_FOR_KEY_OBJECT(KEY_TYPE, VALUE_TYPE, VNAME) +//%/** +//% * Fetches the object stored under the given key. +//% * +//% * @param key Key under which the value is stored, if present. +//% * +//% * @return The object if found, nil otherwise. +//% **/ +//%- (VALUE_TYPE)objectForKey:(KEY_TYPE)key; +//%PDDM-DEFINE VALUE_FOR_KEY_Enum(KEY_TYPE, VALUE_TYPE, VNAME) +//%VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE, VNAME) +//%PDDM-DEFINE ARRAY_ARG_MODIFIERPOD() +// Nothing +//%PDDM-DEFINE ARRAY_ARG_MODIFIEREnum() +// Nothing +//%PDDM-DEFINE ARRAY_ARG_MODIFIEROBJECT() +//%__nonnull GPB_UNSAFE_UNRETAINED ## +//%PDDM-DEFINE DICTIONARY_CLASS_DECLPOD(KEY_NAME, VALUE_NAME, VALUE_TYPE) +//%GPB##KEY_NAME##VALUE_NAME##Dictionary +//%PDDM-DEFINE DICTIONARY_CLASS_DECLEnum(KEY_NAME, VALUE_NAME, VALUE_TYPE) +//%GPB##KEY_NAME##VALUE_NAME##Dictionary +//%PDDM-DEFINE DICTIONARY_CLASS_DECLOBJECT(KEY_NAME, VALUE_NAME, VALUE_TYPE) +//%GPB##KEY_NAME##VALUE_NAME##Dictionary<__covariant VALUE_TYPE> +//%PDDM-DEFINE DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR) +//%#pragma mark - KEY_NAME -> VALUE_NAME +//% +//%/** +//% * Class used for map fields of <##KEY_TYPE##, ##VALUE_TYPE##> +//% * values. This performs better than boxing into NSNumbers in NSDictionaries. +//% * +//% * @note This class is not meant to be subclassed. +//% **/ +//%@interface DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) : NSObject +//% +//%/** Number of entries stored in this dictionary. */ +//%@property(nonatomic, readonly) NSUInteger count; +//% +//%/** +//% * @return A newly instanced and empty dictionary. +//% **/ +//%+ (instancetype)dictionary; +//% +//%/** +//% * Creates and initializes a dictionary with the single entry given. +//% * +//% * @param ##VNAME_VAR The value to be placed in the dictionary. +//% * @param key ##VNAME_VAR$S## The key under which to store the value. +//% * +//% * @return A newly instanced dictionary with the key and value in it. +//% **/ +//%+ (instancetype)dictionaryWith##VNAME##:(VALUE_TYPE)##VNAME_VAR +//% ##VNAME$S## forKey:(KEY_TYPE##KisP$S##KisP)key; +//% +//%/** +//% * Creates and initializes a dictionary with the entries given. +//% * +//% * @param ##VNAME_VAR##s The values to be placed in the dictionary. +//% * @param keys ##VNAME_VAR$S## The keys under which to store the values. +//% * @param count ##VNAME_VAR$S## The number of entries to store in the dictionary. +//% * +//% * @return A newly instanced dictionary with the keys and values in it. +//% **/ +//%+ (instancetype)dictionaryWith##VNAME##s:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[__nullable])##VNAME_VAR##s +//% ##VNAME$S## forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[__nullable])keys +//% ##VNAME$S## count:(NSUInteger)count; +//% +//%/** +//% * Creates and initializes a dictionary with the entries from the given. +//% * dictionary. +//% * +//% * @param dictionary Dictionary containing the entries to add to the dictionary. +//% * +//% * @return A newly instanced dictionary with the entries from the given +//% * dictionary in it. +//% **/ +//%+ (instancetype)dictionaryWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary; +//% +//%/** +//% * Creates and initializes a dictionary with the given capacity. +//% * +//% * @param numItems Capacity needed for the dictionary. +//% * +//% * @return A newly instanced dictionary with the given capacity. +//% **/ +//%+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; +//% +//%/** +//% * Initializes this dictionary, copying the given values and keys. +//% * +//% * @param ##VNAME_VAR##s The values to be placed in this dictionary. +//% * @param keys ##VNAME_VAR$S## The keys under which to store the values. +//% * @param count ##VNAME_VAR$S## The number of elements to copy into the dictionary. +//% * +//% * @return A newly initialized dictionary with a copy of the values and keys. +//% **/ +//%- (instancetype)initWith##VNAME##s:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[__nullable])##VNAME_VAR##s +//% ##VNAME$S## forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[__nullable])keys +//% ##VNAME$S## count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; +//% +//%/** +//% * Initializes this dictionary, copying the entries from the given dictionary. +//% * +//% * @param dictionary Dictionary containing the entries to add to this dictionary. +//% * +//% * @return A newly initialized dictionary with the entries of the given dictionary. +//% **/ +//%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary; +//% +//%/** +//% * Initializes this dictionary with the requested capacity. +//% * +//% * @param numItems Number of items needed for this dictionary. +//% * +//% * @return A newly initialized dictionary with the requested capacity. +//% **/ +//%- (instancetype)initWithCapacity:(NSUInteger)numItems; +//% +//%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR) +//% +//%/** +//% * Adds the keys and values from another dictionary. +//% * +//% * @param otherDictionary Dictionary containing entries to be added to this +//% * dictionary. +//% **/ +//%- (void)addEntriesFromDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)otherDictionary; +//% +//%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR) +//% +//%@end +//% + +//%PDDM-DEFINE DICTIONARY_KEY_TO_ENUM_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE) +//%DICTIONARY_KEY_TO_ENUM_INTERFACE2(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, Enum) +//%PDDM-DEFINE DICTIONARY_KEY_TO_ENUM_INTERFACE2(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, VHELPER) +//%#pragma mark - KEY_NAME -> VALUE_NAME +//% +//%/** +//% * Class used for map fields of <##KEY_TYPE##, ##VALUE_TYPE##> +//% * values. This performs better than boxing into NSNumbers in NSDictionaries. +//% * +//% * @note This class is not meant to be subclassed. +//% **/ +//%@interface GPB##KEY_NAME##VALUE_NAME##Dictionary : NSObject +//% +//%/** Number of entries stored in this dictionary. */ +//%@property(nonatomic, readonly) NSUInteger count; +//%/** The validation function to check if the enums are valid. */ +//%@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; +//% +//%/** +//% * @return A newly instanced and empty dictionary. +//% **/ +//%+ (instancetype)dictionary; +//% +//%/** +//% * Creates and initializes a dictionary with the given validation function. +//% * +//% * @param func The enum validation function for the dictionary. +//% * +//% * @return A newly instanced dictionary. +//% **/ +//%+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func; +//% +//%/** +//% * Creates and initializes a dictionary with the single entry given. +//% * +//% * @param func The enum validation function for the dictionary. +//% * @param rawValue The raw enum value to be placed in the dictionary. +//% * @param key The key under which to store the value. +//% * +//% * @return A newly instanced dictionary with the key and value in it. +//% **/ +//%+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func +//% rawValue:(VALUE_TYPE)rawValue +//% forKey:(KEY_TYPE##KisP$S##KisP)key; +//% +//%/** +//% * Creates and initializes a dictionary with the entries given. +//% * +//% * @param func The enum validation function for the dictionary. +//% * @param values The raw enum values values to be placed in the dictionary. +//% * @param keys The keys under which to store the values. +//% * @param count The number of entries to store in the dictionary. +//% * +//% * @return A newly instanced dictionary with the keys and values in it. +//% **/ +//%+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func +//% rawValues:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[__nullable])values +//% forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[__nullable])keys +//% count:(NSUInteger)count; +//% +//%/** +//% * Creates and initializes a dictionary with the entries from the given. +//% * dictionary. +//% * +//% * @param dictionary Dictionary containing the entries to add to the dictionary. +//% * +//% * @return A newly instanced dictionary with the entries from the given +//% * dictionary in it. +//% **/ +//%+ (instancetype)dictionaryWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary; +//% +//%/** +//% * Creates and initializes a dictionary with the given capacity. +//% * +//% * @param func The enum validation function for the dictionary. +//% * @param numItems Capacity needed for the dictionary. +//% * +//% * @return A newly instanced dictionary with the given capacity. +//% **/ +//%+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func +//% capacity:(NSUInteger)numItems; +//% +//%/** +//% * Initializes a dictionary with the given validation function. +//% * +//% * @param func The enum validation function for the dictionary. +//% * +//% * @return A newly initialized dictionary. +//% **/ +//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func; +//% +//%/** +//% * Initializes a dictionary with the entries given. +//% * +//% * @param func The enum validation function for the dictionary. +//% * @param values The raw enum values values to be placed in the dictionary. +//% * @param keys The keys under which to store the values. +//% * @param count The number of entries to store in the dictionary. +//% * +//% * @return A newly initialized dictionary with the keys and values in it. +//% **/ +//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func +//% rawValues:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[__nullable])values +//% forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[__nullable])keys +//% count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; +//% +//%/** +//% * Initializes a dictionary with the entries from the given. +//% * dictionary. +//% * +//% * @param dictionary Dictionary containing the entries to add to the dictionary. +//% * +//% * @return A newly initialized dictionary with the entries from the given +//% * dictionary in it. +//% **/ +//%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary; +//% +//%/** +//% * Initializes a dictionary with the given capacity. +//% * +//% * @param func The enum validation function for the dictionary. +//% * @param numItems Capacity needed for the dictionary. +//% * +//% * @return A newly initialized dictionary with the given capacity. +//% **/ +//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func +//% capacity:(NSUInteger)numItems; +//% +//%// These will return kGPBUnrecognizedEnumeratorValue if the value for the key +//%// is not a valid enumerator as defined by validationFunc. If the actual value is +//%// desired, use "raw" version of the method. +//% +//%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, Enum, value) +//% +//%/** +//% * Gets the raw enum value for the given key. +//% * +//% * @note This method bypass the validationFunc to enable the access of values that +//% * were not known at the time the binary was compiled. +//% * +//% * @param rawValue Pointer into which the value will be set, if found. +//% * @param key Key under which the value is stored, if present. +//% * +//% * @return YES if the key was found and the value was copied, NO otherwise. +//% **/ +//%- (BOOL)getRawValue:(nullable VALUE_TYPE *)rawValue forKey:(KEY_TYPE##KisP$S##KisP)key; +//% +//%/** +//% * Enumerates the keys and values on this dictionary with the given block. +//% * +//% * @note This method bypass the validationFunc to enable the access of values that +//% * were not known at the time the binary was compiled. +//% * +//% * @param block The block to enumerate with. +//% * **key**: The key for the current entry. +//% * **rawValue**: The value for the current entry +//% * **stop**: A pointer to a boolean that when set stops the enumeration. +//% **/ +//%- (void)enumerateKeysAndRawValuesUsingBlock: +//% (void (^)(KEY_TYPE KisP##key, VALUE_TYPE rawValue, BOOL *stop))block; +//% +//%/** +//% * Adds the keys and raw enum values from another dictionary. +//% * +//% * @note This method bypass the validationFunc to enable the setting of values that +//% * were not known at the time the binary was compiled. +//% * +//% * @param otherDictionary Dictionary containing entries to be added to this +//% * dictionary. +//% **/ +//%- (void)addRawEntriesFromDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)otherDictionary; +//% +//%// If value is not a valid enumerator as defined by validationFunc, these +//%// methods will assert in debug, and will log in release and assign the value +//%// to the default value. Use the rawValue methods below to assign non enumerator +//%// values. +//% +//%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, Enum, value) +//% +//%@end +//% + +//%PDDM-DEFINE DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR) +//%VALUE_FOR_KEY_##VHELPER(KEY_TYPE##KisP$S##KisP, VALUE_TYPE, VNAME) +//% +//%/** +//% * Enumerates the keys and values on this dictionary with the given block. +//% * +//% * @param block The block to enumerate with. +//% * **key**: ##VNAME_VAR$S## The key for the current entry. +//% * **VNAME_VAR**: The value for the current entry +//% * **stop**: ##VNAME_VAR$S## A pointer to a boolean that when set stops the enumeration. +//% **/ +//%- (void)enumerateKeysAnd##VNAME##sUsingBlock: +//% (void (^)(KEY_TYPE KisP##key, VALUE_TYPE VNAME_VAR, BOOL *stop))block; + +//%PDDM-DEFINE DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR) +//%/** +//% * Sets the value for the given key. +//% * +//% * @param ##VNAME_VAR The value to set. +//% * @param key ##VNAME_VAR$S## The key under which to store the value. +//% **/ +//%- (void)set##VNAME##:(VALUE_TYPE)##VNAME_VAR forKey:(KEY_TYPE##KisP$S##KisP)key; +//%DICTIONARY_EXTRA_MUTABLE_METHODS_##VHELPER(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE) +//%/** +//% * Removes the entry for the given key. +//% * +//% * @param aKey Key to be removed from this dictionary. +//% **/ +//%- (void)remove##VNAME##ForKey:(KEY_TYPE##KisP$S##KisP)aKey; +//% +//%/** +//% * Removes all entries in this dictionary. +//% **/ +//%- (void)removeAll; + +//%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_POD(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE) +// Empty +//%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_OBJECT(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE) +// Empty +//%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_Enum(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE) +//% +//%/** +//% * Sets the raw enum value for the given key. +//% * +//% * @note This method bypass the validationFunc to enable the setting of values that +//% * were not known at the time the binary was compiled. +//% * +//% * @param rawValue The raw enum value to set. +//% * @param key The key under which to store the raw enum value. +//% **/ +//%- (void)setRawValue:(VALUE_TYPE)rawValue forKey:(KEY_TYPE##KisP$S##KisP)key; +//% diff --git a/Pods/Protobuf/objectivec/GPBDictionary.m b/Pods/Protobuf/objectivec/GPBDictionary.m new file mode 100644 index 0000000..7713376 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBDictionary.m @@ -0,0 +1,14073 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import "GPBDictionary_PackagePrivate.h" + +#import "GPBCodedInputStream_PackagePrivate.h" +#import "GPBCodedOutputStream_PackagePrivate.h" +#import "GPBDescriptor_PackagePrivate.h" +#import "GPBMessage_PackagePrivate.h" +#import "GPBUtilities_PackagePrivate.h" + +// ------------------------------ NOTE ------------------------------ +// At the moment, this is all using NSNumbers in NSDictionaries under +// the hood, but it is all hidden so we can come back and optimize +// with direct CFDictionary usage later. The reason that wasn't +// done yet is needing to support 32bit iOS builds. Otherwise +// it would be pretty simple to store all this data in CFDictionaries +// directly. +// ------------------------------------------------------------------ + +// Direct access is use for speed, to avoid even internally declaring things +// read/write, etc. The warning is enabled in the project to ensure code calling +// protos can turn on -Wdirect-ivar-access without issues. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdirect-ivar-access" + +// Used to include code only visible to specific versions of the static +// analyzer. Useful for wrapping code that only exists to silence the analyzer. +// Determine the values you want to use for BEGIN_APPLE_BUILD_VERSION, +// END_APPLE_BUILD_VERSION using: +// xcrun clang -dM -E -x c /dev/null | grep __apple_build_version__ +// Example usage: +// #if GPB_STATIC_ANALYZER_ONLY(5621, 5623) ... #endif +#define GPB_STATIC_ANALYZER_ONLY(BEGIN_APPLE_BUILD_VERSION, END_APPLE_BUILD_VERSION) \ + (defined(__clang_analyzer__) && \ + (__apple_build_version__ >= BEGIN_APPLE_BUILD_VERSION && \ + __apple_build_version__ <= END_APPLE_BUILD_VERSION)) + +enum { + kMapKeyFieldNumber = 1, + kMapValueFieldNumber = 2, +}; + +static BOOL DictDefault_IsValidValue(int32_t value) { + // Anything but the bad value marker is allowed. + return (value != kGPBUnrecognizedEnumeratorValue); +} + +//%PDDM-DEFINE SERIALIZE_SUPPORT_2_TYPE(VALUE_NAME, VALUE_TYPE, GPBDATATYPE_NAME1, GPBDATATYPE_NAME2) +//%static size_t ComputeDict##VALUE_NAME##FieldSize(VALUE_TYPE value, uint32_t fieldNum, GPBDataType dataType) { +//% if (dataType == GPBDataType##GPBDATATYPE_NAME1) { +//% return GPBCompute##GPBDATATYPE_NAME1##Size(fieldNum, value); +//% } else if (dataType == GPBDataType##GPBDATATYPE_NAME2) { +//% return GPBCompute##GPBDATATYPE_NAME2##Size(fieldNum, value); +//% } else { +//% NSCAssert(NO, @"Unexpected type %d", dataType); +//% return 0; +//% } +//%} +//% +//%static void WriteDict##VALUE_NAME##Field(GPBCodedOutputStream *stream, VALUE_TYPE value, uint32_t fieldNum, GPBDataType dataType) { +//% if (dataType == GPBDataType##GPBDATATYPE_NAME1) { +//% [stream write##GPBDATATYPE_NAME1##:fieldNum value:value]; +//% } else if (dataType == GPBDataType##GPBDATATYPE_NAME2) { +//% [stream write##GPBDATATYPE_NAME2##:fieldNum value:value]; +//% } else { +//% NSCAssert(NO, @"Unexpected type %d", dataType); +//% } +//%} +//% +//%PDDM-DEFINE SERIALIZE_SUPPORT_3_TYPE(VALUE_NAME, VALUE_TYPE, GPBDATATYPE_NAME1, GPBDATATYPE_NAME2, GPBDATATYPE_NAME3) +//%static size_t ComputeDict##VALUE_NAME##FieldSize(VALUE_TYPE value, uint32_t fieldNum, GPBDataType dataType) { +//% if (dataType == GPBDataType##GPBDATATYPE_NAME1) { +//% return GPBCompute##GPBDATATYPE_NAME1##Size(fieldNum, value); +//% } else if (dataType == GPBDataType##GPBDATATYPE_NAME2) { +//% return GPBCompute##GPBDATATYPE_NAME2##Size(fieldNum, value); +//% } else if (dataType == GPBDataType##GPBDATATYPE_NAME3) { +//% return GPBCompute##GPBDATATYPE_NAME3##Size(fieldNum, value); +//% } else { +//% NSCAssert(NO, @"Unexpected type %d", dataType); +//% return 0; +//% } +//%} +//% +//%static void WriteDict##VALUE_NAME##Field(GPBCodedOutputStream *stream, VALUE_TYPE value, uint32_t fieldNum, GPBDataType dataType) { +//% if (dataType == GPBDataType##GPBDATATYPE_NAME1) { +//% [stream write##GPBDATATYPE_NAME1##:fieldNum value:value]; +//% } else if (dataType == GPBDataType##GPBDATATYPE_NAME2) { +//% [stream write##GPBDATATYPE_NAME2##:fieldNum value:value]; +//% } else if (dataType == GPBDataType##GPBDATATYPE_NAME3) { +//% [stream write##GPBDATATYPE_NAME3##:fieldNum value:value]; +//% } else { +//% NSCAssert(NO, @"Unexpected type %d", dataType); +//% } +//%} +//% +//%PDDM-DEFINE SIMPLE_SERIALIZE_SUPPORT(VALUE_NAME, VALUE_TYPE, VisP) +//%static size_t ComputeDict##VALUE_NAME##FieldSize(VALUE_TYPE VisP##value, uint32_t fieldNum, GPBDataType dataType) { +//% NSCAssert(dataType == GPBDataType##VALUE_NAME, @"bad type: %d", dataType); +//% #pragma unused(dataType) // For when asserts are off in release. +//% return GPBCompute##VALUE_NAME##Size(fieldNum, value); +//%} +//% +//%static void WriteDict##VALUE_NAME##Field(GPBCodedOutputStream *stream, VALUE_TYPE VisP##value, uint32_t fieldNum, GPBDataType dataType) { +//% NSCAssert(dataType == GPBDataType##VALUE_NAME, @"bad type: %d", dataType); +//% #pragma unused(dataType) // For when asserts are off in release. +//% [stream write##VALUE_NAME##:fieldNum value:value]; +//%} +//% +//%PDDM-DEFINE SERIALIZE_SUPPORT_HELPERS() +//%SERIALIZE_SUPPORT_3_TYPE(Int32, int32_t, Int32, SInt32, SFixed32) +//%SERIALIZE_SUPPORT_2_TYPE(UInt32, uint32_t, UInt32, Fixed32) +//%SERIALIZE_SUPPORT_3_TYPE(Int64, int64_t, Int64, SInt64, SFixed64) +//%SERIALIZE_SUPPORT_2_TYPE(UInt64, uint64_t, UInt64, Fixed64) +//%SIMPLE_SERIALIZE_SUPPORT(Bool, BOOL, ) +//%SIMPLE_SERIALIZE_SUPPORT(Enum, int32_t, ) +//%SIMPLE_SERIALIZE_SUPPORT(Float, float, ) +//%SIMPLE_SERIALIZE_SUPPORT(Double, double, ) +//%SIMPLE_SERIALIZE_SUPPORT(String, NSString, *) +//%SERIALIZE_SUPPORT_3_TYPE(Object, id, Message, String, Bytes) +//%PDDM-EXPAND SERIALIZE_SUPPORT_HELPERS() +// This block of code is generated, do not edit it directly. + +static size_t ComputeDictInt32FieldSize(int32_t value, uint32_t fieldNum, GPBDataType dataType) { + if (dataType == GPBDataTypeInt32) { + return GPBComputeInt32Size(fieldNum, value); + } else if (dataType == GPBDataTypeSInt32) { + return GPBComputeSInt32Size(fieldNum, value); + } else if (dataType == GPBDataTypeSFixed32) { + return GPBComputeSFixed32Size(fieldNum, value); + } else { + NSCAssert(NO, @"Unexpected type %d", dataType); + return 0; + } +} + +static void WriteDictInt32Field(GPBCodedOutputStream *stream, int32_t value, uint32_t fieldNum, GPBDataType dataType) { + if (dataType == GPBDataTypeInt32) { + [stream writeInt32:fieldNum value:value]; + } else if (dataType == GPBDataTypeSInt32) { + [stream writeSInt32:fieldNum value:value]; + } else if (dataType == GPBDataTypeSFixed32) { + [stream writeSFixed32:fieldNum value:value]; + } else { + NSCAssert(NO, @"Unexpected type %d", dataType); + } +} + +static size_t ComputeDictUInt32FieldSize(uint32_t value, uint32_t fieldNum, GPBDataType dataType) { + if (dataType == GPBDataTypeUInt32) { + return GPBComputeUInt32Size(fieldNum, value); + } else if (dataType == GPBDataTypeFixed32) { + return GPBComputeFixed32Size(fieldNum, value); + } else { + NSCAssert(NO, @"Unexpected type %d", dataType); + return 0; + } +} + +static void WriteDictUInt32Field(GPBCodedOutputStream *stream, uint32_t value, uint32_t fieldNum, GPBDataType dataType) { + if (dataType == GPBDataTypeUInt32) { + [stream writeUInt32:fieldNum value:value]; + } else if (dataType == GPBDataTypeFixed32) { + [stream writeFixed32:fieldNum value:value]; + } else { + NSCAssert(NO, @"Unexpected type %d", dataType); + } +} + +static size_t ComputeDictInt64FieldSize(int64_t value, uint32_t fieldNum, GPBDataType dataType) { + if (dataType == GPBDataTypeInt64) { + return GPBComputeInt64Size(fieldNum, value); + } else if (dataType == GPBDataTypeSInt64) { + return GPBComputeSInt64Size(fieldNum, value); + } else if (dataType == GPBDataTypeSFixed64) { + return GPBComputeSFixed64Size(fieldNum, value); + } else { + NSCAssert(NO, @"Unexpected type %d", dataType); + return 0; + } +} + +static void WriteDictInt64Field(GPBCodedOutputStream *stream, int64_t value, uint32_t fieldNum, GPBDataType dataType) { + if (dataType == GPBDataTypeInt64) { + [stream writeInt64:fieldNum value:value]; + } else if (dataType == GPBDataTypeSInt64) { + [stream writeSInt64:fieldNum value:value]; + } else if (dataType == GPBDataTypeSFixed64) { + [stream writeSFixed64:fieldNum value:value]; + } else { + NSCAssert(NO, @"Unexpected type %d", dataType); + } +} + +static size_t ComputeDictUInt64FieldSize(uint64_t value, uint32_t fieldNum, GPBDataType dataType) { + if (dataType == GPBDataTypeUInt64) { + return GPBComputeUInt64Size(fieldNum, value); + } else if (dataType == GPBDataTypeFixed64) { + return GPBComputeFixed64Size(fieldNum, value); + } else { + NSCAssert(NO, @"Unexpected type %d", dataType); + return 0; + } +} + +static void WriteDictUInt64Field(GPBCodedOutputStream *stream, uint64_t value, uint32_t fieldNum, GPBDataType dataType) { + if (dataType == GPBDataTypeUInt64) { + [stream writeUInt64:fieldNum value:value]; + } else if (dataType == GPBDataTypeFixed64) { + [stream writeFixed64:fieldNum value:value]; + } else { + NSCAssert(NO, @"Unexpected type %d", dataType); + } +} + +static size_t ComputeDictBoolFieldSize(BOOL value, uint32_t fieldNum, GPBDataType dataType) { + NSCAssert(dataType == GPBDataTypeBool, @"bad type: %d", dataType); + #pragma unused(dataType) // For when asserts are off in release. + return GPBComputeBoolSize(fieldNum, value); +} + +static void WriteDictBoolField(GPBCodedOutputStream *stream, BOOL value, uint32_t fieldNum, GPBDataType dataType) { + NSCAssert(dataType == GPBDataTypeBool, @"bad type: %d", dataType); + #pragma unused(dataType) // For when asserts are off in release. + [stream writeBool:fieldNum value:value]; +} + +static size_t ComputeDictEnumFieldSize(int32_t value, uint32_t fieldNum, GPBDataType dataType) { + NSCAssert(dataType == GPBDataTypeEnum, @"bad type: %d", dataType); + #pragma unused(dataType) // For when asserts are off in release. + return GPBComputeEnumSize(fieldNum, value); +} + +static void WriteDictEnumField(GPBCodedOutputStream *stream, int32_t value, uint32_t fieldNum, GPBDataType dataType) { + NSCAssert(dataType == GPBDataTypeEnum, @"bad type: %d", dataType); + #pragma unused(dataType) // For when asserts are off in release. + [stream writeEnum:fieldNum value:value]; +} + +static size_t ComputeDictFloatFieldSize(float value, uint32_t fieldNum, GPBDataType dataType) { + NSCAssert(dataType == GPBDataTypeFloat, @"bad type: %d", dataType); + #pragma unused(dataType) // For when asserts are off in release. + return GPBComputeFloatSize(fieldNum, value); +} + +static void WriteDictFloatField(GPBCodedOutputStream *stream, float value, uint32_t fieldNum, GPBDataType dataType) { + NSCAssert(dataType == GPBDataTypeFloat, @"bad type: %d", dataType); + #pragma unused(dataType) // For when asserts are off in release. + [stream writeFloat:fieldNum value:value]; +} + +static size_t ComputeDictDoubleFieldSize(double value, uint32_t fieldNum, GPBDataType dataType) { + NSCAssert(dataType == GPBDataTypeDouble, @"bad type: %d", dataType); + #pragma unused(dataType) // For when asserts are off in release. + return GPBComputeDoubleSize(fieldNum, value); +} + +static void WriteDictDoubleField(GPBCodedOutputStream *stream, double value, uint32_t fieldNum, GPBDataType dataType) { + NSCAssert(dataType == GPBDataTypeDouble, @"bad type: %d", dataType); + #pragma unused(dataType) // For when asserts are off in release. + [stream writeDouble:fieldNum value:value]; +} + +static size_t ComputeDictStringFieldSize(NSString *value, uint32_t fieldNum, GPBDataType dataType) { + NSCAssert(dataType == GPBDataTypeString, @"bad type: %d", dataType); + #pragma unused(dataType) // For when asserts are off in release. + return GPBComputeStringSize(fieldNum, value); +} + +static void WriteDictStringField(GPBCodedOutputStream *stream, NSString *value, uint32_t fieldNum, GPBDataType dataType) { + NSCAssert(dataType == GPBDataTypeString, @"bad type: %d", dataType); + #pragma unused(dataType) // For when asserts are off in release. + [stream writeString:fieldNum value:value]; +} + +static size_t ComputeDictObjectFieldSize(id value, uint32_t fieldNum, GPBDataType dataType) { + if (dataType == GPBDataTypeMessage) { + return GPBComputeMessageSize(fieldNum, value); + } else if (dataType == GPBDataTypeString) { + return GPBComputeStringSize(fieldNum, value); + } else if (dataType == GPBDataTypeBytes) { + return GPBComputeBytesSize(fieldNum, value); + } else { + NSCAssert(NO, @"Unexpected type %d", dataType); + return 0; + } +} + +static void WriteDictObjectField(GPBCodedOutputStream *stream, id value, uint32_t fieldNum, GPBDataType dataType) { + if (dataType == GPBDataTypeMessage) { + [stream writeMessage:fieldNum value:value]; + } else if (dataType == GPBDataTypeString) { + [stream writeString:fieldNum value:value]; + } else if (dataType == GPBDataTypeBytes) { + [stream writeBytes:fieldNum value:value]; + } else { + NSCAssert(NO, @"Unexpected type %d", dataType); + } +} + +//%PDDM-EXPAND-END SERIALIZE_SUPPORT_HELPERS() + +size_t GPBDictionaryComputeSizeInternalHelper(NSDictionary *dict, GPBFieldDescriptor *field) { + GPBDataType mapValueType = GPBGetFieldDataType(field); + size_t result = 0; + NSString *key; + NSEnumerator *keys = [dict keyEnumerator]; + while ((key = [keys nextObject])) { + id obj = dict[key]; + size_t msgSize = GPBComputeStringSize(kMapKeyFieldNumber, key); + msgSize += ComputeDictObjectFieldSize(obj, kMapValueFieldNumber, mapValueType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * dict.count; + return result; +} + +void GPBDictionaryWriteToStreamInternalHelper(GPBCodedOutputStream *outputStream, + NSDictionary *dict, + GPBFieldDescriptor *field) { + NSCAssert(field.mapKeyDataType == GPBDataTypeString, @"Unexpected key type"); + GPBDataType mapValueType = GPBGetFieldDataType(field); + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSString *key; + NSEnumerator *keys = [dict keyEnumerator]; + while ((key = [keys nextObject])) { + id obj = dict[key]; + // Write the tag. + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + size_t msgSize = GPBComputeStringSize(kMapKeyFieldNumber, key); + msgSize += ComputeDictObjectFieldSize(obj, kMapValueFieldNumber, mapValueType); + + // Write the size and fields. + [outputStream writeInt32NoTag:(int32_t)msgSize]; + [outputStream writeString:kMapKeyFieldNumber value:key]; + WriteDictObjectField(outputStream, obj, kMapValueFieldNumber, mapValueType); + } +} + +BOOL GPBDictionaryIsInitializedInternalHelper(NSDictionary *dict, GPBFieldDescriptor *field) { + NSCAssert(field.mapKeyDataType == GPBDataTypeString, @"Unexpected key type"); + NSCAssert(GPBGetFieldDataType(field) == GPBDataTypeMessage, @"Unexpected value type"); + #pragma unused(field) // For when asserts are off in release. + GPBMessage *msg; + NSEnumerator *objects = [dict objectEnumerator]; + while ((msg = [objects nextObject])) { + if (!msg.initialized) { + return NO; + } + } + return YES; +} + +// Note: if the type is an object, it the retain pass back to the caller. +static void ReadValue(GPBCodedInputStream *stream, + GPBGenericValue *valueToFill, + GPBDataType type, + GPBExtensionRegistry *registry, + GPBFieldDescriptor *field) { + switch (type) { + case GPBDataTypeBool: + valueToFill->valueBool = GPBCodedInputStreamReadBool(&stream->state_); + break; + case GPBDataTypeFixed32: + valueToFill->valueUInt32 = GPBCodedInputStreamReadFixed32(&stream->state_); + break; + case GPBDataTypeSFixed32: + valueToFill->valueInt32 = GPBCodedInputStreamReadSFixed32(&stream->state_); + break; + case GPBDataTypeFloat: + valueToFill->valueFloat = GPBCodedInputStreamReadFloat(&stream->state_); + break; + case GPBDataTypeFixed64: + valueToFill->valueUInt64 = GPBCodedInputStreamReadFixed64(&stream->state_); + break; + case GPBDataTypeSFixed64: + valueToFill->valueInt64 = GPBCodedInputStreamReadSFixed64(&stream->state_); + break; + case GPBDataTypeDouble: + valueToFill->valueDouble = GPBCodedInputStreamReadDouble(&stream->state_); + break; + case GPBDataTypeInt32: + valueToFill->valueInt32 = GPBCodedInputStreamReadInt32(&stream->state_); + break; + case GPBDataTypeInt64: + valueToFill->valueInt64 = GPBCodedInputStreamReadInt64(&stream->state_); + break; + case GPBDataTypeSInt32: + valueToFill->valueInt32 = GPBCodedInputStreamReadSInt32(&stream->state_); + break; + case GPBDataTypeSInt64: + valueToFill->valueInt64 = GPBCodedInputStreamReadSInt64(&stream->state_); + break; + case GPBDataTypeUInt32: + valueToFill->valueUInt32 = GPBCodedInputStreamReadUInt32(&stream->state_); + break; + case GPBDataTypeUInt64: + valueToFill->valueUInt64 = GPBCodedInputStreamReadUInt64(&stream->state_); + break; + case GPBDataTypeBytes: + [valueToFill->valueData release]; + valueToFill->valueData = GPBCodedInputStreamReadRetainedBytes(&stream->state_); + break; + case GPBDataTypeString: + [valueToFill->valueString release]; + valueToFill->valueString = GPBCodedInputStreamReadRetainedString(&stream->state_); + break; + case GPBDataTypeMessage: { + GPBMessage *message = [[field.msgClass alloc] init]; + [stream readMessage:message extensionRegistry:registry]; + [valueToFill->valueMessage release]; + valueToFill->valueMessage = message; + break; + } + case GPBDataTypeGroup: + NSCAssert(NO, @"Can't happen"); + break; + case GPBDataTypeEnum: + valueToFill->valueEnum = GPBCodedInputStreamReadEnum(&stream->state_); + break; + } +} + +void GPBDictionaryReadEntry(id mapDictionary, + GPBCodedInputStream *stream, + GPBExtensionRegistry *registry, + GPBFieldDescriptor *field, + GPBMessage *parentMessage) { + GPBDataType keyDataType = field.mapKeyDataType; + GPBDataType valueDataType = GPBGetFieldDataType(field); + + GPBGenericValue key; + GPBGenericValue value; + // Zero them (but pick up any enum default for proto2). + key.valueString = value.valueString = nil; + if (valueDataType == GPBDataTypeEnum) { + value = field.defaultValue; + } + + GPBCodedInputStreamState *state = &stream->state_; + uint32_t keyTag = + GPBWireFormatMakeTag(kMapKeyFieldNumber, GPBWireFormatForType(keyDataType, NO)); + uint32_t valueTag = + GPBWireFormatMakeTag(kMapValueFieldNumber, GPBWireFormatForType(valueDataType, NO)); + + BOOL hitError = NO; + while (YES) { + uint32_t tag = GPBCodedInputStreamReadTag(state); + if (tag == keyTag) { + ReadValue(stream, &key, keyDataType, registry, field); + } else if (tag == valueTag) { + ReadValue(stream, &value, valueDataType, registry, field); + } else if (tag == 0) { + // zero signals EOF / limit reached + break; + } else { // Unknown + if (![stream skipField:tag]){ + hitError = YES; + break; + } + } + } + + if (!hitError) { + // Handle the special defaults and/or missing key/value. + if ((keyDataType == GPBDataTypeString) && (key.valueString == nil)) { + key.valueString = [@"" retain]; + } + if (GPBDataTypeIsObject(valueDataType) && value.valueString == nil) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wswitch-enum" + switch (valueDataType) { + case GPBDataTypeString: + value.valueString = [@"" retain]; + break; + case GPBDataTypeBytes: + value.valueData = [GPBEmptyNSData() retain]; + break; +#if defined(__clang_analyzer__) + case GPBDataTypeGroup: + // Maps can't really have Groups as the value type, but this case is needed + // so the analyzer won't report the posibility of send nil in for the value + // in the NSMutableDictionary case below. +#endif + case GPBDataTypeMessage: { + value.valueMessage = [[field.msgClass alloc] init]; + break; + } + default: + // Nothing + break; + } +#pragma clang diagnostic pop + } + + if ((keyDataType == GPBDataTypeString) && GPBDataTypeIsObject(valueDataType)) { +#if GPB_STATIC_ANALYZER_ONLY(6020053, 7000181) + // Limited to Xcode 6.4 - 7.2, are known to fail here. The upper end can + // be raised as needed for new Xcodes. + // + // This is only needed on a "shallow" analyze; on a "deep" analyze, the + // existing code path gets this correct. In shallow, the analyzer decides + // GPBDataTypeIsObject(valueDataType) is both false and true on a single + // path through this function, allowing nil to be used for the + // setObject:forKey:. + if (value.valueString == nil) { + value.valueString = [@"" retain]; + } +#endif + // mapDictionary is an NSMutableDictionary + [(NSMutableDictionary *)mapDictionary setObject:value.valueString + forKey:key.valueString]; + } else { + if (valueDataType == GPBDataTypeEnum) { + if (GPBHasPreservingUnknownEnumSemantics([parentMessage descriptor].file.syntax) || + [field isValidEnumValue:value.valueEnum]) { + [mapDictionary setGPBGenericValue:&value forGPBGenericValueKey:&key]; + } else { + NSData *data = [mapDictionary serializedDataForUnknownValue:value.valueEnum + forKey:&key + keyDataType:keyDataType]; + [parentMessage addUnknownMapEntry:GPBFieldNumber(field) value:data]; + } + } else { + [mapDictionary setGPBGenericValue:&value forGPBGenericValueKey:&key]; + } + } + } + + if (GPBDataTypeIsObject(keyDataType)) { + [key.valueString release]; + } + if (GPBDataTypeIsObject(valueDataType)) { + [value.valueString release]; + } +} + +// +// Macros for the common basic cases. +// + +//%PDDM-DEFINE DICTIONARY_IMPL_FOR_POD_KEY(KEY_NAME, KEY_TYPE) +//%DICTIONARY_POD_IMPL_FOR_KEY(KEY_NAME, KEY_TYPE, , POD) +//%DICTIONARY_POD_KEY_TO_OBJECT_IMPL(KEY_NAME, KEY_TYPE, Object, id) + +//%PDDM-DEFINE DICTIONARY_POD_IMPL_FOR_KEY(KEY_NAME, KEY_TYPE, KisP, KHELPER) +//%DICTIONARY_KEY_TO_POD_IMPL(KEY_NAME, KEY_TYPE, KisP, UInt32, uint32_t, KHELPER) +//%DICTIONARY_KEY_TO_POD_IMPL(KEY_NAME, KEY_TYPE, KisP, Int32, int32_t, KHELPER) +//%DICTIONARY_KEY_TO_POD_IMPL(KEY_NAME, KEY_TYPE, KisP, UInt64, uint64_t, KHELPER) +//%DICTIONARY_KEY_TO_POD_IMPL(KEY_NAME, KEY_TYPE, KisP, Int64, int64_t, KHELPER) +//%DICTIONARY_KEY_TO_POD_IMPL(KEY_NAME, KEY_TYPE, KisP, Bool, BOOL, KHELPER) +//%DICTIONARY_KEY_TO_POD_IMPL(KEY_NAME, KEY_TYPE, KisP, Float, float, KHELPER) +//%DICTIONARY_KEY_TO_POD_IMPL(KEY_NAME, KEY_TYPE, KisP, Double, double, KHELPER) +//%DICTIONARY_KEY_TO_ENUM_IMPL(KEY_NAME, KEY_TYPE, KisP, Enum, int32_t, KHELPER) + +//%PDDM-DEFINE DICTIONARY_KEY_TO_POD_IMPL(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER) +//%DICTIONARY_COMMON_IMPL(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, POD, VALUE_NAME, value) + +//%PDDM-DEFINE DICTIONARY_POD_KEY_TO_OBJECT_IMPL(KEY_NAME, KEY_TYPE, VALUE_NAME, VALUE_TYPE) +//%DICTIONARY_COMMON_IMPL(KEY_NAME, KEY_TYPE, , VALUE_NAME, VALUE_TYPE, POD, OBJECT, Object, object) + +//%PDDM-DEFINE DICTIONARY_COMMON_IMPL(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, VNAME, VNAME_VAR) +//%#pragma mark - KEY_NAME -> VALUE_NAME +//% +//%@implementation GPB##KEY_NAME##VALUE_NAME##Dictionary { +//% @package +//% NSMutableDictionary *_dictionary; +//%} +//% +//%+ (instancetype)dictionary { +//% return [[[self alloc] initWith##VNAME##s:NULL forKeys:NULL count:0] autorelease]; +//%} +//% +//%+ (instancetype)dictionaryWith##VNAME##:(VALUE_TYPE)##VNAME_VAR +//% ##VNAME$S## forKey:(KEY_TYPE##KisP$S##KisP)key { +//% // Cast is needed so the compiler knows what class we are invoking initWith##VNAME##s:forKeys:count: +//% // on to get the type correct. +//% return [[(GPB##KEY_NAME##VALUE_NAME##Dictionary*)[self alloc] initWith##VNAME##s:&##VNAME_VAR +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:&key +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:1] autorelease]; +//%} +//% +//%+ (instancetype)dictionaryWith##VNAME##s:(const VALUE_TYPE [])##VNAME_VAR##s +//% ##VNAME$S## forKeys:(const KEY_TYPE##KisP$S##KisP [])keys +//% ##VNAME$S## count:(NSUInteger)count { +//% // Cast is needed so the compiler knows what class we are invoking initWith##VNAME##s:forKeys:count: +//% // on to get the type correct. +//% return [[(GPB##KEY_NAME##VALUE_NAME##Dictionary*)[self alloc] initWith##VNAME##s:##VNAME_VAR##s +//% KEY_NAME$S VALUE_NAME$S forKeys:keys +//% KEY_NAME$S VALUE_NAME$S count:count] autorelease]; +//%} +//% +//%+ (instancetype)dictionaryWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary { +//% // Cast is needed so the compiler knows what class we are invoking initWithDictionary: +//% // on to get the type correct. +//% return [[(GPB##KEY_NAME##VALUE_NAME##Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +//%} +//% +//%+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { +//% return [[[self alloc] initWithCapacity:numItems] autorelease]; +//%} +//% +//%- (instancetype)init { +//% return [self initWith##VNAME##s:NULL forKeys:NULL count:0]; +//%} +//% +//%- (instancetype)initWith##VNAME##s:(const VALUE_TYPE [])##VNAME_VAR##s +//% ##VNAME$S## forKeys:(const KEY_TYPE##KisP$S##KisP [])keys +//% ##VNAME$S## count:(NSUInteger)count { +//% self = [super init]; +//% if (self) { +//% _dictionary = [[NSMutableDictionary alloc] init]; +//% if (count && VNAME_VAR##s && keys) { +//% for (NSUInteger i = 0; i < count; ++i) { +//%DICTIONARY_VALIDATE_VALUE_##VHELPER(VNAME_VAR##s[i], ______)##DICTIONARY_VALIDATE_KEY_##KHELPER(keys[i], ______) [_dictionary setObject:WRAPPED##VHELPER(VNAME_VAR##s[i]) forKey:WRAPPED##KHELPER(keys[i])]; +//% } +//% } +//% } +//% return self; +//%} +//% +//%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary { +//% self = [self initWith##VNAME##s:NULL forKeys:NULL count:0]; +//% if (self) { +//% if (dictionary) { +//% [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; +//% } +//% } +//% return self; +//%} +//% +//%- (instancetype)initWithCapacity:(NSUInteger)numItems { +//% #pragma unused(numItems) +//% return [self initWith##VNAME##s:NULL forKeys:NULL count:0]; +//%} +//% +//%DICTIONARY_IMMUTABLE_CORE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, VNAME, VNAME_VAR, ) +//% +//%VALUE_FOR_KEY_##VHELPER(KEY_TYPE##KisP$S##KisP, VALUE_NAME, VALUE_TYPE, KHELPER) +//% +//%DICTIONARY_MUTABLE_CORE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, VNAME, VNAME_VAR, ) +//% +//%@end +//% + +//%PDDM-DEFINE DICTIONARY_KEY_TO_ENUM_IMPL(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER) +//%DICTIONARY_KEY_TO_ENUM_IMPL2(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, POD) +//%PDDM-DEFINE DICTIONARY_KEY_TO_ENUM_IMPL2(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER) +//%#pragma mark - KEY_NAME -> VALUE_NAME +//% +//%@implementation GPB##KEY_NAME##VALUE_NAME##Dictionary { +//% @package +//% NSMutableDictionary *_dictionary; +//% GPBEnumValidationFunc _validationFunc; +//%} +//% +//%@synthesize validationFunc = _validationFunc; +//% +//%+ (instancetype)dictionary { +//% return [[[self alloc] initWithValidationFunction:NULL +//% rawValues:NULL +//% forKeys:NULL +//% count:0] autorelease]; +//%} +//% +//%+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func { +//% return [[[self alloc] initWithValidationFunction:func +//% rawValues:NULL +//% forKeys:NULL +//% count:0] autorelease]; +//%} +//% +//%+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func +//% rawValue:(VALUE_TYPE)rawValue +//% forKey:(KEY_TYPE##KisP$S##KisP)key { +//% // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count: +//% // on to get the type correct. +//% return [[(GPB##KEY_NAME##VALUE_NAME##Dictionary*)[self alloc] initWithValidationFunction:func +//% KEY_NAME$S VALUE_NAME$S rawValues:&rawValue +//% KEY_NAME$S VALUE_NAME$S forKeys:&key +//% KEY_NAME$S VALUE_NAME$S count:1] autorelease]; +//%} +//% +//%+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func +//% rawValues:(const VALUE_TYPE [])rawValues +//% forKeys:(const KEY_TYPE##KisP$S##KisP [])keys +//% count:(NSUInteger)count { +//% // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count: +//% // on to get the type correct. +//% return [[(GPB##KEY_NAME##VALUE_NAME##Dictionary*)[self alloc] initWithValidationFunction:func +//% KEY_NAME$S VALUE_NAME$S rawValues:rawValues +//% KEY_NAME$S VALUE_NAME$S forKeys:keys +//% KEY_NAME$S VALUE_NAME$S count:count] autorelease]; +//%} +//% +//%+ (instancetype)dictionaryWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary { +//% // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count: +//% // on to get the type correct. +//% return [[(GPB##KEY_NAME##VALUE_NAME##Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +//%} +//% +//%+ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func +//% capacity:(NSUInteger)numItems { +//% return [[[self alloc] initWithValidationFunction:func capacity:numItems] autorelease]; +//%} +//% +//%- (instancetype)init { +//% return [self initWithValidationFunction:NULL rawValues:NULL forKeys:NULL count:0]; +//%} +//% +//%- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func { +//% return [self initWithValidationFunction:func rawValues:NULL forKeys:NULL count:0]; +//%} +//% +//%- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func +//% rawValues:(const VALUE_TYPE [])rawValues +//% forKeys:(const KEY_TYPE##KisP$S##KisP [])keys +//% count:(NSUInteger)count { +//% self = [super init]; +//% if (self) { +//% _dictionary = [[NSMutableDictionary alloc] init]; +//% _validationFunc = (func != NULL ? func : DictDefault_IsValidValue); +//% if (count && rawValues && keys) { +//% for (NSUInteger i = 0; i < count; ++i) { +//%DICTIONARY_VALIDATE_KEY_##KHELPER(keys[i], ______) [_dictionary setObject:WRAPPED##VHELPER(rawValues[i]) forKey:WRAPPED##KHELPER(keys[i])]; +//% } +//% } +//% } +//% return self; +//%} +//% +//%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary { +//% self = [self initWithValidationFunction:dictionary.validationFunc +//% rawValues:NULL +//% forKeys:NULL +//% count:0]; +//% if (self) { +//% if (dictionary) { +//% [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; +//% } +//% } +//% return self; +//%} +//% +//%- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func +//% capacity:(NSUInteger)numItems { +//% #pragma unused(numItems) +//% return [self initWithValidationFunction:func rawValues:NULL forKeys:NULL count:0]; +//%} +//% +//%DICTIONARY_IMMUTABLE_CORE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, Value, value, Raw) +//% +//%- (BOOL)getEnum:(VALUE_TYPE *)value forKey:(KEY_TYPE##KisP$S##KisP)key { +//% NSNumber *wrapped = [_dictionary objectForKey:WRAPPED##KHELPER(key)]; +//% if (wrapped && value) { +//% VALUE_TYPE result = UNWRAP##VALUE_NAME(wrapped); +//% if (!_validationFunc(result)) { +//% result = kGPBUnrecognizedEnumeratorValue; +//% } +//% *value = result; +//% } +//% return (wrapped != NULL); +//%} +//% +//%- (BOOL)getRawValue:(VALUE_TYPE *)rawValue forKey:(KEY_TYPE##KisP$S##KisP)key { +//% NSNumber *wrapped = [_dictionary objectForKey:WRAPPED##KHELPER(key)]; +//% if (wrapped && rawValue) { +//% *rawValue = UNWRAP##VALUE_NAME(wrapped); +//% } +//% return (wrapped != NULL); +//%} +//% +//%- (void)enumerateKeysAndEnumsUsingBlock: +//% (void (^)(KEY_TYPE KisP##key, VALUE_TYPE value, BOOL *stop))block { +//% GPBEnumValidationFunc func = _validationFunc; +//% BOOL stop = NO; +//% NSEnumerator *keys = [_dictionary keyEnumerator]; +//% ENUM_TYPE##KHELPER(KEY_TYPE)##aKey; +//% while ((aKey = [keys nextObject])) { +//% ENUM_TYPE##VHELPER(VALUE_TYPE)##aValue = _dictionary[aKey]; +//% VALUE_TYPE unwrapped = UNWRAP##VALUE_NAME(aValue); +//% if (!func(unwrapped)) { +//% unwrapped = kGPBUnrecognizedEnumeratorValue; +//% } +//% block(UNWRAP##KEY_NAME(aKey), unwrapped, &stop); +//% if (stop) { +//% break; +//% } +//% } +//%} +//% +//%DICTIONARY_MUTABLE_CORE2(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, Value, Enum, value, Raw) +//% +//%- (void)setEnum:(VALUE_TYPE)value forKey:(KEY_TYPE##KisP$S##KisP)key { +//%DICTIONARY_VALIDATE_KEY_##KHELPER(key, ) if (!_validationFunc(value)) { +//% [NSException raise:NSInvalidArgumentException +//% format:@"GPB##KEY_NAME##VALUE_NAME##Dictionary: Attempt to set an unknown enum value (%d)", +//% value]; +//% } +//% +//% [_dictionary setObject:WRAPPED##VHELPER(value) forKey:WRAPPED##KHELPER(key)]; +//% if (_autocreator) { +//% GPBAutocreatedDictionaryModified(_autocreator, self); +//% } +//%} +//% +//%@end +//% + +//%PDDM-DEFINE DICTIONARY_IMMUTABLE_CORE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, VNAME, VNAME_VAR, ACCESSOR_NAME) +//%- (void)dealloc { +//% NSAssert(!_autocreator, +//% @"%@: Autocreator must be cleared before release, autocreator: %@", +//% [self class], _autocreator); +//% [_dictionary release]; +//% [super dealloc]; +//%} +//% +//%- (instancetype)copyWithZone:(NSZone *)zone { +//% return [[GPB##KEY_NAME##VALUE_NAME##Dictionary allocWithZone:zone] initWithDictionary:self]; +//%} +//% +//%- (BOOL)isEqual:(id)other { +//% if (self == other) { +//% return YES; +//% } +//% if (![other isKindOfClass:[GPB##KEY_NAME##VALUE_NAME##Dictionary class]]) { +//% return NO; +//% } +//% GPB##KEY_NAME##VALUE_NAME##Dictionary *otherDictionary = other; +//% return [_dictionary isEqual:otherDictionary->_dictionary]; +//%} +//% +//%- (NSUInteger)hash { +//% return _dictionary.count; +//%} +//% +//%- (NSString *)description { +//% return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +//%} +//% +//%- (NSUInteger)count { +//% return _dictionary.count; +//%} +//% +//%- (void)enumerateKeysAnd##ACCESSOR_NAME##VNAME##sUsingBlock: +//% (void (^)(KEY_TYPE KisP##key, VALUE_TYPE VNAME_VAR, BOOL *stop))block { +//% BOOL stop = NO; +//% NSDictionary *internal = _dictionary; +//% NSEnumerator *keys = [internal keyEnumerator]; +//% ENUM_TYPE##KHELPER(KEY_TYPE)##aKey; +//% while ((aKey = [keys nextObject])) { +//% ENUM_TYPE##VHELPER(VALUE_TYPE)##a##VNAME_VAR$u = internal[aKey]; +//% block(UNWRAP##KEY_NAME(aKey), UNWRAP##VALUE_NAME(a##VNAME_VAR$u), &stop); +//% if (stop) { +//% break; +//% } +//% } +//%} +//% +//%EXTRA_METHODS_##VHELPER(KEY_NAME, VALUE_NAME)- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { +//% NSDictionary *internal = _dictionary; +//% NSUInteger count = internal.count; +//% if (count == 0) { +//% return 0; +//% } +//% +//% GPBDataType valueDataType = GPBGetFieldDataType(field); +//% GPBDataType keyDataType = field.mapKeyDataType; +//% size_t result = 0; +//% NSEnumerator *keys = [internal keyEnumerator]; +//% ENUM_TYPE##KHELPER(KEY_TYPE)##aKey; +//% while ((aKey = [keys nextObject])) { +//% ENUM_TYPE##VHELPER(VALUE_TYPE)##a##VNAME_VAR$u = internal[aKey]; +//% size_t msgSize = ComputeDict##KEY_NAME##FieldSize(UNWRAP##KEY_NAME(aKey), kMapKeyFieldNumber, keyDataType); +//% msgSize += ComputeDict##VALUE_NAME##FieldSize(UNWRAP##VALUE_NAME(a##VNAME_VAR$u), kMapValueFieldNumber, valueDataType); +//% result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; +//% } +//% size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); +//% result += tagSize * count; +//% return result; +//%} +//% +//%- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream +//% asField:(GPBFieldDescriptor *)field { +//% GPBDataType valueDataType = GPBGetFieldDataType(field); +//% GPBDataType keyDataType = field.mapKeyDataType; +//% uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); +//% NSDictionary *internal = _dictionary; +//% NSEnumerator *keys = [internal keyEnumerator]; +//% ENUM_TYPE##KHELPER(KEY_TYPE)##aKey; +//% while ((aKey = [keys nextObject])) { +//% ENUM_TYPE##VHELPER(VALUE_TYPE)##a##VNAME_VAR$u = internal[aKey]; +//% [outputStream writeInt32NoTag:tag]; +//% // Write the size of the message. +//% KEY_TYPE KisP##unwrappedKey = UNWRAP##KEY_NAME(aKey); +//% VALUE_TYPE unwrappedValue = UNWRAP##VALUE_NAME(a##VNAME_VAR$u); +//% size_t msgSize = ComputeDict##KEY_NAME##FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); +//% msgSize += ComputeDict##VALUE_NAME##FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); +//% [outputStream writeInt32NoTag:(int32_t)msgSize]; +//% // Write the fields. +//% WriteDict##KEY_NAME##Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); +//% WriteDict##VALUE_NAME##Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); +//% } +//%} +//% +//%SERIAL_DATA_FOR_ENTRY_##VHELPER(KEY_NAME, VALUE_NAME)- (void)setGPBGenericValue:(GPBGenericValue *)value +//% forGPBGenericValueKey:(GPBGenericValue *)key { +//% [_dictionary setObject:WRAPPED##VHELPER(value->##GPBVALUE_##VHELPER(VALUE_NAME)##) forKey:WRAPPED##KHELPER(key->value##KEY_NAME)]; +//%} +//% +//%- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { +//% [self enumerateKeysAnd##ACCESSOR_NAME##VNAME##sUsingBlock:^(KEY_TYPE KisP##key, VALUE_TYPE VNAME_VAR, BOOL *stop) { +//% #pragma unused(stop) +//% block(TEXT_FORMAT_OBJ##KEY_NAME(key), TEXT_FORMAT_OBJ##VALUE_NAME(VNAME_VAR)); +//% }]; +//%} +//%PDDM-DEFINE DICTIONARY_MUTABLE_CORE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, VNAME, VNAME_VAR, ACCESSOR_NAME) +//%DICTIONARY_MUTABLE_CORE2(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, VNAME, VNAME, VNAME_VAR, ACCESSOR_NAME) +//%PDDM-DEFINE DICTIONARY_MUTABLE_CORE2(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, KHELPER, VHELPER, VNAME, VNAME_REMOVE, VNAME_VAR, ACCESSOR_NAME) +//%- (void)add##ACCESSOR_NAME##EntriesFromDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)otherDictionary { +//% if (otherDictionary) { +//% [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; +//% if (_autocreator) { +//% GPBAutocreatedDictionaryModified(_autocreator, self); +//% } +//% } +//%} +//% +//%- (void)set##ACCESSOR_NAME##VNAME##:(VALUE_TYPE)VNAME_VAR forKey:(KEY_TYPE##KisP$S##KisP)key { +//%DICTIONARY_VALIDATE_VALUE_##VHELPER(VNAME_VAR, )##DICTIONARY_VALIDATE_KEY_##KHELPER(key, ) [_dictionary setObject:WRAPPED##VHELPER(VNAME_VAR) forKey:WRAPPED##KHELPER(key)]; +//% if (_autocreator) { +//% GPBAutocreatedDictionaryModified(_autocreator, self); +//% } +//%} +//% +//%- (void)remove##VNAME_REMOVE##ForKey:(KEY_TYPE##KisP$S##KisP)aKey { +//% [_dictionary removeObjectForKey:WRAPPED##KHELPER(aKey)]; +//%} +//% +//%- (void)removeAll { +//% [_dictionary removeAllObjects]; +//%} + +// +// Custom Generation for Bool keys +// + +//%PDDM-DEFINE DICTIONARY_BOOL_KEY_TO_POD_IMPL(VALUE_NAME, VALUE_TYPE) +//%DICTIONARY_BOOL_KEY_TO_VALUE_IMPL(VALUE_NAME, VALUE_TYPE, POD, VALUE_NAME, value) +//%PDDM-DEFINE DICTIONARY_BOOL_KEY_TO_OBJECT_IMPL(VALUE_NAME, VALUE_TYPE) +//%DICTIONARY_BOOL_KEY_TO_VALUE_IMPL(VALUE_NAME, VALUE_TYPE, OBJECT, Object, object) + +//%PDDM-DEFINE DICTIONARY_BOOL_KEY_TO_VALUE_IMPL(VALUE_NAME, VALUE_TYPE, HELPER, VNAME, VNAME_VAR) +//%#pragma mark - Bool -> VALUE_NAME +//% +//%@implementation GPBBool##VALUE_NAME##Dictionary { +//% @package +//% VALUE_TYPE _values[2]; +//%BOOL_DICT_HAS_STORAGE_##HELPER()} +//% +//%+ (instancetype)dictionary { +//% return [[[self alloc] initWith##VNAME##s:NULL forKeys:NULL count:0] autorelease]; +//%} +//% +//%+ (instancetype)dictionaryWith##VNAME##:(VALUE_TYPE)VNAME_VAR +//% ##VNAME$S## forKey:(BOOL)key { +//% // Cast is needed so the compiler knows what class we are invoking initWith##VNAME##s:forKeys:count: +//% // on to get the type correct. +//% return [[(GPBBool##VALUE_NAME##Dictionary*)[self alloc] initWith##VNAME##s:&##VNAME_VAR +//% VALUE_NAME$S ##VNAME$S## forKeys:&key +//% VALUE_NAME$S ##VNAME$S## count:1] autorelease]; +//%} +//% +//%+ (instancetype)dictionaryWith##VNAME##s:(const VALUE_TYPE [])##VNAME_VAR##s +//% ##VNAME$S## forKeys:(const BOOL [])keys +//% ##VNAME$S## count:(NSUInteger)count { +//% // Cast is needed so the compiler knows what class we are invoking initWith##VNAME##s:forKeys:count: +//% // on to get the type correct. +//% return [[(GPBBool##VALUE_NAME##Dictionary*)[self alloc] initWith##VNAME##s:##VNAME_VAR##s +//% VALUE_NAME$S ##VNAME$S## forKeys:keys +//% VALUE_NAME$S ##VNAME$S## count:count] autorelease]; +//%} +//% +//%+ (instancetype)dictionaryWithDictionary:(GPBBool##VALUE_NAME##Dictionary *)dictionary { +//% // Cast is needed so the compiler knows what class we are invoking initWithDictionary: +//% // on to get the type correct. +//% return [[(GPBBool##VALUE_NAME##Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +//%} +//% +//%+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { +//% return [[[self alloc] initWithCapacity:numItems] autorelease]; +//%} +//% +//%- (instancetype)init { +//% return [self initWith##VNAME##s:NULL forKeys:NULL count:0]; +//%} +//% +//%BOOL_DICT_INITS_##HELPER(VALUE_NAME, VALUE_TYPE) +//% +//%- (instancetype)initWithCapacity:(NSUInteger)numItems { +//% #pragma unused(numItems) +//% return [self initWith##VNAME##s:NULL forKeys:NULL count:0]; +//%} +//% +//%BOOL_DICT_DEALLOC##HELPER() +//% +//%- (instancetype)copyWithZone:(NSZone *)zone { +//% return [[GPBBool##VALUE_NAME##Dictionary allocWithZone:zone] initWithDictionary:self]; +//%} +//% +//%- (BOOL)isEqual:(id)other { +//% if (self == other) { +//% return YES; +//% } +//% if (![other isKindOfClass:[GPBBool##VALUE_NAME##Dictionary class]]) { +//% return NO; +//% } +//% GPBBool##VALUE_NAME##Dictionary *otherDictionary = other; +//% if ((BOOL_DICT_W_HAS##HELPER(0, ) != BOOL_DICT_W_HAS##HELPER(0, otherDictionary->)) || +//% (BOOL_DICT_W_HAS##HELPER(1, ) != BOOL_DICT_W_HAS##HELPER(1, otherDictionary->))) { +//% return NO; +//% } +//% if ((BOOL_DICT_W_HAS##HELPER(0, ) && (NEQ_##HELPER(_values[0], otherDictionary->_values[0]))) || +//% (BOOL_DICT_W_HAS##HELPER(1, ) && (NEQ_##HELPER(_values[1], otherDictionary->_values[1])))) { +//% return NO; +//% } +//% return YES; +//%} +//% +//%- (NSUInteger)hash { +//% return (BOOL_DICT_W_HAS##HELPER(0, ) ? 1 : 0) + (BOOL_DICT_W_HAS##HELPER(1, ) ? 1 : 0); +//%} +//% +//%- (NSString *)description { +//% NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> {", [self class], self]; +//% if (BOOL_DICT_W_HAS##HELPER(0, )) { +//% [result appendFormat:@"NO: STR_FORMAT_##HELPER(VALUE_NAME)", _values[0]]; +//% } +//% if (BOOL_DICT_W_HAS##HELPER(1, )) { +//% [result appendFormat:@"YES: STR_FORMAT_##HELPER(VALUE_NAME)", _values[1]]; +//% } +//% [result appendString:@" }"]; +//% return result; +//%} +//% +//%- (NSUInteger)count { +//% return (BOOL_DICT_W_HAS##HELPER(0, ) ? 1 : 0) + (BOOL_DICT_W_HAS##HELPER(1, ) ? 1 : 0); +//%} +//% +//%BOOL_VALUE_FOR_KEY_##HELPER(VALUE_NAME, VALUE_TYPE) +//% +//%BOOL_SET_GPBVALUE_FOR_KEY_##HELPER(VALUE_NAME, VALUE_TYPE, VisP) +//% +//%- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { +//% if (BOOL_DICT_HAS##HELPER(0, )) { +//% block(@"false", TEXT_FORMAT_OBJ##VALUE_NAME(_values[0])); +//% } +//% if (BOOL_DICT_W_HAS##HELPER(1, )) { +//% block(@"true", TEXT_FORMAT_OBJ##VALUE_NAME(_values[1])); +//% } +//%} +//% +//%- (void)enumerateKeysAnd##VNAME##sUsingBlock: +//% (void (^)(BOOL key, VALUE_TYPE VNAME_VAR, BOOL *stop))block { +//% BOOL stop = NO; +//% if (BOOL_DICT_HAS##HELPER(0, )) { +//% block(NO, _values[0], &stop); +//% } +//% if (!stop && BOOL_DICT_W_HAS##HELPER(1, )) { +//% block(YES, _values[1], &stop); +//% } +//%} +//% +//%BOOL_EXTRA_METHODS_##HELPER(Bool, VALUE_NAME)- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { +//% GPBDataType valueDataType = GPBGetFieldDataType(field); +//% NSUInteger count = 0; +//% size_t result = 0; +//% for (int i = 0; i < 2; ++i) { +//% if (BOOL_DICT_HAS##HELPER(i, )) { +//% ++count; +//% size_t msgSize = ComputeDictBoolFieldSize((i == 1), kMapKeyFieldNumber, GPBDataTypeBool); +//% msgSize += ComputeDict##VALUE_NAME##FieldSize(_values[i], kMapValueFieldNumber, valueDataType); +//% result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; +//% } +//% } +//% size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); +//% result += tagSize * count; +//% return result; +//%} +//% +//%- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream +//% asField:(GPBFieldDescriptor *)field { +//% GPBDataType valueDataType = GPBGetFieldDataType(field); +//% uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); +//% for (int i = 0; i < 2; ++i) { +//% if (BOOL_DICT_HAS##HELPER(i, )) { +//% // Write the tag. +//% [outputStream writeInt32NoTag:tag]; +//% // Write the size of the message. +//% size_t msgSize = ComputeDictBoolFieldSize((i == 1), kMapKeyFieldNumber, GPBDataTypeBool); +//% msgSize += ComputeDict##VALUE_NAME##FieldSize(_values[i], kMapValueFieldNumber, valueDataType); +//% [outputStream writeInt32NoTag:(int32_t)msgSize]; +//% // Write the fields. +//% WriteDictBoolField(outputStream, (i == 1), kMapKeyFieldNumber, GPBDataTypeBool); +//% WriteDict##VALUE_NAME##Field(outputStream, _values[i], kMapValueFieldNumber, valueDataType); +//% } +//% } +//%} +//% +//%BOOL_DICT_MUTATIONS_##HELPER(VALUE_NAME, VALUE_TYPE) +//% +//%@end +//% + + +// +// Helpers for PODs +// + +//%PDDM-DEFINE VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_NAME, VALUE_TYPE, KHELPER) +//%- (BOOL)get##VALUE_NAME##:(nullable VALUE_TYPE *)value forKey:(KEY_TYPE)key { +//% NSNumber *wrapped = [_dictionary objectForKey:WRAPPED##KHELPER(key)]; +//% if (wrapped && value) { +//% *value = UNWRAP##VALUE_NAME(wrapped); +//% } +//% return (wrapped != NULL); +//%} +//%PDDM-DEFINE WRAPPEDPOD(VALUE) +//%@(VALUE) +//%PDDM-DEFINE UNWRAPUInt32(VALUE) +//%[VALUE unsignedIntValue] +//%PDDM-DEFINE UNWRAPInt32(VALUE) +//%[VALUE intValue] +//%PDDM-DEFINE UNWRAPUInt64(VALUE) +//%[VALUE unsignedLongLongValue] +//%PDDM-DEFINE UNWRAPInt64(VALUE) +//%[VALUE longLongValue] +//%PDDM-DEFINE UNWRAPBool(VALUE) +//%[VALUE boolValue] +//%PDDM-DEFINE UNWRAPFloat(VALUE) +//%[VALUE floatValue] +//%PDDM-DEFINE UNWRAPDouble(VALUE) +//%[VALUE doubleValue] +//%PDDM-DEFINE UNWRAPEnum(VALUE) +//%[VALUE intValue] +//%PDDM-DEFINE TEXT_FORMAT_OBJUInt32(VALUE) +//%[NSString stringWithFormat:@"%u", VALUE] +//%PDDM-DEFINE TEXT_FORMAT_OBJInt32(VALUE) +//%[NSString stringWithFormat:@"%d", VALUE] +//%PDDM-DEFINE TEXT_FORMAT_OBJUInt64(VALUE) +//%[NSString stringWithFormat:@"%llu", VALUE] +//%PDDM-DEFINE TEXT_FORMAT_OBJInt64(VALUE) +//%[NSString stringWithFormat:@"%lld", VALUE] +//%PDDM-DEFINE TEXT_FORMAT_OBJBool(VALUE) +//%(VALUE ? @"true" : @"false") +//%PDDM-DEFINE TEXT_FORMAT_OBJFloat(VALUE) +//%[NSString stringWithFormat:@"%.*g", FLT_DIG, VALUE] +//%PDDM-DEFINE TEXT_FORMAT_OBJDouble(VALUE) +//%[NSString stringWithFormat:@"%.*lg", DBL_DIG, VALUE] +//%PDDM-DEFINE TEXT_FORMAT_OBJEnum(VALUE) +//%@(VALUE) +//%PDDM-DEFINE ENUM_TYPEPOD(TYPE) +//%NSNumber * +//%PDDM-DEFINE NEQ_POD(VAL1, VAL2) +//%VAL1 != VAL2 +//%PDDM-DEFINE EXTRA_METHODS_POD(KEY_NAME, VALUE_NAME) +// Empty +//%PDDM-DEFINE BOOL_EXTRA_METHODS_POD(KEY_NAME, VALUE_NAME) +// Empty +//%PDDM-DEFINE SERIAL_DATA_FOR_ENTRY_POD(KEY_NAME, VALUE_NAME) +//%SERIAL_DATA_FOR_ENTRY_POD_##VALUE_NAME(KEY_NAME) +//%PDDM-DEFINE SERIAL_DATA_FOR_ENTRY_POD_UInt32(KEY_NAME) +// Empty +//%PDDM-DEFINE SERIAL_DATA_FOR_ENTRY_POD_Int32(KEY_NAME) +// Empty +//%PDDM-DEFINE SERIAL_DATA_FOR_ENTRY_POD_UInt64(KEY_NAME) +// Empty +//%PDDM-DEFINE SERIAL_DATA_FOR_ENTRY_POD_Int64(KEY_NAME) +// Empty +//%PDDM-DEFINE SERIAL_DATA_FOR_ENTRY_POD_Bool(KEY_NAME) +// Empty +//%PDDM-DEFINE SERIAL_DATA_FOR_ENTRY_POD_Float(KEY_NAME) +// Empty +//%PDDM-DEFINE SERIAL_DATA_FOR_ENTRY_POD_Double(KEY_NAME) +// Empty +//%PDDM-DEFINE SERIAL_DATA_FOR_ENTRY_POD_Enum(KEY_NAME) +//%- (NSData *)serializedDataForUnknownValue:(int32_t)value +//% forKey:(GPBGenericValue *)key +//% keyDataType:(GPBDataType)keyDataType { +//% size_t msgSize = ComputeDict##KEY_NAME##FieldSize(key->value##KEY_NAME, kMapKeyFieldNumber, keyDataType); +//% msgSize += ComputeDictEnumFieldSize(value, kMapValueFieldNumber, GPBDataTypeEnum); +//% NSMutableData *data = [NSMutableData dataWithLength:msgSize]; +//% GPBCodedOutputStream *outputStream = [[GPBCodedOutputStream alloc] initWithData:data]; +//% WriteDict##KEY_NAME##Field(outputStream, key->value##KEY_NAME, kMapKeyFieldNumber, keyDataType); +//% WriteDictEnumField(outputStream, value, kMapValueFieldNumber, GPBDataTypeEnum); +//% [outputStream release]; +//% return data; +//%} +//% +//%PDDM-DEFINE GPBVALUE_POD(VALUE_NAME) +//%value##VALUE_NAME +//%PDDM-DEFINE DICTIONARY_VALIDATE_VALUE_POD(VALUE_NAME, EXTRA_INDENT) +// Empty +//%PDDM-DEFINE DICTIONARY_VALIDATE_KEY_POD(KEY_NAME, EXTRA_INDENT) +// Empty + +//%PDDM-DEFINE BOOL_DICT_HAS_STORAGE_POD() +//% BOOL _valueSet[2]; +//% +//%PDDM-DEFINE BOOL_DICT_INITS_POD(VALUE_NAME, VALUE_TYPE) +//%- (instancetype)initWith##VALUE_NAME##s:(const VALUE_TYPE [])values +//% ##VALUE_NAME$S## forKeys:(const BOOL [])keys +//% ##VALUE_NAME$S## count:(NSUInteger)count { +//% self = [super init]; +//% if (self) { +//% for (NSUInteger i = 0; i < count; ++i) { +//% int idx = keys[i] ? 1 : 0; +//% _values[idx] = values[i]; +//% _valueSet[idx] = YES; +//% } +//% } +//% return self; +//%} +//% +//%- (instancetype)initWithDictionary:(GPBBool##VALUE_NAME##Dictionary *)dictionary { +//% self = [self initWith##VALUE_NAME##s:NULL forKeys:NULL count:0]; +//% if (self) { +//% if (dictionary) { +//% for (int i = 0; i < 2; ++i) { +//% if (dictionary->_valueSet[i]) { +//% _values[i] = dictionary->_values[i]; +//% _valueSet[i] = YES; +//% } +//% } +//% } +//% } +//% return self; +//%} +//%PDDM-DEFINE BOOL_DICT_DEALLOCPOD() +//%#if !defined(NS_BLOCK_ASSERTIONS) +//%- (void)dealloc { +//% NSAssert(!_autocreator, +//% @"%@: Autocreator must be cleared before release, autocreator: %@", +//% [self class], _autocreator); +//% [super dealloc]; +//%} +//%#endif // !defined(NS_BLOCK_ASSERTIONS) +//%PDDM-DEFINE BOOL_DICT_W_HASPOD(IDX, REF) +//%BOOL_DICT_HASPOD(IDX, REF) +//%PDDM-DEFINE BOOL_DICT_HASPOD(IDX, REF) +//%REF##_valueSet[IDX] +//%PDDM-DEFINE BOOL_VALUE_FOR_KEY_POD(VALUE_NAME, VALUE_TYPE) +//%- (BOOL)get##VALUE_NAME##:(VALUE_TYPE *)value forKey:(BOOL)key { +//% int idx = (key ? 1 : 0); +//% if (_valueSet[idx]) { +//% if (value) { +//% *value = _values[idx]; +//% } +//% return YES; +//% } +//% return NO; +//%} +//%PDDM-DEFINE BOOL_SET_GPBVALUE_FOR_KEY_POD(VALUE_NAME, VALUE_TYPE, VisP) +//%- (void)setGPBGenericValue:(GPBGenericValue *)value +//% forGPBGenericValueKey:(GPBGenericValue *)key { +//% int idx = (key->valueBool ? 1 : 0); +//% _values[idx] = value->value##VALUE_NAME; +//% _valueSet[idx] = YES; +//%} +//%PDDM-DEFINE BOOL_DICT_MUTATIONS_POD(VALUE_NAME, VALUE_TYPE) +//%- (void)addEntriesFromDictionary:(GPBBool##VALUE_NAME##Dictionary *)otherDictionary { +//% if (otherDictionary) { +//% for (int i = 0; i < 2; ++i) { +//% if (otherDictionary->_valueSet[i]) { +//% _valueSet[i] = YES; +//% _values[i] = otherDictionary->_values[i]; +//% } +//% } +//% if (_autocreator) { +//% GPBAutocreatedDictionaryModified(_autocreator, self); +//% } +//% } +//%} +//% +//%- (void)set##VALUE_NAME:(VALUE_TYPE)value forKey:(BOOL)key { +//% int idx = (key ? 1 : 0); +//% _values[idx] = value; +//% _valueSet[idx] = YES; +//% if (_autocreator) { +//% GPBAutocreatedDictionaryModified(_autocreator, self); +//% } +//%} +//% +//%- (void)remove##VALUE_NAME##ForKey:(BOOL)aKey { +//% _valueSet[aKey ? 1 : 0] = NO; +//%} +//% +//%- (void)removeAll { +//% _valueSet[0] = NO; +//% _valueSet[1] = NO; +//%} +//%PDDM-DEFINE STR_FORMAT_POD(VALUE_NAME) +//%STR_FORMAT_##VALUE_NAME() +//%PDDM-DEFINE STR_FORMAT_UInt32() +//%%u +//%PDDM-DEFINE STR_FORMAT_Int32() +//%%d +//%PDDM-DEFINE STR_FORMAT_UInt64() +//%%llu +//%PDDM-DEFINE STR_FORMAT_Int64() +//%%lld +//%PDDM-DEFINE STR_FORMAT_Bool() +//%%d +//%PDDM-DEFINE STR_FORMAT_Float() +//%%f +//%PDDM-DEFINE STR_FORMAT_Double() +//%%lf + +// +// Helpers for Objects +// + +//%PDDM-DEFINE VALUE_FOR_KEY_OBJECT(KEY_TYPE, VALUE_NAME, VALUE_TYPE, KHELPER) +//%- (VALUE_TYPE)objectForKey:(KEY_TYPE)key { +//% VALUE_TYPE result = [_dictionary objectForKey:WRAPPED##KHELPER(key)]; +//% return result; +//%} +//%PDDM-DEFINE WRAPPEDOBJECT(VALUE) +//%VALUE +//%PDDM-DEFINE UNWRAPString(VALUE) +//%VALUE +//%PDDM-DEFINE UNWRAPObject(VALUE) +//%VALUE +//%PDDM-DEFINE TEXT_FORMAT_OBJString(VALUE) +//%VALUE +//%PDDM-DEFINE TEXT_FORMAT_OBJObject(VALUE) +//%VALUE +//%PDDM-DEFINE ENUM_TYPEOBJECT(TYPE) +//%ENUM_TYPEOBJECT_##TYPE() +//%PDDM-DEFINE ENUM_TYPEOBJECT_NSString() +//%NSString * +//%PDDM-DEFINE ENUM_TYPEOBJECT_id() +//%id ## +//%PDDM-DEFINE NEQ_OBJECT(VAL1, VAL2) +//%![VAL1 isEqual:VAL2] +//%PDDM-DEFINE EXTRA_METHODS_OBJECT(KEY_NAME, VALUE_NAME) +//%- (BOOL)isInitialized { +//% for (GPBMessage *msg in [_dictionary objectEnumerator]) { +//% if (!msg.initialized) { +//% return NO; +//% } +//% } +//% return YES; +//%} +//% +//%- (instancetype)deepCopyWithZone:(NSZone *)zone { +//% GPB##KEY_NAME##VALUE_NAME##Dictionary *newDict = +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init]; +//% NSEnumerator *keys = [_dictionary keyEnumerator]; +//% id aKey; +//% NSMutableDictionary *internalDict = newDict->_dictionary; +//% while ((aKey = [keys nextObject])) { +//% GPBMessage *msg = _dictionary[aKey]; +//% GPBMessage *copiedMsg = [msg copyWithZone:zone]; +//% [internalDict setObject:copiedMsg forKey:aKey]; +//% [copiedMsg release]; +//% } +//% return newDict; +//%} +//% +//% +//%PDDM-DEFINE BOOL_EXTRA_METHODS_OBJECT(KEY_NAME, VALUE_NAME) +//%- (BOOL)isInitialized { +//% if (_values[0] && ![_values[0] isInitialized]) { +//% return NO; +//% } +//% if (_values[1] && ![_values[1] isInitialized]) { +//% return NO; +//% } +//% return YES; +//%} +//% +//%- (instancetype)deepCopyWithZone:(NSZone *)zone { +//% GPB##KEY_NAME##VALUE_NAME##Dictionary *newDict = +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init]; +//% for (int i = 0; i < 2; ++i) { +//% if (_values[i] != nil) { +//% newDict->_values[i] = [_values[i] copyWithZone:zone]; +//% } +//% } +//% return newDict; +//%} +//% +//% +//%PDDM-DEFINE SERIAL_DATA_FOR_ENTRY_OBJECT(KEY_NAME, VALUE_NAME) +// Empty +//%PDDM-DEFINE GPBVALUE_OBJECT(VALUE_NAME) +//%valueString +//%PDDM-DEFINE DICTIONARY_VALIDATE_VALUE_OBJECT(VALUE_NAME, EXTRA_INDENT) +//%##EXTRA_INDENT$S## if (!##VALUE_NAME) { +//%##EXTRA_INDENT$S## [NSException raise:NSInvalidArgumentException +//%##EXTRA_INDENT$S## format:@"Attempting to add nil object to a Dictionary"]; +//%##EXTRA_INDENT$S## } +//% +//%PDDM-DEFINE DICTIONARY_VALIDATE_KEY_OBJECT(KEY_NAME, EXTRA_INDENT) +//%##EXTRA_INDENT$S## if (!##KEY_NAME) { +//%##EXTRA_INDENT$S## [NSException raise:NSInvalidArgumentException +//%##EXTRA_INDENT$S## format:@"Attempting to add nil key to a Dictionary"]; +//%##EXTRA_INDENT$S## } +//% + +//%PDDM-DEFINE BOOL_DICT_HAS_STORAGE_OBJECT() +// Empty +//%PDDM-DEFINE BOOL_DICT_INITS_OBJECT(VALUE_NAME, VALUE_TYPE) +//%- (instancetype)initWithObjects:(const VALUE_TYPE [])objects +//% forKeys:(const BOOL [])keys +//% count:(NSUInteger)count { +//% self = [super init]; +//% if (self) { +//% for (NSUInteger i = 0; i < count; ++i) { +//% if (!objects[i]) { +//% [NSException raise:NSInvalidArgumentException +//% format:@"Attempting to add nil object to a Dictionary"]; +//% } +//% int idx = keys[i] ? 1 : 0; +//% [_values[idx] release]; +//% _values[idx] = (VALUE_TYPE)[objects[i] retain]; +//% } +//% } +//% return self; +//%} +//% +//%- (instancetype)initWithDictionary:(GPBBool##VALUE_NAME##Dictionary *)dictionary { +//% self = [self initWithObjects:NULL forKeys:NULL count:0]; +//% if (self) { +//% if (dictionary) { +//% _values[0] = [dictionary->_values[0] retain]; +//% _values[1] = [dictionary->_values[1] retain]; +//% } +//% } +//% return self; +//%} +//%PDDM-DEFINE BOOL_DICT_DEALLOCOBJECT() +//%- (void)dealloc { +//% NSAssert(!_autocreator, +//% @"%@: Autocreator must be cleared before release, autocreator: %@", +//% [self class], _autocreator); +//% [_values[0] release]; +//% [_values[1] release]; +//% [super dealloc]; +//%} +//%PDDM-DEFINE BOOL_DICT_W_HASOBJECT(IDX, REF) +//%(BOOL_DICT_HASOBJECT(IDX, REF)) +//%PDDM-DEFINE BOOL_DICT_HASOBJECT(IDX, REF) +//%REF##_values[IDX] != nil +//%PDDM-DEFINE BOOL_VALUE_FOR_KEY_OBJECT(VALUE_NAME, VALUE_TYPE) +//%- (VALUE_TYPE)objectForKey:(BOOL)key { +//% return _values[key ? 1 : 0]; +//%} +//%PDDM-DEFINE BOOL_SET_GPBVALUE_FOR_KEY_OBJECT(VALUE_NAME, VALUE_TYPE, VisP) +//%- (void)setGPBGenericValue:(GPBGenericValue *)value +//% forGPBGenericValueKey:(GPBGenericValue *)key { +//% int idx = (key->valueBool ? 1 : 0); +//% [_values[idx] release]; +//% _values[idx] = [value->valueString retain]; +//%} + +//%PDDM-DEFINE BOOL_DICT_MUTATIONS_OBJECT(VALUE_NAME, VALUE_TYPE) +//%- (void)addEntriesFromDictionary:(GPBBool##VALUE_NAME##Dictionary *)otherDictionary { +//% if (otherDictionary) { +//% for (int i = 0; i < 2; ++i) { +//% if (otherDictionary->_values[i] != nil) { +//% [_values[i] release]; +//% _values[i] = [otherDictionary->_values[i] retain]; +//% } +//% } +//% if (_autocreator) { +//% GPBAutocreatedDictionaryModified(_autocreator, self); +//% } +//% } +//%} +//% +//%- (void)setObject:(VALUE_TYPE)object forKey:(BOOL)key { +//% if (!object) { +//% [NSException raise:NSInvalidArgumentException +//% format:@"Attempting to add nil object to a Dictionary"]; +//% } +//% int idx = (key ? 1 : 0); +//% [_values[idx] release]; +//% _values[idx] = [object retain]; +//% if (_autocreator) { +//% GPBAutocreatedDictionaryModified(_autocreator, self); +//% } +//%} +//% +//%- (void)removeObjectForKey:(BOOL)aKey { +//% int idx = (aKey ? 1 : 0); +//% [_values[idx] release]; +//% _values[idx] = nil; +//%} +//% +//%- (void)removeAll { +//% for (int i = 0; i < 2; ++i) { +//% [_values[i] release]; +//% _values[i] = nil; +//% } +//%} +//%PDDM-DEFINE STR_FORMAT_OBJECT(VALUE_NAME) +//%%@ + + +//%PDDM-EXPAND DICTIONARY_IMPL_FOR_POD_KEY(UInt32, uint32_t) +// This block of code is generated, do not edit it directly. + +#pragma mark - UInt32 -> UInt32 + +@implementation GPBUInt32UInt32Dictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithUInt32s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithUInt32:(uint32_t)value + forKey:(uint32_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithUInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBUInt32UInt32Dictionary*)[self alloc] initWithUInt32s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithUInt32s:(const uint32_t [])values + forKeys:(const uint32_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithUInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBUInt32UInt32Dictionary*)[self alloc] initWithUInt32s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBUInt32UInt32Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBUInt32UInt32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithUInt32s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithUInt32s:(const uint32_t [])values + forKeys:(const uint32_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBUInt32UInt32Dictionary *)dictionary { + self = [self initWithUInt32s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithUInt32s:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBUInt32UInt32Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBUInt32UInt32Dictionary class]]) { + return NO; + } + GPBUInt32UInt32Dictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndUInt32sUsingBlock: + (void (^)(uint32_t key, uint32_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey unsignedIntValue], [aValue unsignedIntValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictUInt32FieldSize([aValue unsignedIntValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + uint32_t unwrappedKey = [aKey unsignedIntValue]; + uint32_t unwrappedValue = [aValue unsignedIntValue]; + size_t msgSize = ComputeDictUInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictUInt32FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictUInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictUInt32Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueUInt32) forKey:@(key->valueUInt32)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndUInt32sUsingBlock:^(uint32_t key, uint32_t value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%u", key], [NSString stringWithFormat:@"%u", value]); + }]; +} + +- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(uint32_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped unsignedIntValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBUInt32UInt32Dictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setUInt32:(uint32_t)value forKey:(uint32_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeUInt32ForKey:(uint32_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - UInt32 -> Int32 + +@implementation GPBUInt32Int32Dictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithInt32s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithInt32:(int32_t)value + forKey:(uint32_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBUInt32Int32Dictionary*)[self alloc] initWithInt32s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithInt32s:(const int32_t [])values + forKeys:(const uint32_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBUInt32Int32Dictionary*)[self alloc] initWithInt32s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBUInt32Int32Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBUInt32Int32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithInt32s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithInt32s:(const int32_t [])values + forKeys:(const uint32_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBUInt32Int32Dictionary *)dictionary { + self = [self initWithInt32s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithInt32s:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBUInt32Int32Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBUInt32Int32Dictionary class]]) { + return NO; + } + GPBUInt32Int32Dictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndInt32sUsingBlock: + (void (^)(uint32_t key, int32_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey unsignedIntValue], [aValue intValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictInt32FieldSize([aValue intValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + uint32_t unwrappedKey = [aKey unsignedIntValue]; + int32_t unwrappedValue = [aValue intValue]; + size_t msgSize = ComputeDictUInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictInt32FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictUInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictInt32Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueInt32) forKey:@(key->valueUInt32)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndInt32sUsingBlock:^(uint32_t key, int32_t value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%u", key], [NSString stringWithFormat:@"%d", value]); + }]; +} + +- (BOOL)getInt32:(nullable int32_t *)value forKey:(uint32_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped intValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBUInt32Int32Dictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setInt32:(int32_t)value forKey:(uint32_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeInt32ForKey:(uint32_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - UInt32 -> UInt64 + +@implementation GPBUInt32UInt64Dictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithUInt64s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithUInt64:(uint64_t)value + forKey:(uint32_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithUInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBUInt32UInt64Dictionary*)[self alloc] initWithUInt64s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithUInt64s:(const uint64_t [])values + forKeys:(const uint32_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithUInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBUInt32UInt64Dictionary*)[self alloc] initWithUInt64s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBUInt32UInt64Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBUInt32UInt64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithUInt64s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithUInt64s:(const uint64_t [])values + forKeys:(const uint32_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBUInt32UInt64Dictionary *)dictionary { + self = [self initWithUInt64s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithUInt64s:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBUInt32UInt64Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBUInt32UInt64Dictionary class]]) { + return NO; + } + GPBUInt32UInt64Dictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndUInt64sUsingBlock: + (void (^)(uint32_t key, uint64_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey unsignedIntValue], [aValue unsignedLongLongValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictUInt64FieldSize([aValue unsignedLongLongValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + uint32_t unwrappedKey = [aKey unsignedIntValue]; + uint64_t unwrappedValue = [aValue unsignedLongLongValue]; + size_t msgSize = ComputeDictUInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictUInt64FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictUInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictUInt64Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueUInt64) forKey:@(key->valueUInt32)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndUInt64sUsingBlock:^(uint32_t key, uint64_t value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%u", key], [NSString stringWithFormat:@"%llu", value]); + }]; +} + +- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(uint32_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped unsignedLongLongValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBUInt32UInt64Dictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setUInt64:(uint64_t)value forKey:(uint32_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeUInt64ForKey:(uint32_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - UInt32 -> Int64 + +@implementation GPBUInt32Int64Dictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithInt64s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithInt64:(int64_t)value + forKey:(uint32_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBUInt32Int64Dictionary*)[self alloc] initWithInt64s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithInt64s:(const int64_t [])values + forKeys:(const uint32_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBUInt32Int64Dictionary*)[self alloc] initWithInt64s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBUInt32Int64Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBUInt32Int64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithInt64s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithInt64s:(const int64_t [])values + forKeys:(const uint32_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBUInt32Int64Dictionary *)dictionary { + self = [self initWithInt64s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithInt64s:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBUInt32Int64Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBUInt32Int64Dictionary class]]) { + return NO; + } + GPBUInt32Int64Dictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndInt64sUsingBlock: + (void (^)(uint32_t key, int64_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey unsignedIntValue], [aValue longLongValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictInt64FieldSize([aValue longLongValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + uint32_t unwrappedKey = [aKey unsignedIntValue]; + int64_t unwrappedValue = [aValue longLongValue]; + size_t msgSize = ComputeDictUInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictInt64FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictUInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictInt64Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueInt64) forKey:@(key->valueUInt32)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndInt64sUsingBlock:^(uint32_t key, int64_t value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%u", key], [NSString stringWithFormat:@"%lld", value]); + }]; +} + +- (BOOL)getInt64:(nullable int64_t *)value forKey:(uint32_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped longLongValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBUInt32Int64Dictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setInt64:(int64_t)value forKey:(uint32_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeInt64ForKey:(uint32_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - UInt32 -> Bool + +@implementation GPBUInt32BoolDictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithBools:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithBool:(BOOL)value + forKey:(uint32_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithBools:forKeys:count: + // on to get the type correct. + return [[(GPBUInt32BoolDictionary*)[self alloc] initWithBools:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithBools:(const BOOL [])values + forKeys:(const uint32_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithBools:forKeys:count: + // on to get the type correct. + return [[(GPBUInt32BoolDictionary*)[self alloc] initWithBools:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBUInt32BoolDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBUInt32BoolDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithBools:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithBools:(const BOOL [])values + forKeys:(const uint32_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBUInt32BoolDictionary *)dictionary { + self = [self initWithBools:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithBools:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBUInt32BoolDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBUInt32BoolDictionary class]]) { + return NO; + } + GPBUInt32BoolDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndBoolsUsingBlock: + (void (^)(uint32_t key, BOOL value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey unsignedIntValue], [aValue boolValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictBoolFieldSize([aValue boolValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + uint32_t unwrappedKey = [aKey unsignedIntValue]; + BOOL unwrappedValue = [aValue boolValue]; + size_t msgSize = ComputeDictUInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictBoolFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictUInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictBoolField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueBool) forKey:@(key->valueUInt32)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndBoolsUsingBlock:^(uint32_t key, BOOL value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%u", key], (value ? @"true" : @"false")); + }]; +} + +- (BOOL)getBool:(nullable BOOL *)value forKey:(uint32_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped boolValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBUInt32BoolDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setBool:(BOOL)value forKey:(uint32_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeBoolForKey:(uint32_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - UInt32 -> Float + +@implementation GPBUInt32FloatDictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithFloats:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithFloat:(float)value + forKey:(uint32_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithFloats:forKeys:count: + // on to get the type correct. + return [[(GPBUInt32FloatDictionary*)[self alloc] initWithFloats:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithFloats:(const float [])values + forKeys:(const uint32_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithFloats:forKeys:count: + // on to get the type correct. + return [[(GPBUInt32FloatDictionary*)[self alloc] initWithFloats:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBUInt32FloatDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBUInt32FloatDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithFloats:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithFloats:(const float [])values + forKeys:(const uint32_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBUInt32FloatDictionary *)dictionary { + self = [self initWithFloats:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithFloats:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBUInt32FloatDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBUInt32FloatDictionary class]]) { + return NO; + } + GPBUInt32FloatDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndFloatsUsingBlock: + (void (^)(uint32_t key, float value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey unsignedIntValue], [aValue floatValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictFloatFieldSize([aValue floatValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + uint32_t unwrappedKey = [aKey unsignedIntValue]; + float unwrappedValue = [aValue floatValue]; + size_t msgSize = ComputeDictUInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictFloatFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictUInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictFloatField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueFloat) forKey:@(key->valueUInt32)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndFloatsUsingBlock:^(uint32_t key, float value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%u", key], [NSString stringWithFormat:@"%.*g", FLT_DIG, value]); + }]; +} + +- (BOOL)getFloat:(nullable float *)value forKey:(uint32_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped floatValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBUInt32FloatDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setFloat:(float)value forKey:(uint32_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeFloatForKey:(uint32_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - UInt32 -> Double + +@implementation GPBUInt32DoubleDictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithDoubles:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithDouble:(double)value + forKey:(uint32_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithDoubles:forKeys:count: + // on to get the type correct. + return [[(GPBUInt32DoubleDictionary*)[self alloc] initWithDoubles:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithDoubles:(const double [])values + forKeys:(const uint32_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithDoubles:forKeys:count: + // on to get the type correct. + return [[(GPBUInt32DoubleDictionary*)[self alloc] initWithDoubles:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBUInt32DoubleDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBUInt32DoubleDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithDoubles:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithDoubles:(const double [])values + forKeys:(const uint32_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBUInt32DoubleDictionary *)dictionary { + self = [self initWithDoubles:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithDoubles:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBUInt32DoubleDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBUInt32DoubleDictionary class]]) { + return NO; + } + GPBUInt32DoubleDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndDoublesUsingBlock: + (void (^)(uint32_t key, double value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey unsignedIntValue], [aValue doubleValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictDoubleFieldSize([aValue doubleValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + uint32_t unwrappedKey = [aKey unsignedIntValue]; + double unwrappedValue = [aValue doubleValue]; + size_t msgSize = ComputeDictUInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictDoubleFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictUInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictDoubleField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueDouble) forKey:@(key->valueUInt32)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndDoublesUsingBlock:^(uint32_t key, double value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%u", key], [NSString stringWithFormat:@"%.*lg", DBL_DIG, value]); + }]; +} + +- (BOOL)getDouble:(nullable double *)value forKey:(uint32_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped doubleValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBUInt32DoubleDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setDouble:(double)value forKey:(uint32_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeDoubleForKey:(uint32_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - UInt32 -> Enum + +@implementation GPBUInt32EnumDictionary { + @package + NSMutableDictionary *_dictionary; + GPBEnumValidationFunc _validationFunc; +} + +@synthesize validationFunc = _validationFunc; + ++ (instancetype)dictionary { + return [[[self alloc] initWithValidationFunction:NULL + rawValues:NULL + forKeys:NULL + count:0] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func { + return [[[self alloc] initWithValidationFunction:func + rawValues:NULL + forKeys:NULL + count:0] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func + rawValue:(int32_t)rawValue + forKey:(uint32_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count: + // on to get the type correct. + return [[(GPBUInt32EnumDictionary*)[self alloc] initWithValidationFunction:func + rawValues:&rawValue + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func + rawValues:(const int32_t [])rawValues + forKeys:(const uint32_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count: + // on to get the type correct. + return [[(GPBUInt32EnumDictionary*)[self alloc] initWithValidationFunction:func + rawValues:rawValues + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBUInt32EnumDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count: + // on to get the type correct. + return [[(GPBUInt32EnumDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems { + return [[[self alloc] initWithValidationFunction:func capacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithValidationFunction:NULL rawValues:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func { + return [self initWithValidationFunction:func rawValues:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func + rawValues:(const int32_t [])rawValues + forKeys:(const uint32_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + _validationFunc = (func != NULL ? func : DictDefault_IsValidValue); + if (count && rawValues && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(rawValues[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBUInt32EnumDictionary *)dictionary { + self = [self initWithValidationFunction:dictionary.validationFunc + rawValues:NULL + forKeys:NULL + count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithValidationFunction:func rawValues:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBUInt32EnumDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBUInt32EnumDictionary class]]) { + return NO; + } + GPBUInt32EnumDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndRawValuesUsingBlock: + (void (^)(uint32_t key, int32_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey unsignedIntValue], [aValue intValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictEnumFieldSize([aValue intValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + uint32_t unwrappedKey = [aKey unsignedIntValue]; + int32_t unwrappedValue = [aValue intValue]; + size_t msgSize = ComputeDictUInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictEnumFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictUInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictEnumField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (NSData *)serializedDataForUnknownValue:(int32_t)value + forKey:(GPBGenericValue *)key + keyDataType:(GPBDataType)keyDataType { + size_t msgSize = ComputeDictUInt32FieldSize(key->valueUInt32, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictEnumFieldSize(value, kMapValueFieldNumber, GPBDataTypeEnum); + NSMutableData *data = [NSMutableData dataWithLength:msgSize]; + GPBCodedOutputStream *outputStream = [[GPBCodedOutputStream alloc] initWithData:data]; + WriteDictUInt32Field(outputStream, key->valueUInt32, kMapKeyFieldNumber, keyDataType); + WriteDictEnumField(outputStream, value, kMapValueFieldNumber, GPBDataTypeEnum); + [outputStream release]; + return data; +} +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueEnum) forKey:@(key->valueUInt32)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndRawValuesUsingBlock:^(uint32_t key, int32_t value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%u", key], @(value)); + }]; +} + +- (BOOL)getEnum:(int32_t *)value forKey:(uint32_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + int32_t result = [wrapped intValue]; + if (!_validationFunc(result)) { + result = kGPBUnrecognizedEnumeratorValue; + } + *value = result; + } + return (wrapped != NULL); +} + +- (BOOL)getRawValue:(int32_t *)rawValue forKey:(uint32_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && rawValue) { + *rawValue = [wrapped intValue]; + } + return (wrapped != NULL); +} + +- (void)enumerateKeysAndEnumsUsingBlock: + (void (^)(uint32_t key, int32_t value, BOOL *stop))block { + GPBEnumValidationFunc func = _validationFunc; + BOOL stop = NO; + NSEnumerator *keys = [_dictionary keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = _dictionary[aKey]; + int32_t unwrapped = [aValue intValue]; + if (!func(unwrapped)) { + unwrapped = kGPBUnrecognizedEnumeratorValue; + } + block([aKey unsignedIntValue], unwrapped, &stop); + if (stop) { + break; + } + } +} + +- (void)addRawEntriesFromDictionary:(GPBUInt32EnumDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setRawValue:(int32_t)value forKey:(uint32_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeEnumForKey:(uint32_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +- (void)setEnum:(int32_t)value forKey:(uint32_t)key { + if (!_validationFunc(value)) { + [NSException raise:NSInvalidArgumentException + format:@"GPBUInt32EnumDictionary: Attempt to set an unknown enum value (%d)", + value]; + } + + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +@end + +#pragma mark - UInt32 -> Object + +@implementation GPBUInt32ObjectDictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithObjects:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithObject:(id)object + forKey:(uint32_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithObjects:forKeys:count: + // on to get the type correct. + return [[(GPBUInt32ObjectDictionary*)[self alloc] initWithObjects:&object + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithObjects:(const id [])objects + forKeys:(const uint32_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithObjects:forKeys:count: + // on to get the type correct. + return [[(GPBUInt32ObjectDictionary*)[self alloc] initWithObjects:objects + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBUInt32ObjectDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBUInt32ObjectDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithObjects:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithObjects:(const id [])objects + forKeys:(const uint32_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && objects && keys) { + for (NSUInteger i = 0; i < count; ++i) { + if (!objects[i]) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil object to a Dictionary"]; + } + [_dictionary setObject:objects[i] forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBUInt32ObjectDictionary *)dictionary { + self = [self initWithObjects:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithObjects:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBUInt32ObjectDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBUInt32ObjectDictionary class]]) { + return NO; + } + GPBUInt32ObjectDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndObjectsUsingBlock: + (void (^)(uint32_t key, id object, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + id aObject = internal[aKey]; + block([aKey unsignedIntValue], aObject, &stop); + if (stop) { + break; + } + } +} + +- (BOOL)isInitialized { + for (GPBMessage *msg in [_dictionary objectEnumerator]) { + if (!msg.initialized) { + return NO; + } + } + return YES; +} + +- (instancetype)deepCopyWithZone:(NSZone *)zone { + GPBUInt32ObjectDictionary *newDict = + [[GPBUInt32ObjectDictionary alloc] init]; + NSEnumerator *keys = [_dictionary keyEnumerator]; + id aKey; + NSMutableDictionary *internalDict = newDict->_dictionary; + while ((aKey = [keys nextObject])) { + GPBMessage *msg = _dictionary[aKey]; + GPBMessage *copiedMsg = [msg copyWithZone:zone]; + [internalDict setObject:copiedMsg forKey:aKey]; + [copiedMsg release]; + } + return newDict; +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + id aObject = internal[aKey]; + size_t msgSize = ComputeDictUInt32FieldSize([aKey unsignedIntValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictObjectFieldSize(aObject, kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + id aObject = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + uint32_t unwrappedKey = [aKey unsignedIntValue]; + id unwrappedValue = aObject; + size_t msgSize = ComputeDictUInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictObjectFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictUInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictObjectField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:value->valueString forKey:@(key->valueUInt32)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndObjectsUsingBlock:^(uint32_t key, id object, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%u", key], object); + }]; +} + +- (id)objectForKey:(uint32_t)key { + id result = [_dictionary objectForKey:@(key)]; + return result; +} + +- (void)addEntriesFromDictionary:(GPBUInt32ObjectDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setObject:(id)object forKey:(uint32_t)key { + if (!object) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil object to a Dictionary"]; + } + [_dictionary setObject:object forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeObjectForKey:(uint32_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +//%PDDM-EXPAND DICTIONARY_IMPL_FOR_POD_KEY(Int32, int32_t) +// This block of code is generated, do not edit it directly. + +#pragma mark - Int32 -> UInt32 + +@implementation GPBInt32UInt32Dictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithUInt32s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithUInt32:(uint32_t)value + forKey:(int32_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithUInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBInt32UInt32Dictionary*)[self alloc] initWithUInt32s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithUInt32s:(const uint32_t [])values + forKeys:(const int32_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithUInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBInt32UInt32Dictionary*)[self alloc] initWithUInt32s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBInt32UInt32Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBInt32UInt32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithUInt32s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithUInt32s:(const uint32_t [])values + forKeys:(const int32_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBInt32UInt32Dictionary *)dictionary { + self = [self initWithUInt32s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithUInt32s:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBInt32UInt32Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBInt32UInt32Dictionary class]]) { + return NO; + } + GPBInt32UInt32Dictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndUInt32sUsingBlock: + (void (^)(int32_t key, uint32_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey intValue], [aValue unsignedIntValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictUInt32FieldSize([aValue unsignedIntValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + int32_t unwrappedKey = [aKey intValue]; + uint32_t unwrappedValue = [aValue unsignedIntValue]; + size_t msgSize = ComputeDictInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictUInt32FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictUInt32Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueUInt32) forKey:@(key->valueInt32)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndUInt32sUsingBlock:^(int32_t key, uint32_t value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%d", key], [NSString stringWithFormat:@"%u", value]); + }]; +} + +- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(int32_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped unsignedIntValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBInt32UInt32Dictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setUInt32:(uint32_t)value forKey:(int32_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeUInt32ForKey:(int32_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - Int32 -> Int32 + +@implementation GPBInt32Int32Dictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithInt32s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithInt32:(int32_t)value + forKey:(int32_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBInt32Int32Dictionary*)[self alloc] initWithInt32s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithInt32s:(const int32_t [])values + forKeys:(const int32_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBInt32Int32Dictionary*)[self alloc] initWithInt32s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBInt32Int32Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBInt32Int32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithInt32s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithInt32s:(const int32_t [])values + forKeys:(const int32_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBInt32Int32Dictionary *)dictionary { + self = [self initWithInt32s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithInt32s:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBInt32Int32Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBInt32Int32Dictionary class]]) { + return NO; + } + GPBInt32Int32Dictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndInt32sUsingBlock: + (void (^)(int32_t key, int32_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey intValue], [aValue intValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictInt32FieldSize([aValue intValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + int32_t unwrappedKey = [aKey intValue]; + int32_t unwrappedValue = [aValue intValue]; + size_t msgSize = ComputeDictInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictInt32FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictInt32Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueInt32) forKey:@(key->valueInt32)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndInt32sUsingBlock:^(int32_t key, int32_t value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%d", key], [NSString stringWithFormat:@"%d", value]); + }]; +} + +- (BOOL)getInt32:(nullable int32_t *)value forKey:(int32_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped intValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBInt32Int32Dictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setInt32:(int32_t)value forKey:(int32_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeInt32ForKey:(int32_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - Int32 -> UInt64 + +@implementation GPBInt32UInt64Dictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithUInt64s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithUInt64:(uint64_t)value + forKey:(int32_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithUInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBInt32UInt64Dictionary*)[self alloc] initWithUInt64s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithUInt64s:(const uint64_t [])values + forKeys:(const int32_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithUInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBInt32UInt64Dictionary*)[self alloc] initWithUInt64s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBInt32UInt64Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBInt32UInt64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithUInt64s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithUInt64s:(const uint64_t [])values + forKeys:(const int32_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBInt32UInt64Dictionary *)dictionary { + self = [self initWithUInt64s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithUInt64s:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBInt32UInt64Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBInt32UInt64Dictionary class]]) { + return NO; + } + GPBInt32UInt64Dictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndUInt64sUsingBlock: + (void (^)(int32_t key, uint64_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey intValue], [aValue unsignedLongLongValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictUInt64FieldSize([aValue unsignedLongLongValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + int32_t unwrappedKey = [aKey intValue]; + uint64_t unwrappedValue = [aValue unsignedLongLongValue]; + size_t msgSize = ComputeDictInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictUInt64FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictUInt64Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueUInt64) forKey:@(key->valueInt32)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndUInt64sUsingBlock:^(int32_t key, uint64_t value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%d", key], [NSString stringWithFormat:@"%llu", value]); + }]; +} + +- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(int32_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped unsignedLongLongValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBInt32UInt64Dictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setUInt64:(uint64_t)value forKey:(int32_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeUInt64ForKey:(int32_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - Int32 -> Int64 + +@implementation GPBInt32Int64Dictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithInt64s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithInt64:(int64_t)value + forKey:(int32_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBInt32Int64Dictionary*)[self alloc] initWithInt64s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithInt64s:(const int64_t [])values + forKeys:(const int32_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBInt32Int64Dictionary*)[self alloc] initWithInt64s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBInt32Int64Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBInt32Int64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithInt64s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithInt64s:(const int64_t [])values + forKeys:(const int32_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBInt32Int64Dictionary *)dictionary { + self = [self initWithInt64s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithInt64s:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBInt32Int64Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBInt32Int64Dictionary class]]) { + return NO; + } + GPBInt32Int64Dictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndInt64sUsingBlock: + (void (^)(int32_t key, int64_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey intValue], [aValue longLongValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictInt64FieldSize([aValue longLongValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + int32_t unwrappedKey = [aKey intValue]; + int64_t unwrappedValue = [aValue longLongValue]; + size_t msgSize = ComputeDictInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictInt64FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictInt64Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueInt64) forKey:@(key->valueInt32)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndInt64sUsingBlock:^(int32_t key, int64_t value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%d", key], [NSString stringWithFormat:@"%lld", value]); + }]; +} + +- (BOOL)getInt64:(nullable int64_t *)value forKey:(int32_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped longLongValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBInt32Int64Dictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setInt64:(int64_t)value forKey:(int32_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeInt64ForKey:(int32_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - Int32 -> Bool + +@implementation GPBInt32BoolDictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithBools:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithBool:(BOOL)value + forKey:(int32_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithBools:forKeys:count: + // on to get the type correct. + return [[(GPBInt32BoolDictionary*)[self alloc] initWithBools:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithBools:(const BOOL [])values + forKeys:(const int32_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithBools:forKeys:count: + // on to get the type correct. + return [[(GPBInt32BoolDictionary*)[self alloc] initWithBools:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBInt32BoolDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBInt32BoolDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithBools:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithBools:(const BOOL [])values + forKeys:(const int32_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBInt32BoolDictionary *)dictionary { + self = [self initWithBools:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithBools:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBInt32BoolDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBInt32BoolDictionary class]]) { + return NO; + } + GPBInt32BoolDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndBoolsUsingBlock: + (void (^)(int32_t key, BOOL value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey intValue], [aValue boolValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictBoolFieldSize([aValue boolValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + int32_t unwrappedKey = [aKey intValue]; + BOOL unwrappedValue = [aValue boolValue]; + size_t msgSize = ComputeDictInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictBoolFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictBoolField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueBool) forKey:@(key->valueInt32)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndBoolsUsingBlock:^(int32_t key, BOOL value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%d", key], (value ? @"true" : @"false")); + }]; +} + +- (BOOL)getBool:(nullable BOOL *)value forKey:(int32_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped boolValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBInt32BoolDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setBool:(BOOL)value forKey:(int32_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeBoolForKey:(int32_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - Int32 -> Float + +@implementation GPBInt32FloatDictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithFloats:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithFloat:(float)value + forKey:(int32_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithFloats:forKeys:count: + // on to get the type correct. + return [[(GPBInt32FloatDictionary*)[self alloc] initWithFloats:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithFloats:(const float [])values + forKeys:(const int32_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithFloats:forKeys:count: + // on to get the type correct. + return [[(GPBInt32FloatDictionary*)[self alloc] initWithFloats:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBInt32FloatDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBInt32FloatDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithFloats:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithFloats:(const float [])values + forKeys:(const int32_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBInt32FloatDictionary *)dictionary { + self = [self initWithFloats:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithFloats:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBInt32FloatDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBInt32FloatDictionary class]]) { + return NO; + } + GPBInt32FloatDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndFloatsUsingBlock: + (void (^)(int32_t key, float value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey intValue], [aValue floatValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictFloatFieldSize([aValue floatValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + int32_t unwrappedKey = [aKey intValue]; + float unwrappedValue = [aValue floatValue]; + size_t msgSize = ComputeDictInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictFloatFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictFloatField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueFloat) forKey:@(key->valueInt32)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndFloatsUsingBlock:^(int32_t key, float value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%d", key], [NSString stringWithFormat:@"%.*g", FLT_DIG, value]); + }]; +} + +- (BOOL)getFloat:(nullable float *)value forKey:(int32_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped floatValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBInt32FloatDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setFloat:(float)value forKey:(int32_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeFloatForKey:(int32_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - Int32 -> Double + +@implementation GPBInt32DoubleDictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithDoubles:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithDouble:(double)value + forKey:(int32_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithDoubles:forKeys:count: + // on to get the type correct. + return [[(GPBInt32DoubleDictionary*)[self alloc] initWithDoubles:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithDoubles:(const double [])values + forKeys:(const int32_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithDoubles:forKeys:count: + // on to get the type correct. + return [[(GPBInt32DoubleDictionary*)[self alloc] initWithDoubles:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBInt32DoubleDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBInt32DoubleDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithDoubles:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithDoubles:(const double [])values + forKeys:(const int32_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBInt32DoubleDictionary *)dictionary { + self = [self initWithDoubles:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithDoubles:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBInt32DoubleDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBInt32DoubleDictionary class]]) { + return NO; + } + GPBInt32DoubleDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndDoublesUsingBlock: + (void (^)(int32_t key, double value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey intValue], [aValue doubleValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictDoubleFieldSize([aValue doubleValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + int32_t unwrappedKey = [aKey intValue]; + double unwrappedValue = [aValue doubleValue]; + size_t msgSize = ComputeDictInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictDoubleFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictDoubleField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueDouble) forKey:@(key->valueInt32)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndDoublesUsingBlock:^(int32_t key, double value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%d", key], [NSString stringWithFormat:@"%.*lg", DBL_DIG, value]); + }]; +} + +- (BOOL)getDouble:(nullable double *)value forKey:(int32_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped doubleValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBInt32DoubleDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setDouble:(double)value forKey:(int32_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeDoubleForKey:(int32_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - Int32 -> Enum + +@implementation GPBInt32EnumDictionary { + @package + NSMutableDictionary *_dictionary; + GPBEnumValidationFunc _validationFunc; +} + +@synthesize validationFunc = _validationFunc; + ++ (instancetype)dictionary { + return [[[self alloc] initWithValidationFunction:NULL + rawValues:NULL + forKeys:NULL + count:0] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func { + return [[[self alloc] initWithValidationFunction:func + rawValues:NULL + forKeys:NULL + count:0] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func + rawValue:(int32_t)rawValue + forKey:(int32_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count: + // on to get the type correct. + return [[(GPBInt32EnumDictionary*)[self alloc] initWithValidationFunction:func + rawValues:&rawValue + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func + rawValues:(const int32_t [])rawValues + forKeys:(const int32_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count: + // on to get the type correct. + return [[(GPBInt32EnumDictionary*)[self alloc] initWithValidationFunction:func + rawValues:rawValues + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBInt32EnumDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count: + // on to get the type correct. + return [[(GPBInt32EnumDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems { + return [[[self alloc] initWithValidationFunction:func capacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithValidationFunction:NULL rawValues:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func { + return [self initWithValidationFunction:func rawValues:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func + rawValues:(const int32_t [])rawValues + forKeys:(const int32_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + _validationFunc = (func != NULL ? func : DictDefault_IsValidValue); + if (count && rawValues && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(rawValues[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBInt32EnumDictionary *)dictionary { + self = [self initWithValidationFunction:dictionary.validationFunc + rawValues:NULL + forKeys:NULL + count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithValidationFunction:func rawValues:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBInt32EnumDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBInt32EnumDictionary class]]) { + return NO; + } + GPBInt32EnumDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndRawValuesUsingBlock: + (void (^)(int32_t key, int32_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey intValue], [aValue intValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictEnumFieldSize([aValue intValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + int32_t unwrappedKey = [aKey intValue]; + int32_t unwrappedValue = [aValue intValue]; + size_t msgSize = ComputeDictInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictEnumFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictEnumField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (NSData *)serializedDataForUnknownValue:(int32_t)value + forKey:(GPBGenericValue *)key + keyDataType:(GPBDataType)keyDataType { + size_t msgSize = ComputeDictInt32FieldSize(key->valueInt32, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictEnumFieldSize(value, kMapValueFieldNumber, GPBDataTypeEnum); + NSMutableData *data = [NSMutableData dataWithLength:msgSize]; + GPBCodedOutputStream *outputStream = [[GPBCodedOutputStream alloc] initWithData:data]; + WriteDictInt32Field(outputStream, key->valueInt32, kMapKeyFieldNumber, keyDataType); + WriteDictEnumField(outputStream, value, kMapValueFieldNumber, GPBDataTypeEnum); + [outputStream release]; + return data; +} +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueEnum) forKey:@(key->valueInt32)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndRawValuesUsingBlock:^(int32_t key, int32_t value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%d", key], @(value)); + }]; +} + +- (BOOL)getEnum:(int32_t *)value forKey:(int32_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + int32_t result = [wrapped intValue]; + if (!_validationFunc(result)) { + result = kGPBUnrecognizedEnumeratorValue; + } + *value = result; + } + return (wrapped != NULL); +} + +- (BOOL)getRawValue:(int32_t *)rawValue forKey:(int32_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && rawValue) { + *rawValue = [wrapped intValue]; + } + return (wrapped != NULL); +} + +- (void)enumerateKeysAndEnumsUsingBlock: + (void (^)(int32_t key, int32_t value, BOOL *stop))block { + GPBEnumValidationFunc func = _validationFunc; + BOOL stop = NO; + NSEnumerator *keys = [_dictionary keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = _dictionary[aKey]; + int32_t unwrapped = [aValue intValue]; + if (!func(unwrapped)) { + unwrapped = kGPBUnrecognizedEnumeratorValue; + } + block([aKey intValue], unwrapped, &stop); + if (stop) { + break; + } + } +} + +- (void)addRawEntriesFromDictionary:(GPBInt32EnumDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setRawValue:(int32_t)value forKey:(int32_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeEnumForKey:(int32_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +- (void)setEnum:(int32_t)value forKey:(int32_t)key { + if (!_validationFunc(value)) { + [NSException raise:NSInvalidArgumentException + format:@"GPBInt32EnumDictionary: Attempt to set an unknown enum value (%d)", + value]; + } + + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +@end + +#pragma mark - Int32 -> Object + +@implementation GPBInt32ObjectDictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithObjects:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithObject:(id)object + forKey:(int32_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithObjects:forKeys:count: + // on to get the type correct. + return [[(GPBInt32ObjectDictionary*)[self alloc] initWithObjects:&object + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithObjects:(const id [])objects + forKeys:(const int32_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithObjects:forKeys:count: + // on to get the type correct. + return [[(GPBInt32ObjectDictionary*)[self alloc] initWithObjects:objects + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBInt32ObjectDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBInt32ObjectDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithObjects:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithObjects:(const id [])objects + forKeys:(const int32_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && objects && keys) { + for (NSUInteger i = 0; i < count; ++i) { + if (!objects[i]) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil object to a Dictionary"]; + } + [_dictionary setObject:objects[i] forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBInt32ObjectDictionary *)dictionary { + self = [self initWithObjects:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithObjects:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBInt32ObjectDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBInt32ObjectDictionary class]]) { + return NO; + } + GPBInt32ObjectDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndObjectsUsingBlock: + (void (^)(int32_t key, id object, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + id aObject = internal[aKey]; + block([aKey intValue], aObject, &stop); + if (stop) { + break; + } + } +} + +- (BOOL)isInitialized { + for (GPBMessage *msg in [_dictionary objectEnumerator]) { + if (!msg.initialized) { + return NO; + } + } + return YES; +} + +- (instancetype)deepCopyWithZone:(NSZone *)zone { + GPBInt32ObjectDictionary *newDict = + [[GPBInt32ObjectDictionary alloc] init]; + NSEnumerator *keys = [_dictionary keyEnumerator]; + id aKey; + NSMutableDictionary *internalDict = newDict->_dictionary; + while ((aKey = [keys nextObject])) { + GPBMessage *msg = _dictionary[aKey]; + GPBMessage *copiedMsg = [msg copyWithZone:zone]; + [internalDict setObject:copiedMsg forKey:aKey]; + [copiedMsg release]; + } + return newDict; +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + id aObject = internal[aKey]; + size_t msgSize = ComputeDictInt32FieldSize([aKey intValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictObjectFieldSize(aObject, kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + id aObject = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + int32_t unwrappedKey = [aKey intValue]; + id unwrappedValue = aObject; + size_t msgSize = ComputeDictInt32FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictObjectFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictInt32Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictObjectField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:value->valueString forKey:@(key->valueInt32)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndObjectsUsingBlock:^(int32_t key, id object, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%d", key], object); + }]; +} + +- (id)objectForKey:(int32_t)key { + id result = [_dictionary objectForKey:@(key)]; + return result; +} + +- (void)addEntriesFromDictionary:(GPBInt32ObjectDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setObject:(id)object forKey:(int32_t)key { + if (!object) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil object to a Dictionary"]; + } + [_dictionary setObject:object forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeObjectForKey:(int32_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +//%PDDM-EXPAND DICTIONARY_IMPL_FOR_POD_KEY(UInt64, uint64_t) +// This block of code is generated, do not edit it directly. + +#pragma mark - UInt64 -> UInt32 + +@implementation GPBUInt64UInt32Dictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithUInt32s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithUInt32:(uint32_t)value + forKey:(uint64_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithUInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBUInt64UInt32Dictionary*)[self alloc] initWithUInt32s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithUInt32s:(const uint32_t [])values + forKeys:(const uint64_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithUInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBUInt64UInt32Dictionary*)[self alloc] initWithUInt32s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBUInt64UInt32Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBUInt64UInt32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithUInt32s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithUInt32s:(const uint32_t [])values + forKeys:(const uint64_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBUInt64UInt32Dictionary *)dictionary { + self = [self initWithUInt32s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithUInt32s:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBUInt64UInt32Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBUInt64UInt32Dictionary class]]) { + return NO; + } + GPBUInt64UInt32Dictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndUInt32sUsingBlock: + (void (^)(uint64_t key, uint32_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey unsignedLongLongValue], [aValue unsignedIntValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictUInt32FieldSize([aValue unsignedIntValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + uint64_t unwrappedKey = [aKey unsignedLongLongValue]; + uint32_t unwrappedValue = [aValue unsignedIntValue]; + size_t msgSize = ComputeDictUInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictUInt32FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictUInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictUInt32Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueUInt32) forKey:@(key->valueUInt64)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndUInt32sUsingBlock:^(uint64_t key, uint32_t value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%llu", key], [NSString stringWithFormat:@"%u", value]); + }]; +} + +- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(uint64_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped unsignedIntValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBUInt64UInt32Dictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setUInt32:(uint32_t)value forKey:(uint64_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeUInt32ForKey:(uint64_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - UInt64 -> Int32 + +@implementation GPBUInt64Int32Dictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithInt32s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithInt32:(int32_t)value + forKey:(uint64_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBUInt64Int32Dictionary*)[self alloc] initWithInt32s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithInt32s:(const int32_t [])values + forKeys:(const uint64_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBUInt64Int32Dictionary*)[self alloc] initWithInt32s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBUInt64Int32Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBUInt64Int32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithInt32s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithInt32s:(const int32_t [])values + forKeys:(const uint64_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBUInt64Int32Dictionary *)dictionary { + self = [self initWithInt32s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithInt32s:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBUInt64Int32Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBUInt64Int32Dictionary class]]) { + return NO; + } + GPBUInt64Int32Dictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndInt32sUsingBlock: + (void (^)(uint64_t key, int32_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey unsignedLongLongValue], [aValue intValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictInt32FieldSize([aValue intValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + uint64_t unwrappedKey = [aKey unsignedLongLongValue]; + int32_t unwrappedValue = [aValue intValue]; + size_t msgSize = ComputeDictUInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictInt32FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictUInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictInt32Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueInt32) forKey:@(key->valueUInt64)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndInt32sUsingBlock:^(uint64_t key, int32_t value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%llu", key], [NSString stringWithFormat:@"%d", value]); + }]; +} + +- (BOOL)getInt32:(nullable int32_t *)value forKey:(uint64_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped intValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBUInt64Int32Dictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setInt32:(int32_t)value forKey:(uint64_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeInt32ForKey:(uint64_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - UInt64 -> UInt64 + +@implementation GPBUInt64UInt64Dictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithUInt64s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithUInt64:(uint64_t)value + forKey:(uint64_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithUInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBUInt64UInt64Dictionary*)[self alloc] initWithUInt64s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithUInt64s:(const uint64_t [])values + forKeys:(const uint64_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithUInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBUInt64UInt64Dictionary*)[self alloc] initWithUInt64s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBUInt64UInt64Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBUInt64UInt64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithUInt64s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithUInt64s:(const uint64_t [])values + forKeys:(const uint64_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBUInt64UInt64Dictionary *)dictionary { + self = [self initWithUInt64s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithUInt64s:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBUInt64UInt64Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBUInt64UInt64Dictionary class]]) { + return NO; + } + GPBUInt64UInt64Dictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndUInt64sUsingBlock: + (void (^)(uint64_t key, uint64_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey unsignedLongLongValue], [aValue unsignedLongLongValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictUInt64FieldSize([aValue unsignedLongLongValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + uint64_t unwrappedKey = [aKey unsignedLongLongValue]; + uint64_t unwrappedValue = [aValue unsignedLongLongValue]; + size_t msgSize = ComputeDictUInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictUInt64FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictUInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictUInt64Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueUInt64) forKey:@(key->valueUInt64)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndUInt64sUsingBlock:^(uint64_t key, uint64_t value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%llu", key], [NSString stringWithFormat:@"%llu", value]); + }]; +} + +- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(uint64_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped unsignedLongLongValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBUInt64UInt64Dictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setUInt64:(uint64_t)value forKey:(uint64_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeUInt64ForKey:(uint64_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - UInt64 -> Int64 + +@implementation GPBUInt64Int64Dictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithInt64s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithInt64:(int64_t)value + forKey:(uint64_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBUInt64Int64Dictionary*)[self alloc] initWithInt64s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithInt64s:(const int64_t [])values + forKeys:(const uint64_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBUInt64Int64Dictionary*)[self alloc] initWithInt64s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBUInt64Int64Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBUInt64Int64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithInt64s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithInt64s:(const int64_t [])values + forKeys:(const uint64_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBUInt64Int64Dictionary *)dictionary { + self = [self initWithInt64s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithInt64s:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBUInt64Int64Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBUInt64Int64Dictionary class]]) { + return NO; + } + GPBUInt64Int64Dictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndInt64sUsingBlock: + (void (^)(uint64_t key, int64_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey unsignedLongLongValue], [aValue longLongValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictInt64FieldSize([aValue longLongValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + uint64_t unwrappedKey = [aKey unsignedLongLongValue]; + int64_t unwrappedValue = [aValue longLongValue]; + size_t msgSize = ComputeDictUInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictInt64FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictUInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictInt64Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueInt64) forKey:@(key->valueUInt64)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndInt64sUsingBlock:^(uint64_t key, int64_t value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%llu", key], [NSString stringWithFormat:@"%lld", value]); + }]; +} + +- (BOOL)getInt64:(nullable int64_t *)value forKey:(uint64_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped longLongValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBUInt64Int64Dictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setInt64:(int64_t)value forKey:(uint64_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeInt64ForKey:(uint64_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - UInt64 -> Bool + +@implementation GPBUInt64BoolDictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithBools:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithBool:(BOOL)value + forKey:(uint64_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithBools:forKeys:count: + // on to get the type correct. + return [[(GPBUInt64BoolDictionary*)[self alloc] initWithBools:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithBools:(const BOOL [])values + forKeys:(const uint64_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithBools:forKeys:count: + // on to get the type correct. + return [[(GPBUInt64BoolDictionary*)[self alloc] initWithBools:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBUInt64BoolDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBUInt64BoolDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithBools:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithBools:(const BOOL [])values + forKeys:(const uint64_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBUInt64BoolDictionary *)dictionary { + self = [self initWithBools:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithBools:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBUInt64BoolDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBUInt64BoolDictionary class]]) { + return NO; + } + GPBUInt64BoolDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndBoolsUsingBlock: + (void (^)(uint64_t key, BOOL value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey unsignedLongLongValue], [aValue boolValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictBoolFieldSize([aValue boolValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + uint64_t unwrappedKey = [aKey unsignedLongLongValue]; + BOOL unwrappedValue = [aValue boolValue]; + size_t msgSize = ComputeDictUInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictBoolFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictUInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictBoolField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueBool) forKey:@(key->valueUInt64)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndBoolsUsingBlock:^(uint64_t key, BOOL value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%llu", key], (value ? @"true" : @"false")); + }]; +} + +- (BOOL)getBool:(nullable BOOL *)value forKey:(uint64_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped boolValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBUInt64BoolDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setBool:(BOOL)value forKey:(uint64_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeBoolForKey:(uint64_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - UInt64 -> Float + +@implementation GPBUInt64FloatDictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithFloats:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithFloat:(float)value + forKey:(uint64_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithFloats:forKeys:count: + // on to get the type correct. + return [[(GPBUInt64FloatDictionary*)[self alloc] initWithFloats:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithFloats:(const float [])values + forKeys:(const uint64_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithFloats:forKeys:count: + // on to get the type correct. + return [[(GPBUInt64FloatDictionary*)[self alloc] initWithFloats:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBUInt64FloatDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBUInt64FloatDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithFloats:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithFloats:(const float [])values + forKeys:(const uint64_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBUInt64FloatDictionary *)dictionary { + self = [self initWithFloats:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithFloats:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBUInt64FloatDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBUInt64FloatDictionary class]]) { + return NO; + } + GPBUInt64FloatDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndFloatsUsingBlock: + (void (^)(uint64_t key, float value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey unsignedLongLongValue], [aValue floatValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictFloatFieldSize([aValue floatValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + uint64_t unwrappedKey = [aKey unsignedLongLongValue]; + float unwrappedValue = [aValue floatValue]; + size_t msgSize = ComputeDictUInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictFloatFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictUInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictFloatField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueFloat) forKey:@(key->valueUInt64)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndFloatsUsingBlock:^(uint64_t key, float value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%llu", key], [NSString stringWithFormat:@"%.*g", FLT_DIG, value]); + }]; +} + +- (BOOL)getFloat:(nullable float *)value forKey:(uint64_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped floatValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBUInt64FloatDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setFloat:(float)value forKey:(uint64_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeFloatForKey:(uint64_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - UInt64 -> Double + +@implementation GPBUInt64DoubleDictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithDoubles:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithDouble:(double)value + forKey:(uint64_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithDoubles:forKeys:count: + // on to get the type correct. + return [[(GPBUInt64DoubleDictionary*)[self alloc] initWithDoubles:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithDoubles:(const double [])values + forKeys:(const uint64_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithDoubles:forKeys:count: + // on to get the type correct. + return [[(GPBUInt64DoubleDictionary*)[self alloc] initWithDoubles:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBUInt64DoubleDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBUInt64DoubleDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithDoubles:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithDoubles:(const double [])values + forKeys:(const uint64_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBUInt64DoubleDictionary *)dictionary { + self = [self initWithDoubles:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithDoubles:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBUInt64DoubleDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBUInt64DoubleDictionary class]]) { + return NO; + } + GPBUInt64DoubleDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndDoublesUsingBlock: + (void (^)(uint64_t key, double value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey unsignedLongLongValue], [aValue doubleValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictDoubleFieldSize([aValue doubleValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + uint64_t unwrappedKey = [aKey unsignedLongLongValue]; + double unwrappedValue = [aValue doubleValue]; + size_t msgSize = ComputeDictUInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictDoubleFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictUInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictDoubleField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueDouble) forKey:@(key->valueUInt64)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndDoublesUsingBlock:^(uint64_t key, double value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%llu", key], [NSString stringWithFormat:@"%.*lg", DBL_DIG, value]); + }]; +} + +- (BOOL)getDouble:(nullable double *)value forKey:(uint64_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped doubleValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBUInt64DoubleDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setDouble:(double)value forKey:(uint64_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeDoubleForKey:(uint64_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - UInt64 -> Enum + +@implementation GPBUInt64EnumDictionary { + @package + NSMutableDictionary *_dictionary; + GPBEnumValidationFunc _validationFunc; +} + +@synthesize validationFunc = _validationFunc; + ++ (instancetype)dictionary { + return [[[self alloc] initWithValidationFunction:NULL + rawValues:NULL + forKeys:NULL + count:0] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func { + return [[[self alloc] initWithValidationFunction:func + rawValues:NULL + forKeys:NULL + count:0] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func + rawValue:(int32_t)rawValue + forKey:(uint64_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count: + // on to get the type correct. + return [[(GPBUInt64EnumDictionary*)[self alloc] initWithValidationFunction:func + rawValues:&rawValue + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func + rawValues:(const int32_t [])rawValues + forKeys:(const uint64_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count: + // on to get the type correct. + return [[(GPBUInt64EnumDictionary*)[self alloc] initWithValidationFunction:func + rawValues:rawValues + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBUInt64EnumDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count: + // on to get the type correct. + return [[(GPBUInt64EnumDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems { + return [[[self alloc] initWithValidationFunction:func capacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithValidationFunction:NULL rawValues:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func { + return [self initWithValidationFunction:func rawValues:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func + rawValues:(const int32_t [])rawValues + forKeys:(const uint64_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + _validationFunc = (func != NULL ? func : DictDefault_IsValidValue); + if (count && rawValues && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(rawValues[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBUInt64EnumDictionary *)dictionary { + self = [self initWithValidationFunction:dictionary.validationFunc + rawValues:NULL + forKeys:NULL + count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithValidationFunction:func rawValues:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBUInt64EnumDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBUInt64EnumDictionary class]]) { + return NO; + } + GPBUInt64EnumDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndRawValuesUsingBlock: + (void (^)(uint64_t key, int32_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey unsignedLongLongValue], [aValue intValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictEnumFieldSize([aValue intValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + uint64_t unwrappedKey = [aKey unsignedLongLongValue]; + int32_t unwrappedValue = [aValue intValue]; + size_t msgSize = ComputeDictUInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictEnumFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictUInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictEnumField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (NSData *)serializedDataForUnknownValue:(int32_t)value + forKey:(GPBGenericValue *)key + keyDataType:(GPBDataType)keyDataType { + size_t msgSize = ComputeDictUInt64FieldSize(key->valueUInt64, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictEnumFieldSize(value, kMapValueFieldNumber, GPBDataTypeEnum); + NSMutableData *data = [NSMutableData dataWithLength:msgSize]; + GPBCodedOutputStream *outputStream = [[GPBCodedOutputStream alloc] initWithData:data]; + WriteDictUInt64Field(outputStream, key->valueUInt64, kMapKeyFieldNumber, keyDataType); + WriteDictEnumField(outputStream, value, kMapValueFieldNumber, GPBDataTypeEnum); + [outputStream release]; + return data; +} +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueEnum) forKey:@(key->valueUInt64)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndRawValuesUsingBlock:^(uint64_t key, int32_t value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%llu", key], @(value)); + }]; +} + +- (BOOL)getEnum:(int32_t *)value forKey:(uint64_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + int32_t result = [wrapped intValue]; + if (!_validationFunc(result)) { + result = kGPBUnrecognizedEnumeratorValue; + } + *value = result; + } + return (wrapped != NULL); +} + +- (BOOL)getRawValue:(int32_t *)rawValue forKey:(uint64_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && rawValue) { + *rawValue = [wrapped intValue]; + } + return (wrapped != NULL); +} + +- (void)enumerateKeysAndEnumsUsingBlock: + (void (^)(uint64_t key, int32_t value, BOOL *stop))block { + GPBEnumValidationFunc func = _validationFunc; + BOOL stop = NO; + NSEnumerator *keys = [_dictionary keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = _dictionary[aKey]; + int32_t unwrapped = [aValue intValue]; + if (!func(unwrapped)) { + unwrapped = kGPBUnrecognizedEnumeratorValue; + } + block([aKey unsignedLongLongValue], unwrapped, &stop); + if (stop) { + break; + } + } +} + +- (void)addRawEntriesFromDictionary:(GPBUInt64EnumDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setRawValue:(int32_t)value forKey:(uint64_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeEnumForKey:(uint64_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +- (void)setEnum:(int32_t)value forKey:(uint64_t)key { + if (!_validationFunc(value)) { + [NSException raise:NSInvalidArgumentException + format:@"GPBUInt64EnumDictionary: Attempt to set an unknown enum value (%d)", + value]; + } + + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +@end + +#pragma mark - UInt64 -> Object + +@implementation GPBUInt64ObjectDictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithObjects:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithObject:(id)object + forKey:(uint64_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithObjects:forKeys:count: + // on to get the type correct. + return [[(GPBUInt64ObjectDictionary*)[self alloc] initWithObjects:&object + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithObjects:(const id [])objects + forKeys:(const uint64_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithObjects:forKeys:count: + // on to get the type correct. + return [[(GPBUInt64ObjectDictionary*)[self alloc] initWithObjects:objects + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBUInt64ObjectDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBUInt64ObjectDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithObjects:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithObjects:(const id [])objects + forKeys:(const uint64_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && objects && keys) { + for (NSUInteger i = 0; i < count; ++i) { + if (!objects[i]) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil object to a Dictionary"]; + } + [_dictionary setObject:objects[i] forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBUInt64ObjectDictionary *)dictionary { + self = [self initWithObjects:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithObjects:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBUInt64ObjectDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBUInt64ObjectDictionary class]]) { + return NO; + } + GPBUInt64ObjectDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndObjectsUsingBlock: + (void (^)(uint64_t key, id object, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + id aObject = internal[aKey]; + block([aKey unsignedLongLongValue], aObject, &stop); + if (stop) { + break; + } + } +} + +- (BOOL)isInitialized { + for (GPBMessage *msg in [_dictionary objectEnumerator]) { + if (!msg.initialized) { + return NO; + } + } + return YES; +} + +- (instancetype)deepCopyWithZone:(NSZone *)zone { + GPBUInt64ObjectDictionary *newDict = + [[GPBUInt64ObjectDictionary alloc] init]; + NSEnumerator *keys = [_dictionary keyEnumerator]; + id aKey; + NSMutableDictionary *internalDict = newDict->_dictionary; + while ((aKey = [keys nextObject])) { + GPBMessage *msg = _dictionary[aKey]; + GPBMessage *copiedMsg = [msg copyWithZone:zone]; + [internalDict setObject:copiedMsg forKey:aKey]; + [copiedMsg release]; + } + return newDict; +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + id aObject = internal[aKey]; + size_t msgSize = ComputeDictUInt64FieldSize([aKey unsignedLongLongValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictObjectFieldSize(aObject, kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + id aObject = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + uint64_t unwrappedKey = [aKey unsignedLongLongValue]; + id unwrappedValue = aObject; + size_t msgSize = ComputeDictUInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictObjectFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictUInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictObjectField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:value->valueString forKey:@(key->valueUInt64)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndObjectsUsingBlock:^(uint64_t key, id object, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%llu", key], object); + }]; +} + +- (id)objectForKey:(uint64_t)key { + id result = [_dictionary objectForKey:@(key)]; + return result; +} + +- (void)addEntriesFromDictionary:(GPBUInt64ObjectDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setObject:(id)object forKey:(uint64_t)key { + if (!object) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil object to a Dictionary"]; + } + [_dictionary setObject:object forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeObjectForKey:(uint64_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +//%PDDM-EXPAND DICTIONARY_IMPL_FOR_POD_KEY(Int64, int64_t) +// This block of code is generated, do not edit it directly. + +#pragma mark - Int64 -> UInt32 + +@implementation GPBInt64UInt32Dictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithUInt32s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithUInt32:(uint32_t)value + forKey:(int64_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithUInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBInt64UInt32Dictionary*)[self alloc] initWithUInt32s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithUInt32s:(const uint32_t [])values + forKeys:(const int64_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithUInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBInt64UInt32Dictionary*)[self alloc] initWithUInt32s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBInt64UInt32Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBInt64UInt32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithUInt32s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithUInt32s:(const uint32_t [])values + forKeys:(const int64_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBInt64UInt32Dictionary *)dictionary { + self = [self initWithUInt32s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithUInt32s:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBInt64UInt32Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBInt64UInt32Dictionary class]]) { + return NO; + } + GPBInt64UInt32Dictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndUInt32sUsingBlock: + (void (^)(int64_t key, uint32_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey longLongValue], [aValue unsignedIntValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictUInt32FieldSize([aValue unsignedIntValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + int64_t unwrappedKey = [aKey longLongValue]; + uint32_t unwrappedValue = [aValue unsignedIntValue]; + size_t msgSize = ComputeDictInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictUInt32FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictUInt32Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueUInt32) forKey:@(key->valueInt64)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndUInt32sUsingBlock:^(int64_t key, uint32_t value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%lld", key], [NSString stringWithFormat:@"%u", value]); + }]; +} + +- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(int64_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped unsignedIntValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBInt64UInt32Dictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setUInt32:(uint32_t)value forKey:(int64_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeUInt32ForKey:(int64_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - Int64 -> Int32 + +@implementation GPBInt64Int32Dictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithInt32s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithInt32:(int32_t)value + forKey:(int64_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBInt64Int32Dictionary*)[self alloc] initWithInt32s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithInt32s:(const int32_t [])values + forKeys:(const int64_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBInt64Int32Dictionary*)[self alloc] initWithInt32s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBInt64Int32Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBInt64Int32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithInt32s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithInt32s:(const int32_t [])values + forKeys:(const int64_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBInt64Int32Dictionary *)dictionary { + self = [self initWithInt32s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithInt32s:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBInt64Int32Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBInt64Int32Dictionary class]]) { + return NO; + } + GPBInt64Int32Dictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndInt32sUsingBlock: + (void (^)(int64_t key, int32_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey longLongValue], [aValue intValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictInt32FieldSize([aValue intValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + int64_t unwrappedKey = [aKey longLongValue]; + int32_t unwrappedValue = [aValue intValue]; + size_t msgSize = ComputeDictInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictInt32FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictInt32Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueInt32) forKey:@(key->valueInt64)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndInt32sUsingBlock:^(int64_t key, int32_t value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%lld", key], [NSString stringWithFormat:@"%d", value]); + }]; +} + +- (BOOL)getInt32:(nullable int32_t *)value forKey:(int64_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped intValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBInt64Int32Dictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setInt32:(int32_t)value forKey:(int64_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeInt32ForKey:(int64_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - Int64 -> UInt64 + +@implementation GPBInt64UInt64Dictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithUInt64s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithUInt64:(uint64_t)value + forKey:(int64_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithUInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBInt64UInt64Dictionary*)[self alloc] initWithUInt64s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithUInt64s:(const uint64_t [])values + forKeys:(const int64_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithUInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBInt64UInt64Dictionary*)[self alloc] initWithUInt64s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBInt64UInt64Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBInt64UInt64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithUInt64s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithUInt64s:(const uint64_t [])values + forKeys:(const int64_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBInt64UInt64Dictionary *)dictionary { + self = [self initWithUInt64s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithUInt64s:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBInt64UInt64Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBInt64UInt64Dictionary class]]) { + return NO; + } + GPBInt64UInt64Dictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndUInt64sUsingBlock: + (void (^)(int64_t key, uint64_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey longLongValue], [aValue unsignedLongLongValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictUInt64FieldSize([aValue unsignedLongLongValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + int64_t unwrappedKey = [aKey longLongValue]; + uint64_t unwrappedValue = [aValue unsignedLongLongValue]; + size_t msgSize = ComputeDictInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictUInt64FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictUInt64Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueUInt64) forKey:@(key->valueInt64)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndUInt64sUsingBlock:^(int64_t key, uint64_t value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%lld", key], [NSString stringWithFormat:@"%llu", value]); + }]; +} + +- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(int64_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped unsignedLongLongValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBInt64UInt64Dictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setUInt64:(uint64_t)value forKey:(int64_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeUInt64ForKey:(int64_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - Int64 -> Int64 + +@implementation GPBInt64Int64Dictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithInt64s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithInt64:(int64_t)value + forKey:(int64_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBInt64Int64Dictionary*)[self alloc] initWithInt64s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithInt64s:(const int64_t [])values + forKeys:(const int64_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBInt64Int64Dictionary*)[self alloc] initWithInt64s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBInt64Int64Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBInt64Int64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithInt64s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithInt64s:(const int64_t [])values + forKeys:(const int64_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBInt64Int64Dictionary *)dictionary { + self = [self initWithInt64s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithInt64s:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBInt64Int64Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBInt64Int64Dictionary class]]) { + return NO; + } + GPBInt64Int64Dictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndInt64sUsingBlock: + (void (^)(int64_t key, int64_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey longLongValue], [aValue longLongValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictInt64FieldSize([aValue longLongValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + int64_t unwrappedKey = [aKey longLongValue]; + int64_t unwrappedValue = [aValue longLongValue]; + size_t msgSize = ComputeDictInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictInt64FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictInt64Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueInt64) forKey:@(key->valueInt64)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndInt64sUsingBlock:^(int64_t key, int64_t value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%lld", key], [NSString stringWithFormat:@"%lld", value]); + }]; +} + +- (BOOL)getInt64:(nullable int64_t *)value forKey:(int64_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped longLongValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBInt64Int64Dictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setInt64:(int64_t)value forKey:(int64_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeInt64ForKey:(int64_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - Int64 -> Bool + +@implementation GPBInt64BoolDictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithBools:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithBool:(BOOL)value + forKey:(int64_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithBools:forKeys:count: + // on to get the type correct. + return [[(GPBInt64BoolDictionary*)[self alloc] initWithBools:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithBools:(const BOOL [])values + forKeys:(const int64_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithBools:forKeys:count: + // on to get the type correct. + return [[(GPBInt64BoolDictionary*)[self alloc] initWithBools:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBInt64BoolDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBInt64BoolDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithBools:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithBools:(const BOOL [])values + forKeys:(const int64_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBInt64BoolDictionary *)dictionary { + self = [self initWithBools:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithBools:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBInt64BoolDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBInt64BoolDictionary class]]) { + return NO; + } + GPBInt64BoolDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndBoolsUsingBlock: + (void (^)(int64_t key, BOOL value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey longLongValue], [aValue boolValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictBoolFieldSize([aValue boolValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + int64_t unwrappedKey = [aKey longLongValue]; + BOOL unwrappedValue = [aValue boolValue]; + size_t msgSize = ComputeDictInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictBoolFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictBoolField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueBool) forKey:@(key->valueInt64)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndBoolsUsingBlock:^(int64_t key, BOOL value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%lld", key], (value ? @"true" : @"false")); + }]; +} + +- (BOOL)getBool:(nullable BOOL *)value forKey:(int64_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped boolValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBInt64BoolDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setBool:(BOOL)value forKey:(int64_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeBoolForKey:(int64_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - Int64 -> Float + +@implementation GPBInt64FloatDictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithFloats:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithFloat:(float)value + forKey:(int64_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithFloats:forKeys:count: + // on to get the type correct. + return [[(GPBInt64FloatDictionary*)[self alloc] initWithFloats:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithFloats:(const float [])values + forKeys:(const int64_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithFloats:forKeys:count: + // on to get the type correct. + return [[(GPBInt64FloatDictionary*)[self alloc] initWithFloats:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBInt64FloatDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBInt64FloatDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithFloats:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithFloats:(const float [])values + forKeys:(const int64_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBInt64FloatDictionary *)dictionary { + self = [self initWithFloats:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithFloats:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBInt64FloatDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBInt64FloatDictionary class]]) { + return NO; + } + GPBInt64FloatDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndFloatsUsingBlock: + (void (^)(int64_t key, float value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey longLongValue], [aValue floatValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictFloatFieldSize([aValue floatValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + int64_t unwrappedKey = [aKey longLongValue]; + float unwrappedValue = [aValue floatValue]; + size_t msgSize = ComputeDictInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictFloatFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictFloatField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueFloat) forKey:@(key->valueInt64)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndFloatsUsingBlock:^(int64_t key, float value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%lld", key], [NSString stringWithFormat:@"%.*g", FLT_DIG, value]); + }]; +} + +- (BOOL)getFloat:(nullable float *)value forKey:(int64_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped floatValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBInt64FloatDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setFloat:(float)value forKey:(int64_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeFloatForKey:(int64_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - Int64 -> Double + +@implementation GPBInt64DoubleDictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithDoubles:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithDouble:(double)value + forKey:(int64_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithDoubles:forKeys:count: + // on to get the type correct. + return [[(GPBInt64DoubleDictionary*)[self alloc] initWithDoubles:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithDoubles:(const double [])values + forKeys:(const int64_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithDoubles:forKeys:count: + // on to get the type correct. + return [[(GPBInt64DoubleDictionary*)[self alloc] initWithDoubles:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBInt64DoubleDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBInt64DoubleDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithDoubles:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithDoubles:(const double [])values + forKeys:(const int64_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(values[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBInt64DoubleDictionary *)dictionary { + self = [self initWithDoubles:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithDoubles:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBInt64DoubleDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBInt64DoubleDictionary class]]) { + return NO; + } + GPBInt64DoubleDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndDoublesUsingBlock: + (void (^)(int64_t key, double value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey longLongValue], [aValue doubleValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictDoubleFieldSize([aValue doubleValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + int64_t unwrappedKey = [aKey longLongValue]; + double unwrappedValue = [aValue doubleValue]; + size_t msgSize = ComputeDictInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictDoubleFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictDoubleField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueDouble) forKey:@(key->valueInt64)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndDoublesUsingBlock:^(int64_t key, double value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%lld", key], [NSString stringWithFormat:@"%.*lg", DBL_DIG, value]); + }]; +} + +- (BOOL)getDouble:(nullable double *)value forKey:(int64_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + *value = [wrapped doubleValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBInt64DoubleDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setDouble:(double)value forKey:(int64_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeDoubleForKey:(int64_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - Int64 -> Enum + +@implementation GPBInt64EnumDictionary { + @package + NSMutableDictionary *_dictionary; + GPBEnumValidationFunc _validationFunc; +} + +@synthesize validationFunc = _validationFunc; + ++ (instancetype)dictionary { + return [[[self alloc] initWithValidationFunction:NULL + rawValues:NULL + forKeys:NULL + count:0] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func { + return [[[self alloc] initWithValidationFunction:func + rawValues:NULL + forKeys:NULL + count:0] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func + rawValue:(int32_t)rawValue + forKey:(int64_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count: + // on to get the type correct. + return [[(GPBInt64EnumDictionary*)[self alloc] initWithValidationFunction:func + rawValues:&rawValue + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func + rawValues:(const int32_t [])rawValues + forKeys:(const int64_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count: + // on to get the type correct. + return [[(GPBInt64EnumDictionary*)[self alloc] initWithValidationFunction:func + rawValues:rawValues + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBInt64EnumDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count: + // on to get the type correct. + return [[(GPBInt64EnumDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems { + return [[[self alloc] initWithValidationFunction:func capacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithValidationFunction:NULL rawValues:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func { + return [self initWithValidationFunction:func rawValues:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func + rawValues:(const int32_t [])rawValues + forKeys:(const int64_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + _validationFunc = (func != NULL ? func : DictDefault_IsValidValue); + if (count && rawValues && keys) { + for (NSUInteger i = 0; i < count; ++i) { + [_dictionary setObject:@(rawValues[i]) forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBInt64EnumDictionary *)dictionary { + self = [self initWithValidationFunction:dictionary.validationFunc + rawValues:NULL + forKeys:NULL + count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithValidationFunction:func rawValues:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBInt64EnumDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBInt64EnumDictionary class]]) { + return NO; + } + GPBInt64EnumDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndRawValuesUsingBlock: + (void (^)(int64_t key, int32_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block([aKey longLongValue], [aValue intValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictEnumFieldSize([aValue intValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + int64_t unwrappedKey = [aKey longLongValue]; + int32_t unwrappedValue = [aValue intValue]; + size_t msgSize = ComputeDictInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictEnumFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictEnumField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (NSData *)serializedDataForUnknownValue:(int32_t)value + forKey:(GPBGenericValue *)key + keyDataType:(GPBDataType)keyDataType { + size_t msgSize = ComputeDictInt64FieldSize(key->valueInt64, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictEnumFieldSize(value, kMapValueFieldNumber, GPBDataTypeEnum); + NSMutableData *data = [NSMutableData dataWithLength:msgSize]; + GPBCodedOutputStream *outputStream = [[GPBCodedOutputStream alloc] initWithData:data]; + WriteDictInt64Field(outputStream, key->valueInt64, kMapKeyFieldNumber, keyDataType); + WriteDictEnumField(outputStream, value, kMapValueFieldNumber, GPBDataTypeEnum); + [outputStream release]; + return data; +} +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueEnum) forKey:@(key->valueInt64)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndRawValuesUsingBlock:^(int64_t key, int32_t value, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%lld", key], @(value)); + }]; +} + +- (BOOL)getEnum:(int32_t *)value forKey:(int64_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && value) { + int32_t result = [wrapped intValue]; + if (!_validationFunc(result)) { + result = kGPBUnrecognizedEnumeratorValue; + } + *value = result; + } + return (wrapped != NULL); +} + +- (BOOL)getRawValue:(int32_t *)rawValue forKey:(int64_t)key { + NSNumber *wrapped = [_dictionary objectForKey:@(key)]; + if (wrapped && rawValue) { + *rawValue = [wrapped intValue]; + } + return (wrapped != NULL); +} + +- (void)enumerateKeysAndEnumsUsingBlock: + (void (^)(int64_t key, int32_t value, BOOL *stop))block { + GPBEnumValidationFunc func = _validationFunc; + BOOL stop = NO; + NSEnumerator *keys = [_dictionary keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = _dictionary[aKey]; + int32_t unwrapped = [aValue intValue]; + if (!func(unwrapped)) { + unwrapped = kGPBUnrecognizedEnumeratorValue; + } + block([aKey longLongValue], unwrapped, &stop); + if (stop) { + break; + } + } +} + +- (void)addRawEntriesFromDictionary:(GPBInt64EnumDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setRawValue:(int32_t)value forKey:(int64_t)key { + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeEnumForKey:(int64_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +- (void)setEnum:(int32_t)value forKey:(int64_t)key { + if (!_validationFunc(value)) { + [NSException raise:NSInvalidArgumentException + format:@"GPBInt64EnumDictionary: Attempt to set an unknown enum value (%d)", + value]; + } + + [_dictionary setObject:@(value) forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +@end + +#pragma mark - Int64 -> Object + +@implementation GPBInt64ObjectDictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithObjects:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithObject:(id)object + forKey:(int64_t)key { + // Cast is needed so the compiler knows what class we are invoking initWithObjects:forKeys:count: + // on to get the type correct. + return [[(GPBInt64ObjectDictionary*)[self alloc] initWithObjects:&object + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithObjects:(const id [])objects + forKeys:(const int64_t [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithObjects:forKeys:count: + // on to get the type correct. + return [[(GPBInt64ObjectDictionary*)[self alloc] initWithObjects:objects + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBInt64ObjectDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBInt64ObjectDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithObjects:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithObjects:(const id [])objects + forKeys:(const int64_t [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && objects && keys) { + for (NSUInteger i = 0; i < count; ++i) { + if (!objects[i]) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil object to a Dictionary"]; + } + [_dictionary setObject:objects[i] forKey:@(keys[i])]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBInt64ObjectDictionary *)dictionary { + self = [self initWithObjects:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithObjects:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBInt64ObjectDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBInt64ObjectDictionary class]]) { + return NO; + } + GPBInt64ObjectDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndObjectsUsingBlock: + (void (^)(int64_t key, id object, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + id aObject = internal[aKey]; + block([aKey longLongValue], aObject, &stop); + if (stop) { + break; + } + } +} + +- (BOOL)isInitialized { + for (GPBMessage *msg in [_dictionary objectEnumerator]) { + if (!msg.initialized) { + return NO; + } + } + return YES; +} + +- (instancetype)deepCopyWithZone:(NSZone *)zone { + GPBInt64ObjectDictionary *newDict = + [[GPBInt64ObjectDictionary alloc] init]; + NSEnumerator *keys = [_dictionary keyEnumerator]; + id aKey; + NSMutableDictionary *internalDict = newDict->_dictionary; + while ((aKey = [keys nextObject])) { + GPBMessage *msg = _dictionary[aKey]; + GPBMessage *copiedMsg = [msg copyWithZone:zone]; + [internalDict setObject:copiedMsg forKey:aKey]; + [copiedMsg release]; + } + return newDict; +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + id aObject = internal[aKey]; + size_t msgSize = ComputeDictInt64FieldSize([aKey longLongValue], kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictObjectFieldSize(aObject, kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSNumber *aKey; + while ((aKey = [keys nextObject])) { + id aObject = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + int64_t unwrappedKey = [aKey longLongValue]; + id unwrappedValue = aObject; + size_t msgSize = ComputeDictInt64FieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictObjectFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictInt64Field(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictObjectField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:value->valueString forKey:@(key->valueInt64)]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndObjectsUsingBlock:^(int64_t key, id object, BOOL *stop) { + #pragma unused(stop) + block([NSString stringWithFormat:@"%lld", key], object); + }]; +} + +- (id)objectForKey:(int64_t)key { + id result = [_dictionary objectForKey:@(key)]; + return result; +} + +- (void)addEntriesFromDictionary:(GPBInt64ObjectDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setObject:(id)object forKey:(int64_t)key { + if (!object) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil object to a Dictionary"]; + } + [_dictionary setObject:object forKey:@(key)]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeObjectForKey:(int64_t)aKey { + [_dictionary removeObjectForKey:@(aKey)]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +//%PDDM-EXPAND DICTIONARY_POD_IMPL_FOR_KEY(String, NSString, *, OBJECT) +// This block of code is generated, do not edit it directly. + +#pragma mark - String -> UInt32 + +@implementation GPBStringUInt32Dictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithUInt32s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithUInt32:(uint32_t)value + forKey:(NSString *)key { + // Cast is needed so the compiler knows what class we are invoking initWithUInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBStringUInt32Dictionary*)[self alloc] initWithUInt32s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithUInt32s:(const uint32_t [])values + forKeys:(const NSString * [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithUInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBStringUInt32Dictionary*)[self alloc] initWithUInt32s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBStringUInt32Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBStringUInt32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithUInt32s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithUInt32s:(const uint32_t [])values + forKeys:(const NSString * [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + if (!keys[i]) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil key to a Dictionary"]; + } + [_dictionary setObject:@(values[i]) forKey:keys[i]]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBStringUInt32Dictionary *)dictionary { + self = [self initWithUInt32s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithUInt32s:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBStringUInt32Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBStringUInt32Dictionary class]]) { + return NO; + } + GPBStringUInt32Dictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndUInt32sUsingBlock: + (void (^)(NSString *key, uint32_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block(aKey, [aValue unsignedIntValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictUInt32FieldSize([aValue unsignedIntValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + NSString *unwrappedKey = aKey; + uint32_t unwrappedValue = [aValue unsignedIntValue]; + size_t msgSize = ComputeDictStringFieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictUInt32FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictStringField(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictUInt32Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueUInt32) forKey:key->valueString]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndUInt32sUsingBlock:^(NSString *key, uint32_t value, BOOL *stop) { + #pragma unused(stop) + block(key, [NSString stringWithFormat:@"%u", value]); + }]; +} + +- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(NSString *)key { + NSNumber *wrapped = [_dictionary objectForKey:key]; + if (wrapped && value) { + *value = [wrapped unsignedIntValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBStringUInt32Dictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setUInt32:(uint32_t)value forKey:(NSString *)key { + if (!key) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil key to a Dictionary"]; + } + [_dictionary setObject:@(value) forKey:key]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeUInt32ForKey:(NSString *)aKey { + [_dictionary removeObjectForKey:aKey]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - String -> Int32 + +@implementation GPBStringInt32Dictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithInt32s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithInt32:(int32_t)value + forKey:(NSString *)key { + // Cast is needed so the compiler knows what class we are invoking initWithInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBStringInt32Dictionary*)[self alloc] initWithInt32s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithInt32s:(const int32_t [])values + forKeys:(const NSString * [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBStringInt32Dictionary*)[self alloc] initWithInt32s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBStringInt32Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBStringInt32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithInt32s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithInt32s:(const int32_t [])values + forKeys:(const NSString * [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + if (!keys[i]) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil key to a Dictionary"]; + } + [_dictionary setObject:@(values[i]) forKey:keys[i]]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBStringInt32Dictionary *)dictionary { + self = [self initWithInt32s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithInt32s:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBStringInt32Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBStringInt32Dictionary class]]) { + return NO; + } + GPBStringInt32Dictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndInt32sUsingBlock: + (void (^)(NSString *key, int32_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block(aKey, [aValue intValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictInt32FieldSize([aValue intValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + NSString *unwrappedKey = aKey; + int32_t unwrappedValue = [aValue intValue]; + size_t msgSize = ComputeDictStringFieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictInt32FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictStringField(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictInt32Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueInt32) forKey:key->valueString]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndInt32sUsingBlock:^(NSString *key, int32_t value, BOOL *stop) { + #pragma unused(stop) + block(key, [NSString stringWithFormat:@"%d", value]); + }]; +} + +- (BOOL)getInt32:(nullable int32_t *)value forKey:(NSString *)key { + NSNumber *wrapped = [_dictionary objectForKey:key]; + if (wrapped && value) { + *value = [wrapped intValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBStringInt32Dictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setInt32:(int32_t)value forKey:(NSString *)key { + if (!key) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil key to a Dictionary"]; + } + [_dictionary setObject:@(value) forKey:key]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeInt32ForKey:(NSString *)aKey { + [_dictionary removeObjectForKey:aKey]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - String -> UInt64 + +@implementation GPBStringUInt64Dictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithUInt64s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithUInt64:(uint64_t)value + forKey:(NSString *)key { + // Cast is needed so the compiler knows what class we are invoking initWithUInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBStringUInt64Dictionary*)[self alloc] initWithUInt64s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithUInt64s:(const uint64_t [])values + forKeys:(const NSString * [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithUInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBStringUInt64Dictionary*)[self alloc] initWithUInt64s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBStringUInt64Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBStringUInt64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithUInt64s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithUInt64s:(const uint64_t [])values + forKeys:(const NSString * [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + if (!keys[i]) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil key to a Dictionary"]; + } + [_dictionary setObject:@(values[i]) forKey:keys[i]]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBStringUInt64Dictionary *)dictionary { + self = [self initWithUInt64s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithUInt64s:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBStringUInt64Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBStringUInt64Dictionary class]]) { + return NO; + } + GPBStringUInt64Dictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndUInt64sUsingBlock: + (void (^)(NSString *key, uint64_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block(aKey, [aValue unsignedLongLongValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictUInt64FieldSize([aValue unsignedLongLongValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + NSString *unwrappedKey = aKey; + uint64_t unwrappedValue = [aValue unsignedLongLongValue]; + size_t msgSize = ComputeDictStringFieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictUInt64FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictStringField(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictUInt64Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueUInt64) forKey:key->valueString]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndUInt64sUsingBlock:^(NSString *key, uint64_t value, BOOL *stop) { + #pragma unused(stop) + block(key, [NSString stringWithFormat:@"%llu", value]); + }]; +} + +- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(NSString *)key { + NSNumber *wrapped = [_dictionary objectForKey:key]; + if (wrapped && value) { + *value = [wrapped unsignedLongLongValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBStringUInt64Dictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setUInt64:(uint64_t)value forKey:(NSString *)key { + if (!key) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil key to a Dictionary"]; + } + [_dictionary setObject:@(value) forKey:key]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeUInt64ForKey:(NSString *)aKey { + [_dictionary removeObjectForKey:aKey]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - String -> Int64 + +@implementation GPBStringInt64Dictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithInt64s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithInt64:(int64_t)value + forKey:(NSString *)key { + // Cast is needed so the compiler knows what class we are invoking initWithInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBStringInt64Dictionary*)[self alloc] initWithInt64s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithInt64s:(const int64_t [])values + forKeys:(const NSString * [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBStringInt64Dictionary*)[self alloc] initWithInt64s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBStringInt64Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBStringInt64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithInt64s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithInt64s:(const int64_t [])values + forKeys:(const NSString * [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + if (!keys[i]) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil key to a Dictionary"]; + } + [_dictionary setObject:@(values[i]) forKey:keys[i]]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBStringInt64Dictionary *)dictionary { + self = [self initWithInt64s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithInt64s:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBStringInt64Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBStringInt64Dictionary class]]) { + return NO; + } + GPBStringInt64Dictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndInt64sUsingBlock: + (void (^)(NSString *key, int64_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block(aKey, [aValue longLongValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictInt64FieldSize([aValue longLongValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + NSString *unwrappedKey = aKey; + int64_t unwrappedValue = [aValue longLongValue]; + size_t msgSize = ComputeDictStringFieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictInt64FieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictStringField(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictInt64Field(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueInt64) forKey:key->valueString]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndInt64sUsingBlock:^(NSString *key, int64_t value, BOOL *stop) { + #pragma unused(stop) + block(key, [NSString stringWithFormat:@"%lld", value]); + }]; +} + +- (BOOL)getInt64:(nullable int64_t *)value forKey:(NSString *)key { + NSNumber *wrapped = [_dictionary objectForKey:key]; + if (wrapped && value) { + *value = [wrapped longLongValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBStringInt64Dictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setInt64:(int64_t)value forKey:(NSString *)key { + if (!key) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil key to a Dictionary"]; + } + [_dictionary setObject:@(value) forKey:key]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeInt64ForKey:(NSString *)aKey { + [_dictionary removeObjectForKey:aKey]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - String -> Bool + +@implementation GPBStringBoolDictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithBools:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithBool:(BOOL)value + forKey:(NSString *)key { + // Cast is needed so the compiler knows what class we are invoking initWithBools:forKeys:count: + // on to get the type correct. + return [[(GPBStringBoolDictionary*)[self alloc] initWithBools:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithBools:(const BOOL [])values + forKeys:(const NSString * [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithBools:forKeys:count: + // on to get the type correct. + return [[(GPBStringBoolDictionary*)[self alloc] initWithBools:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBStringBoolDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBStringBoolDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithBools:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithBools:(const BOOL [])values + forKeys:(const NSString * [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + if (!keys[i]) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil key to a Dictionary"]; + } + [_dictionary setObject:@(values[i]) forKey:keys[i]]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBStringBoolDictionary *)dictionary { + self = [self initWithBools:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithBools:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBStringBoolDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBStringBoolDictionary class]]) { + return NO; + } + GPBStringBoolDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndBoolsUsingBlock: + (void (^)(NSString *key, BOOL value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block(aKey, [aValue boolValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictBoolFieldSize([aValue boolValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + NSString *unwrappedKey = aKey; + BOOL unwrappedValue = [aValue boolValue]; + size_t msgSize = ComputeDictStringFieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictBoolFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictStringField(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictBoolField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueBool) forKey:key->valueString]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndBoolsUsingBlock:^(NSString *key, BOOL value, BOOL *stop) { + #pragma unused(stop) + block(key, (value ? @"true" : @"false")); + }]; +} + +- (BOOL)getBool:(nullable BOOL *)value forKey:(NSString *)key { + NSNumber *wrapped = [_dictionary objectForKey:key]; + if (wrapped && value) { + *value = [wrapped boolValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBStringBoolDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setBool:(BOOL)value forKey:(NSString *)key { + if (!key) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil key to a Dictionary"]; + } + [_dictionary setObject:@(value) forKey:key]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeBoolForKey:(NSString *)aKey { + [_dictionary removeObjectForKey:aKey]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - String -> Float + +@implementation GPBStringFloatDictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithFloats:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithFloat:(float)value + forKey:(NSString *)key { + // Cast is needed so the compiler knows what class we are invoking initWithFloats:forKeys:count: + // on to get the type correct. + return [[(GPBStringFloatDictionary*)[self alloc] initWithFloats:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithFloats:(const float [])values + forKeys:(const NSString * [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithFloats:forKeys:count: + // on to get the type correct. + return [[(GPBStringFloatDictionary*)[self alloc] initWithFloats:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBStringFloatDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBStringFloatDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithFloats:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithFloats:(const float [])values + forKeys:(const NSString * [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + if (!keys[i]) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil key to a Dictionary"]; + } + [_dictionary setObject:@(values[i]) forKey:keys[i]]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBStringFloatDictionary *)dictionary { + self = [self initWithFloats:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithFloats:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBStringFloatDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBStringFloatDictionary class]]) { + return NO; + } + GPBStringFloatDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndFloatsUsingBlock: + (void (^)(NSString *key, float value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block(aKey, [aValue floatValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictFloatFieldSize([aValue floatValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + NSString *unwrappedKey = aKey; + float unwrappedValue = [aValue floatValue]; + size_t msgSize = ComputeDictStringFieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictFloatFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictStringField(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictFloatField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueFloat) forKey:key->valueString]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndFloatsUsingBlock:^(NSString *key, float value, BOOL *stop) { + #pragma unused(stop) + block(key, [NSString stringWithFormat:@"%.*g", FLT_DIG, value]); + }]; +} + +- (BOOL)getFloat:(nullable float *)value forKey:(NSString *)key { + NSNumber *wrapped = [_dictionary objectForKey:key]; + if (wrapped && value) { + *value = [wrapped floatValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBStringFloatDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setFloat:(float)value forKey:(NSString *)key { + if (!key) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil key to a Dictionary"]; + } + [_dictionary setObject:@(value) forKey:key]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeFloatForKey:(NSString *)aKey { + [_dictionary removeObjectForKey:aKey]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - String -> Double + +@implementation GPBStringDoubleDictionary { + @package + NSMutableDictionary *_dictionary; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithDoubles:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithDouble:(double)value + forKey:(NSString *)key { + // Cast is needed so the compiler knows what class we are invoking initWithDoubles:forKeys:count: + // on to get the type correct. + return [[(GPBStringDoubleDictionary*)[self alloc] initWithDoubles:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithDoubles:(const double [])values + forKeys:(const NSString * [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithDoubles:forKeys:count: + // on to get the type correct. + return [[(GPBStringDoubleDictionary*)[self alloc] initWithDoubles:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBStringDoubleDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBStringDoubleDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithDoubles:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithDoubles:(const double [])values + forKeys:(const NSString * [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + if (count && values && keys) { + for (NSUInteger i = 0; i < count; ++i) { + if (!keys[i]) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil key to a Dictionary"]; + } + [_dictionary setObject:@(values[i]) forKey:keys[i]]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBStringDoubleDictionary *)dictionary { + self = [self initWithDoubles:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithDoubles:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBStringDoubleDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBStringDoubleDictionary class]]) { + return NO; + } + GPBStringDoubleDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndDoublesUsingBlock: + (void (^)(NSString *key, double value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block(aKey, [aValue doubleValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictDoubleFieldSize([aValue doubleValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + NSString *unwrappedKey = aKey; + double unwrappedValue = [aValue doubleValue]; + size_t msgSize = ComputeDictStringFieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictDoubleFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictStringField(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictDoubleField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueDouble) forKey:key->valueString]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndDoublesUsingBlock:^(NSString *key, double value, BOOL *stop) { + #pragma unused(stop) + block(key, [NSString stringWithFormat:@"%.*lg", DBL_DIG, value]); + }]; +} + +- (BOOL)getDouble:(nullable double *)value forKey:(NSString *)key { + NSNumber *wrapped = [_dictionary objectForKey:key]; + if (wrapped && value) { + *value = [wrapped doubleValue]; + } + return (wrapped != NULL); +} + +- (void)addEntriesFromDictionary:(GPBStringDoubleDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setDouble:(double)value forKey:(NSString *)key { + if (!key) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil key to a Dictionary"]; + } + [_dictionary setObject:@(value) forKey:key]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeDoubleForKey:(NSString *)aKey { + [_dictionary removeObjectForKey:aKey]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +@end + +#pragma mark - String -> Enum + +@implementation GPBStringEnumDictionary { + @package + NSMutableDictionary *_dictionary; + GPBEnumValidationFunc _validationFunc; +} + +@synthesize validationFunc = _validationFunc; + ++ (instancetype)dictionary { + return [[[self alloc] initWithValidationFunction:NULL + rawValues:NULL + forKeys:NULL + count:0] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func { + return [[[self alloc] initWithValidationFunction:func + rawValues:NULL + forKeys:NULL + count:0] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func + rawValue:(int32_t)rawValue + forKey:(NSString *)key { + // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count: + // on to get the type correct. + return [[(GPBStringEnumDictionary*)[self alloc] initWithValidationFunction:func + rawValues:&rawValue + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func + rawValues:(const int32_t [])rawValues + forKeys:(const NSString * [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count: + // on to get the type correct. + return [[(GPBStringEnumDictionary*)[self alloc] initWithValidationFunction:func + rawValues:rawValues + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBStringEnumDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count: + // on to get the type correct. + return [[(GPBStringEnumDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems { + return [[[self alloc] initWithValidationFunction:func capacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithValidationFunction:NULL rawValues:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func { + return [self initWithValidationFunction:func rawValues:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func + rawValues:(const int32_t [])rawValues + forKeys:(const NSString * [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] init]; + _validationFunc = (func != NULL ? func : DictDefault_IsValidValue); + if (count && rawValues && keys) { + for (NSUInteger i = 0; i < count; ++i) { + if (!keys[i]) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil key to a Dictionary"]; + } + [_dictionary setObject:@(rawValues[i]) forKey:keys[i]]; + } + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBStringEnumDictionary *)dictionary { + self = [self initWithValidationFunction:dictionary.validationFunc + rawValues:NULL + forKeys:NULL + count:0]; + if (self) { + if (dictionary) { + [_dictionary addEntriesFromDictionary:dictionary->_dictionary]; + } + } + return self; +} + +- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithValidationFunction:func rawValues:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBStringEnumDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBStringEnumDictionary class]]) { + return NO; + } + GPBStringEnumDictionary *otherDictionary = other; + return [_dictionary isEqual:otherDictionary->_dictionary]; +} + +- (NSUInteger)hash { + return _dictionary.count; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> { %@ }", [self class], self, _dictionary]; +} + +- (NSUInteger)count { + return _dictionary.count; +} + +- (void)enumerateKeysAndRawValuesUsingBlock: + (void (^)(NSString *key, int32_t value, BOOL *stop))block { + BOOL stop = NO; + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + block(aKey, [aValue intValue], &stop); + if (stop) { + break; + } + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + NSDictionary *internal = _dictionary; + NSUInteger count = internal.count; + if (count == 0) { + return 0; + } + + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + size_t result = 0; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + size_t msgSize = ComputeDictStringFieldSize(aKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictEnumFieldSize([aValue intValue], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + GPBDataType keyDataType = field.mapKeyDataType; + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + NSDictionary *internal = _dictionary; + NSEnumerator *keys = [internal keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = internal[aKey]; + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + NSString *unwrappedKey = aKey; + int32_t unwrappedValue = [aValue intValue]; + size_t msgSize = ComputeDictStringFieldSize(unwrappedKey, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictEnumFieldSize(unwrappedValue, kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictStringField(outputStream, unwrappedKey, kMapKeyFieldNumber, keyDataType); + WriteDictEnumField(outputStream, unwrappedValue, kMapValueFieldNumber, valueDataType); + } +} + +- (NSData *)serializedDataForUnknownValue:(int32_t)value + forKey:(GPBGenericValue *)key + keyDataType:(GPBDataType)keyDataType { + size_t msgSize = ComputeDictStringFieldSize(key->valueString, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictEnumFieldSize(value, kMapValueFieldNumber, GPBDataTypeEnum); + NSMutableData *data = [NSMutableData dataWithLength:msgSize]; + GPBCodedOutputStream *outputStream = [[GPBCodedOutputStream alloc] initWithData:data]; + WriteDictStringField(outputStream, key->valueString, kMapKeyFieldNumber, keyDataType); + WriteDictEnumField(outputStream, value, kMapValueFieldNumber, GPBDataTypeEnum); + [outputStream release]; + return data; +} +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + [_dictionary setObject:@(value->valueEnum) forKey:key->valueString]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + [self enumerateKeysAndRawValuesUsingBlock:^(NSString *key, int32_t value, BOOL *stop) { + #pragma unused(stop) + block(key, @(value)); + }]; +} + +- (BOOL)getEnum:(int32_t *)value forKey:(NSString *)key { + NSNumber *wrapped = [_dictionary objectForKey:key]; + if (wrapped && value) { + int32_t result = [wrapped intValue]; + if (!_validationFunc(result)) { + result = kGPBUnrecognizedEnumeratorValue; + } + *value = result; + } + return (wrapped != NULL); +} + +- (BOOL)getRawValue:(int32_t *)rawValue forKey:(NSString *)key { + NSNumber *wrapped = [_dictionary objectForKey:key]; + if (wrapped && rawValue) { + *rawValue = [wrapped intValue]; + } + return (wrapped != NULL); +} + +- (void)enumerateKeysAndEnumsUsingBlock: + (void (^)(NSString *key, int32_t value, BOOL *stop))block { + GPBEnumValidationFunc func = _validationFunc; + BOOL stop = NO; + NSEnumerator *keys = [_dictionary keyEnumerator]; + NSString *aKey; + while ((aKey = [keys nextObject])) { + NSNumber *aValue = _dictionary[aKey]; + int32_t unwrapped = [aValue intValue]; + if (!func(unwrapped)) { + unwrapped = kGPBUnrecognizedEnumeratorValue; + } + block(aKey, unwrapped, &stop); + if (stop) { + break; + } + } +} + +- (void)addRawEntriesFromDictionary:(GPBStringEnumDictionary *)otherDictionary { + if (otherDictionary) { + [_dictionary addEntriesFromDictionary:otherDictionary->_dictionary]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setRawValue:(int32_t)value forKey:(NSString *)key { + if (!key) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil key to a Dictionary"]; + } + [_dictionary setObject:@(value) forKey:key]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeEnumForKey:(NSString *)aKey { + [_dictionary removeObjectForKey:aKey]; +} + +- (void)removeAll { + [_dictionary removeAllObjects]; +} + +- (void)setEnum:(int32_t)value forKey:(NSString *)key { + if (!key) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil key to a Dictionary"]; + } + if (!_validationFunc(value)) { + [NSException raise:NSInvalidArgumentException + format:@"GPBStringEnumDictionary: Attempt to set an unknown enum value (%d)", + value]; + } + + [_dictionary setObject:@(value) forKey:key]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +@end + +//%PDDM-EXPAND-END (5 expansions) + + +//%PDDM-EXPAND DICTIONARY_BOOL_KEY_TO_POD_IMPL(UInt32, uint32_t) +// This block of code is generated, do not edit it directly. + +#pragma mark - Bool -> UInt32 + +@implementation GPBBoolUInt32Dictionary { + @package + uint32_t _values[2]; + BOOL _valueSet[2]; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithUInt32s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithUInt32:(uint32_t)value + forKey:(BOOL)key { + // Cast is needed so the compiler knows what class we are invoking initWithUInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBBoolUInt32Dictionary*)[self alloc] initWithUInt32s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithUInt32s:(const uint32_t [])values + forKeys:(const BOOL [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithUInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBBoolUInt32Dictionary*)[self alloc] initWithUInt32s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBBoolUInt32Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBBoolUInt32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithUInt32s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithUInt32s:(const uint32_t [])values + forKeys:(const BOOL [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + for (NSUInteger i = 0; i < count; ++i) { + int idx = keys[i] ? 1 : 0; + _values[idx] = values[i]; + _valueSet[idx] = YES; + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBBoolUInt32Dictionary *)dictionary { + self = [self initWithUInt32s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + for (int i = 0; i < 2; ++i) { + if (dictionary->_valueSet[i]) { + _values[i] = dictionary->_values[i]; + _valueSet[i] = YES; + } + } + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithUInt32s:NULL forKeys:NULL count:0]; +} + +#if !defined(NS_BLOCK_ASSERTIONS) +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [super dealloc]; +} +#endif // !defined(NS_BLOCK_ASSERTIONS) + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBBoolUInt32Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBBoolUInt32Dictionary class]]) { + return NO; + } + GPBBoolUInt32Dictionary *otherDictionary = other; + if ((_valueSet[0] != otherDictionary->_valueSet[0]) || + (_valueSet[1] != otherDictionary->_valueSet[1])) { + return NO; + } + if ((_valueSet[0] && (_values[0] != otherDictionary->_values[0])) || + (_valueSet[1] && (_values[1] != otherDictionary->_values[1]))) { + return NO; + } + return YES; +} + +- (NSUInteger)hash { + return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0); +} + +- (NSString *)description { + NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> {", [self class], self]; + if (_valueSet[0]) { + [result appendFormat:@"NO: %u", _values[0]]; + } + if (_valueSet[1]) { + [result appendFormat:@"YES: %u", _values[1]]; + } + [result appendString:@" }"]; + return result; +} + +- (NSUInteger)count { + return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0); +} + +- (BOOL)getUInt32:(uint32_t *)value forKey:(BOOL)key { + int idx = (key ? 1 : 0); + if (_valueSet[idx]) { + if (value) { + *value = _values[idx]; + } + return YES; + } + return NO; +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + int idx = (key->valueBool ? 1 : 0); + _values[idx] = value->valueUInt32; + _valueSet[idx] = YES; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + if (_valueSet[0]) { + block(@"false", [NSString stringWithFormat:@"%u", _values[0]]); + } + if (_valueSet[1]) { + block(@"true", [NSString stringWithFormat:@"%u", _values[1]]); + } +} + +- (void)enumerateKeysAndUInt32sUsingBlock: + (void (^)(BOOL key, uint32_t value, BOOL *stop))block { + BOOL stop = NO; + if (_valueSet[0]) { + block(NO, _values[0], &stop); + } + if (!stop && _valueSet[1]) { + block(YES, _values[1], &stop); + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + NSUInteger count = 0; + size_t result = 0; + for (int i = 0; i < 2; ++i) { + if (_valueSet[i]) { + ++count; + size_t msgSize = ComputeDictBoolFieldSize((i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + msgSize += ComputeDictUInt32FieldSize(_values[i], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + for (int i = 0; i < 2; ++i) { + if (_valueSet[i]) { + // Write the tag. + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + size_t msgSize = ComputeDictBoolFieldSize((i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + msgSize += ComputeDictUInt32FieldSize(_values[i], kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictBoolField(outputStream, (i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + WriteDictUInt32Field(outputStream, _values[i], kMapValueFieldNumber, valueDataType); + } + } +} + +- (void)addEntriesFromDictionary:(GPBBoolUInt32Dictionary *)otherDictionary { + if (otherDictionary) { + for (int i = 0; i < 2; ++i) { + if (otherDictionary->_valueSet[i]) { + _valueSet[i] = YES; + _values[i] = otherDictionary->_values[i]; + } + } + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setUInt32:(uint32_t)value forKey:(BOOL)key { + int idx = (key ? 1 : 0); + _values[idx] = value; + _valueSet[idx] = YES; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeUInt32ForKey:(BOOL)aKey { + _valueSet[aKey ? 1 : 0] = NO; +} + +- (void)removeAll { + _valueSet[0] = NO; + _valueSet[1] = NO; +} + +@end + +//%PDDM-EXPAND DICTIONARY_BOOL_KEY_TO_POD_IMPL(Int32, int32_t) +// This block of code is generated, do not edit it directly. + +#pragma mark - Bool -> Int32 + +@implementation GPBBoolInt32Dictionary { + @package + int32_t _values[2]; + BOOL _valueSet[2]; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithInt32s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithInt32:(int32_t)value + forKey:(BOOL)key { + // Cast is needed so the compiler knows what class we are invoking initWithInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBBoolInt32Dictionary*)[self alloc] initWithInt32s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithInt32s:(const int32_t [])values + forKeys:(const BOOL [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithInt32s:forKeys:count: + // on to get the type correct. + return [[(GPBBoolInt32Dictionary*)[self alloc] initWithInt32s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBBoolInt32Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBBoolInt32Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithInt32s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithInt32s:(const int32_t [])values + forKeys:(const BOOL [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + for (NSUInteger i = 0; i < count; ++i) { + int idx = keys[i] ? 1 : 0; + _values[idx] = values[i]; + _valueSet[idx] = YES; + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBBoolInt32Dictionary *)dictionary { + self = [self initWithInt32s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + for (int i = 0; i < 2; ++i) { + if (dictionary->_valueSet[i]) { + _values[i] = dictionary->_values[i]; + _valueSet[i] = YES; + } + } + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithInt32s:NULL forKeys:NULL count:0]; +} + +#if !defined(NS_BLOCK_ASSERTIONS) +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [super dealloc]; +} +#endif // !defined(NS_BLOCK_ASSERTIONS) + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBBoolInt32Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBBoolInt32Dictionary class]]) { + return NO; + } + GPBBoolInt32Dictionary *otherDictionary = other; + if ((_valueSet[0] != otherDictionary->_valueSet[0]) || + (_valueSet[1] != otherDictionary->_valueSet[1])) { + return NO; + } + if ((_valueSet[0] && (_values[0] != otherDictionary->_values[0])) || + (_valueSet[1] && (_values[1] != otherDictionary->_values[1]))) { + return NO; + } + return YES; +} + +- (NSUInteger)hash { + return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0); +} + +- (NSString *)description { + NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> {", [self class], self]; + if (_valueSet[0]) { + [result appendFormat:@"NO: %d", _values[0]]; + } + if (_valueSet[1]) { + [result appendFormat:@"YES: %d", _values[1]]; + } + [result appendString:@" }"]; + return result; +} + +- (NSUInteger)count { + return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0); +} + +- (BOOL)getInt32:(int32_t *)value forKey:(BOOL)key { + int idx = (key ? 1 : 0); + if (_valueSet[idx]) { + if (value) { + *value = _values[idx]; + } + return YES; + } + return NO; +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + int idx = (key->valueBool ? 1 : 0); + _values[idx] = value->valueInt32; + _valueSet[idx] = YES; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + if (_valueSet[0]) { + block(@"false", [NSString stringWithFormat:@"%d", _values[0]]); + } + if (_valueSet[1]) { + block(@"true", [NSString stringWithFormat:@"%d", _values[1]]); + } +} + +- (void)enumerateKeysAndInt32sUsingBlock: + (void (^)(BOOL key, int32_t value, BOOL *stop))block { + BOOL stop = NO; + if (_valueSet[0]) { + block(NO, _values[0], &stop); + } + if (!stop && _valueSet[1]) { + block(YES, _values[1], &stop); + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + NSUInteger count = 0; + size_t result = 0; + for (int i = 0; i < 2; ++i) { + if (_valueSet[i]) { + ++count; + size_t msgSize = ComputeDictBoolFieldSize((i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + msgSize += ComputeDictInt32FieldSize(_values[i], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + for (int i = 0; i < 2; ++i) { + if (_valueSet[i]) { + // Write the tag. + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + size_t msgSize = ComputeDictBoolFieldSize((i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + msgSize += ComputeDictInt32FieldSize(_values[i], kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictBoolField(outputStream, (i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + WriteDictInt32Field(outputStream, _values[i], kMapValueFieldNumber, valueDataType); + } + } +} + +- (void)addEntriesFromDictionary:(GPBBoolInt32Dictionary *)otherDictionary { + if (otherDictionary) { + for (int i = 0; i < 2; ++i) { + if (otherDictionary->_valueSet[i]) { + _valueSet[i] = YES; + _values[i] = otherDictionary->_values[i]; + } + } + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setInt32:(int32_t)value forKey:(BOOL)key { + int idx = (key ? 1 : 0); + _values[idx] = value; + _valueSet[idx] = YES; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeInt32ForKey:(BOOL)aKey { + _valueSet[aKey ? 1 : 0] = NO; +} + +- (void)removeAll { + _valueSet[0] = NO; + _valueSet[1] = NO; +} + +@end + +//%PDDM-EXPAND DICTIONARY_BOOL_KEY_TO_POD_IMPL(UInt64, uint64_t) +// This block of code is generated, do not edit it directly. + +#pragma mark - Bool -> UInt64 + +@implementation GPBBoolUInt64Dictionary { + @package + uint64_t _values[2]; + BOOL _valueSet[2]; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithUInt64s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithUInt64:(uint64_t)value + forKey:(BOOL)key { + // Cast is needed so the compiler knows what class we are invoking initWithUInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBBoolUInt64Dictionary*)[self alloc] initWithUInt64s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithUInt64s:(const uint64_t [])values + forKeys:(const BOOL [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithUInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBBoolUInt64Dictionary*)[self alloc] initWithUInt64s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBBoolUInt64Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBBoolUInt64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithUInt64s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithUInt64s:(const uint64_t [])values + forKeys:(const BOOL [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + for (NSUInteger i = 0; i < count; ++i) { + int idx = keys[i] ? 1 : 0; + _values[idx] = values[i]; + _valueSet[idx] = YES; + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBBoolUInt64Dictionary *)dictionary { + self = [self initWithUInt64s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + for (int i = 0; i < 2; ++i) { + if (dictionary->_valueSet[i]) { + _values[i] = dictionary->_values[i]; + _valueSet[i] = YES; + } + } + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithUInt64s:NULL forKeys:NULL count:0]; +} + +#if !defined(NS_BLOCK_ASSERTIONS) +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [super dealloc]; +} +#endif // !defined(NS_BLOCK_ASSERTIONS) + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBBoolUInt64Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBBoolUInt64Dictionary class]]) { + return NO; + } + GPBBoolUInt64Dictionary *otherDictionary = other; + if ((_valueSet[0] != otherDictionary->_valueSet[0]) || + (_valueSet[1] != otherDictionary->_valueSet[1])) { + return NO; + } + if ((_valueSet[0] && (_values[0] != otherDictionary->_values[0])) || + (_valueSet[1] && (_values[1] != otherDictionary->_values[1]))) { + return NO; + } + return YES; +} + +- (NSUInteger)hash { + return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0); +} + +- (NSString *)description { + NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> {", [self class], self]; + if (_valueSet[0]) { + [result appendFormat:@"NO: %llu", _values[0]]; + } + if (_valueSet[1]) { + [result appendFormat:@"YES: %llu", _values[1]]; + } + [result appendString:@" }"]; + return result; +} + +- (NSUInteger)count { + return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0); +} + +- (BOOL)getUInt64:(uint64_t *)value forKey:(BOOL)key { + int idx = (key ? 1 : 0); + if (_valueSet[idx]) { + if (value) { + *value = _values[idx]; + } + return YES; + } + return NO; +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + int idx = (key->valueBool ? 1 : 0); + _values[idx] = value->valueUInt64; + _valueSet[idx] = YES; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + if (_valueSet[0]) { + block(@"false", [NSString stringWithFormat:@"%llu", _values[0]]); + } + if (_valueSet[1]) { + block(@"true", [NSString stringWithFormat:@"%llu", _values[1]]); + } +} + +- (void)enumerateKeysAndUInt64sUsingBlock: + (void (^)(BOOL key, uint64_t value, BOOL *stop))block { + BOOL stop = NO; + if (_valueSet[0]) { + block(NO, _values[0], &stop); + } + if (!stop && _valueSet[1]) { + block(YES, _values[1], &stop); + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + NSUInteger count = 0; + size_t result = 0; + for (int i = 0; i < 2; ++i) { + if (_valueSet[i]) { + ++count; + size_t msgSize = ComputeDictBoolFieldSize((i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + msgSize += ComputeDictUInt64FieldSize(_values[i], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + for (int i = 0; i < 2; ++i) { + if (_valueSet[i]) { + // Write the tag. + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + size_t msgSize = ComputeDictBoolFieldSize((i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + msgSize += ComputeDictUInt64FieldSize(_values[i], kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictBoolField(outputStream, (i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + WriteDictUInt64Field(outputStream, _values[i], kMapValueFieldNumber, valueDataType); + } + } +} + +- (void)addEntriesFromDictionary:(GPBBoolUInt64Dictionary *)otherDictionary { + if (otherDictionary) { + for (int i = 0; i < 2; ++i) { + if (otherDictionary->_valueSet[i]) { + _valueSet[i] = YES; + _values[i] = otherDictionary->_values[i]; + } + } + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setUInt64:(uint64_t)value forKey:(BOOL)key { + int idx = (key ? 1 : 0); + _values[idx] = value; + _valueSet[idx] = YES; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeUInt64ForKey:(BOOL)aKey { + _valueSet[aKey ? 1 : 0] = NO; +} + +- (void)removeAll { + _valueSet[0] = NO; + _valueSet[1] = NO; +} + +@end + +//%PDDM-EXPAND DICTIONARY_BOOL_KEY_TO_POD_IMPL(Int64, int64_t) +// This block of code is generated, do not edit it directly. + +#pragma mark - Bool -> Int64 + +@implementation GPBBoolInt64Dictionary { + @package + int64_t _values[2]; + BOOL _valueSet[2]; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithInt64s:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithInt64:(int64_t)value + forKey:(BOOL)key { + // Cast is needed so the compiler knows what class we are invoking initWithInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBBoolInt64Dictionary*)[self alloc] initWithInt64s:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithInt64s:(const int64_t [])values + forKeys:(const BOOL [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithInt64s:forKeys:count: + // on to get the type correct. + return [[(GPBBoolInt64Dictionary*)[self alloc] initWithInt64s:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBBoolInt64Dictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBBoolInt64Dictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithInt64s:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithInt64s:(const int64_t [])values + forKeys:(const BOOL [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + for (NSUInteger i = 0; i < count; ++i) { + int idx = keys[i] ? 1 : 0; + _values[idx] = values[i]; + _valueSet[idx] = YES; + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBBoolInt64Dictionary *)dictionary { + self = [self initWithInt64s:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + for (int i = 0; i < 2; ++i) { + if (dictionary->_valueSet[i]) { + _values[i] = dictionary->_values[i]; + _valueSet[i] = YES; + } + } + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithInt64s:NULL forKeys:NULL count:0]; +} + +#if !defined(NS_BLOCK_ASSERTIONS) +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [super dealloc]; +} +#endif // !defined(NS_BLOCK_ASSERTIONS) + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBBoolInt64Dictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBBoolInt64Dictionary class]]) { + return NO; + } + GPBBoolInt64Dictionary *otherDictionary = other; + if ((_valueSet[0] != otherDictionary->_valueSet[0]) || + (_valueSet[1] != otherDictionary->_valueSet[1])) { + return NO; + } + if ((_valueSet[0] && (_values[0] != otherDictionary->_values[0])) || + (_valueSet[1] && (_values[1] != otherDictionary->_values[1]))) { + return NO; + } + return YES; +} + +- (NSUInteger)hash { + return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0); +} + +- (NSString *)description { + NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> {", [self class], self]; + if (_valueSet[0]) { + [result appendFormat:@"NO: %lld", _values[0]]; + } + if (_valueSet[1]) { + [result appendFormat:@"YES: %lld", _values[1]]; + } + [result appendString:@" }"]; + return result; +} + +- (NSUInteger)count { + return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0); +} + +- (BOOL)getInt64:(int64_t *)value forKey:(BOOL)key { + int idx = (key ? 1 : 0); + if (_valueSet[idx]) { + if (value) { + *value = _values[idx]; + } + return YES; + } + return NO; +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + int idx = (key->valueBool ? 1 : 0); + _values[idx] = value->valueInt64; + _valueSet[idx] = YES; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + if (_valueSet[0]) { + block(@"false", [NSString stringWithFormat:@"%lld", _values[0]]); + } + if (_valueSet[1]) { + block(@"true", [NSString stringWithFormat:@"%lld", _values[1]]); + } +} + +- (void)enumerateKeysAndInt64sUsingBlock: + (void (^)(BOOL key, int64_t value, BOOL *stop))block { + BOOL stop = NO; + if (_valueSet[0]) { + block(NO, _values[0], &stop); + } + if (!stop && _valueSet[1]) { + block(YES, _values[1], &stop); + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + NSUInteger count = 0; + size_t result = 0; + for (int i = 0; i < 2; ++i) { + if (_valueSet[i]) { + ++count; + size_t msgSize = ComputeDictBoolFieldSize((i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + msgSize += ComputeDictInt64FieldSize(_values[i], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + for (int i = 0; i < 2; ++i) { + if (_valueSet[i]) { + // Write the tag. + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + size_t msgSize = ComputeDictBoolFieldSize((i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + msgSize += ComputeDictInt64FieldSize(_values[i], kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictBoolField(outputStream, (i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + WriteDictInt64Field(outputStream, _values[i], kMapValueFieldNumber, valueDataType); + } + } +} + +- (void)addEntriesFromDictionary:(GPBBoolInt64Dictionary *)otherDictionary { + if (otherDictionary) { + for (int i = 0; i < 2; ++i) { + if (otherDictionary->_valueSet[i]) { + _valueSet[i] = YES; + _values[i] = otherDictionary->_values[i]; + } + } + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setInt64:(int64_t)value forKey:(BOOL)key { + int idx = (key ? 1 : 0); + _values[idx] = value; + _valueSet[idx] = YES; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeInt64ForKey:(BOOL)aKey { + _valueSet[aKey ? 1 : 0] = NO; +} + +- (void)removeAll { + _valueSet[0] = NO; + _valueSet[1] = NO; +} + +@end + +//%PDDM-EXPAND DICTIONARY_BOOL_KEY_TO_POD_IMPL(Bool, BOOL) +// This block of code is generated, do not edit it directly. + +#pragma mark - Bool -> Bool + +@implementation GPBBoolBoolDictionary { + @package + BOOL _values[2]; + BOOL _valueSet[2]; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithBools:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithBool:(BOOL)value + forKey:(BOOL)key { + // Cast is needed so the compiler knows what class we are invoking initWithBools:forKeys:count: + // on to get the type correct. + return [[(GPBBoolBoolDictionary*)[self alloc] initWithBools:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithBools:(const BOOL [])values + forKeys:(const BOOL [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithBools:forKeys:count: + // on to get the type correct. + return [[(GPBBoolBoolDictionary*)[self alloc] initWithBools:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBBoolBoolDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBBoolBoolDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithBools:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithBools:(const BOOL [])values + forKeys:(const BOOL [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + for (NSUInteger i = 0; i < count; ++i) { + int idx = keys[i] ? 1 : 0; + _values[idx] = values[i]; + _valueSet[idx] = YES; + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBBoolBoolDictionary *)dictionary { + self = [self initWithBools:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + for (int i = 0; i < 2; ++i) { + if (dictionary->_valueSet[i]) { + _values[i] = dictionary->_values[i]; + _valueSet[i] = YES; + } + } + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithBools:NULL forKeys:NULL count:0]; +} + +#if !defined(NS_BLOCK_ASSERTIONS) +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [super dealloc]; +} +#endif // !defined(NS_BLOCK_ASSERTIONS) + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBBoolBoolDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBBoolBoolDictionary class]]) { + return NO; + } + GPBBoolBoolDictionary *otherDictionary = other; + if ((_valueSet[0] != otherDictionary->_valueSet[0]) || + (_valueSet[1] != otherDictionary->_valueSet[1])) { + return NO; + } + if ((_valueSet[0] && (_values[0] != otherDictionary->_values[0])) || + (_valueSet[1] && (_values[1] != otherDictionary->_values[1]))) { + return NO; + } + return YES; +} + +- (NSUInteger)hash { + return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0); +} + +- (NSString *)description { + NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> {", [self class], self]; + if (_valueSet[0]) { + [result appendFormat:@"NO: %d", _values[0]]; + } + if (_valueSet[1]) { + [result appendFormat:@"YES: %d", _values[1]]; + } + [result appendString:@" }"]; + return result; +} + +- (NSUInteger)count { + return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0); +} + +- (BOOL)getBool:(BOOL *)value forKey:(BOOL)key { + int idx = (key ? 1 : 0); + if (_valueSet[idx]) { + if (value) { + *value = _values[idx]; + } + return YES; + } + return NO; +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + int idx = (key->valueBool ? 1 : 0); + _values[idx] = value->valueBool; + _valueSet[idx] = YES; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + if (_valueSet[0]) { + block(@"false", (_values[0] ? @"true" : @"false")); + } + if (_valueSet[1]) { + block(@"true", (_values[1] ? @"true" : @"false")); + } +} + +- (void)enumerateKeysAndBoolsUsingBlock: + (void (^)(BOOL key, BOOL value, BOOL *stop))block { + BOOL stop = NO; + if (_valueSet[0]) { + block(NO, _values[0], &stop); + } + if (!stop && _valueSet[1]) { + block(YES, _values[1], &stop); + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + NSUInteger count = 0; + size_t result = 0; + for (int i = 0; i < 2; ++i) { + if (_valueSet[i]) { + ++count; + size_t msgSize = ComputeDictBoolFieldSize((i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + msgSize += ComputeDictBoolFieldSize(_values[i], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + for (int i = 0; i < 2; ++i) { + if (_valueSet[i]) { + // Write the tag. + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + size_t msgSize = ComputeDictBoolFieldSize((i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + msgSize += ComputeDictBoolFieldSize(_values[i], kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictBoolField(outputStream, (i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + WriteDictBoolField(outputStream, _values[i], kMapValueFieldNumber, valueDataType); + } + } +} + +- (void)addEntriesFromDictionary:(GPBBoolBoolDictionary *)otherDictionary { + if (otherDictionary) { + for (int i = 0; i < 2; ++i) { + if (otherDictionary->_valueSet[i]) { + _valueSet[i] = YES; + _values[i] = otherDictionary->_values[i]; + } + } + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setBool:(BOOL)value forKey:(BOOL)key { + int idx = (key ? 1 : 0); + _values[idx] = value; + _valueSet[idx] = YES; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeBoolForKey:(BOOL)aKey { + _valueSet[aKey ? 1 : 0] = NO; +} + +- (void)removeAll { + _valueSet[0] = NO; + _valueSet[1] = NO; +} + +@end + +//%PDDM-EXPAND DICTIONARY_BOOL_KEY_TO_POD_IMPL(Float, float) +// This block of code is generated, do not edit it directly. + +#pragma mark - Bool -> Float + +@implementation GPBBoolFloatDictionary { + @package + float _values[2]; + BOOL _valueSet[2]; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithFloats:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithFloat:(float)value + forKey:(BOOL)key { + // Cast is needed so the compiler knows what class we are invoking initWithFloats:forKeys:count: + // on to get the type correct. + return [[(GPBBoolFloatDictionary*)[self alloc] initWithFloats:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithFloats:(const float [])values + forKeys:(const BOOL [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithFloats:forKeys:count: + // on to get the type correct. + return [[(GPBBoolFloatDictionary*)[self alloc] initWithFloats:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBBoolFloatDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBBoolFloatDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithFloats:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithFloats:(const float [])values + forKeys:(const BOOL [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + for (NSUInteger i = 0; i < count; ++i) { + int idx = keys[i] ? 1 : 0; + _values[idx] = values[i]; + _valueSet[idx] = YES; + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBBoolFloatDictionary *)dictionary { + self = [self initWithFloats:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + for (int i = 0; i < 2; ++i) { + if (dictionary->_valueSet[i]) { + _values[i] = dictionary->_values[i]; + _valueSet[i] = YES; + } + } + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithFloats:NULL forKeys:NULL count:0]; +} + +#if !defined(NS_BLOCK_ASSERTIONS) +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [super dealloc]; +} +#endif // !defined(NS_BLOCK_ASSERTIONS) + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBBoolFloatDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBBoolFloatDictionary class]]) { + return NO; + } + GPBBoolFloatDictionary *otherDictionary = other; + if ((_valueSet[0] != otherDictionary->_valueSet[0]) || + (_valueSet[1] != otherDictionary->_valueSet[1])) { + return NO; + } + if ((_valueSet[0] && (_values[0] != otherDictionary->_values[0])) || + (_valueSet[1] && (_values[1] != otherDictionary->_values[1]))) { + return NO; + } + return YES; +} + +- (NSUInteger)hash { + return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0); +} + +- (NSString *)description { + NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> {", [self class], self]; + if (_valueSet[0]) { + [result appendFormat:@"NO: %f", _values[0]]; + } + if (_valueSet[1]) { + [result appendFormat:@"YES: %f", _values[1]]; + } + [result appendString:@" }"]; + return result; +} + +- (NSUInteger)count { + return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0); +} + +- (BOOL)getFloat:(float *)value forKey:(BOOL)key { + int idx = (key ? 1 : 0); + if (_valueSet[idx]) { + if (value) { + *value = _values[idx]; + } + return YES; + } + return NO; +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + int idx = (key->valueBool ? 1 : 0); + _values[idx] = value->valueFloat; + _valueSet[idx] = YES; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + if (_valueSet[0]) { + block(@"false", [NSString stringWithFormat:@"%.*g", FLT_DIG, _values[0]]); + } + if (_valueSet[1]) { + block(@"true", [NSString stringWithFormat:@"%.*g", FLT_DIG, _values[1]]); + } +} + +- (void)enumerateKeysAndFloatsUsingBlock: + (void (^)(BOOL key, float value, BOOL *stop))block { + BOOL stop = NO; + if (_valueSet[0]) { + block(NO, _values[0], &stop); + } + if (!stop && _valueSet[1]) { + block(YES, _values[1], &stop); + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + NSUInteger count = 0; + size_t result = 0; + for (int i = 0; i < 2; ++i) { + if (_valueSet[i]) { + ++count; + size_t msgSize = ComputeDictBoolFieldSize((i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + msgSize += ComputeDictFloatFieldSize(_values[i], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + for (int i = 0; i < 2; ++i) { + if (_valueSet[i]) { + // Write the tag. + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + size_t msgSize = ComputeDictBoolFieldSize((i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + msgSize += ComputeDictFloatFieldSize(_values[i], kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictBoolField(outputStream, (i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + WriteDictFloatField(outputStream, _values[i], kMapValueFieldNumber, valueDataType); + } + } +} + +- (void)addEntriesFromDictionary:(GPBBoolFloatDictionary *)otherDictionary { + if (otherDictionary) { + for (int i = 0; i < 2; ++i) { + if (otherDictionary->_valueSet[i]) { + _valueSet[i] = YES; + _values[i] = otherDictionary->_values[i]; + } + } + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setFloat:(float)value forKey:(BOOL)key { + int idx = (key ? 1 : 0); + _values[idx] = value; + _valueSet[idx] = YES; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeFloatForKey:(BOOL)aKey { + _valueSet[aKey ? 1 : 0] = NO; +} + +- (void)removeAll { + _valueSet[0] = NO; + _valueSet[1] = NO; +} + +@end + +//%PDDM-EXPAND DICTIONARY_BOOL_KEY_TO_POD_IMPL(Double, double) +// This block of code is generated, do not edit it directly. + +#pragma mark - Bool -> Double + +@implementation GPBBoolDoubleDictionary { + @package + double _values[2]; + BOOL _valueSet[2]; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithDoubles:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithDouble:(double)value + forKey:(BOOL)key { + // Cast is needed so the compiler knows what class we are invoking initWithDoubles:forKeys:count: + // on to get the type correct. + return [[(GPBBoolDoubleDictionary*)[self alloc] initWithDoubles:&value + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithDoubles:(const double [])values + forKeys:(const BOOL [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithDoubles:forKeys:count: + // on to get the type correct. + return [[(GPBBoolDoubleDictionary*)[self alloc] initWithDoubles:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBBoolDoubleDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBBoolDoubleDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithDoubles:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithDoubles:(const double [])values + forKeys:(const BOOL [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + for (NSUInteger i = 0; i < count; ++i) { + int idx = keys[i] ? 1 : 0; + _values[idx] = values[i]; + _valueSet[idx] = YES; + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBBoolDoubleDictionary *)dictionary { + self = [self initWithDoubles:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + for (int i = 0; i < 2; ++i) { + if (dictionary->_valueSet[i]) { + _values[i] = dictionary->_values[i]; + _valueSet[i] = YES; + } + } + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithDoubles:NULL forKeys:NULL count:0]; +} + +#if !defined(NS_BLOCK_ASSERTIONS) +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [super dealloc]; +} +#endif // !defined(NS_BLOCK_ASSERTIONS) + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBBoolDoubleDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBBoolDoubleDictionary class]]) { + return NO; + } + GPBBoolDoubleDictionary *otherDictionary = other; + if ((_valueSet[0] != otherDictionary->_valueSet[0]) || + (_valueSet[1] != otherDictionary->_valueSet[1])) { + return NO; + } + if ((_valueSet[0] && (_values[0] != otherDictionary->_values[0])) || + (_valueSet[1] && (_values[1] != otherDictionary->_values[1]))) { + return NO; + } + return YES; +} + +- (NSUInteger)hash { + return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0); +} + +- (NSString *)description { + NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> {", [self class], self]; + if (_valueSet[0]) { + [result appendFormat:@"NO: %lf", _values[0]]; + } + if (_valueSet[1]) { + [result appendFormat:@"YES: %lf", _values[1]]; + } + [result appendString:@" }"]; + return result; +} + +- (NSUInteger)count { + return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0); +} + +- (BOOL)getDouble:(double *)value forKey:(BOOL)key { + int idx = (key ? 1 : 0); + if (_valueSet[idx]) { + if (value) { + *value = _values[idx]; + } + return YES; + } + return NO; +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + int idx = (key->valueBool ? 1 : 0); + _values[idx] = value->valueDouble; + _valueSet[idx] = YES; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + if (_valueSet[0]) { + block(@"false", [NSString stringWithFormat:@"%.*lg", DBL_DIG, _values[0]]); + } + if (_valueSet[1]) { + block(@"true", [NSString stringWithFormat:@"%.*lg", DBL_DIG, _values[1]]); + } +} + +- (void)enumerateKeysAndDoublesUsingBlock: + (void (^)(BOOL key, double value, BOOL *stop))block { + BOOL stop = NO; + if (_valueSet[0]) { + block(NO, _values[0], &stop); + } + if (!stop && _valueSet[1]) { + block(YES, _values[1], &stop); + } +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + NSUInteger count = 0; + size_t result = 0; + for (int i = 0; i < 2; ++i) { + if (_valueSet[i]) { + ++count; + size_t msgSize = ComputeDictBoolFieldSize((i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + msgSize += ComputeDictDoubleFieldSize(_values[i], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + for (int i = 0; i < 2; ++i) { + if (_valueSet[i]) { + // Write the tag. + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + size_t msgSize = ComputeDictBoolFieldSize((i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + msgSize += ComputeDictDoubleFieldSize(_values[i], kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictBoolField(outputStream, (i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + WriteDictDoubleField(outputStream, _values[i], kMapValueFieldNumber, valueDataType); + } + } +} + +- (void)addEntriesFromDictionary:(GPBBoolDoubleDictionary *)otherDictionary { + if (otherDictionary) { + for (int i = 0; i < 2; ++i) { + if (otherDictionary->_valueSet[i]) { + _valueSet[i] = YES; + _values[i] = otherDictionary->_values[i]; + } + } + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setDouble:(double)value forKey:(BOOL)key { + int idx = (key ? 1 : 0); + _values[idx] = value; + _valueSet[idx] = YES; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeDoubleForKey:(BOOL)aKey { + _valueSet[aKey ? 1 : 0] = NO; +} + +- (void)removeAll { + _valueSet[0] = NO; + _valueSet[1] = NO; +} + +@end + +//%PDDM-EXPAND DICTIONARY_BOOL_KEY_TO_OBJECT_IMPL(Object, id) +// This block of code is generated, do not edit it directly. + +#pragma mark - Bool -> Object + +@implementation GPBBoolObjectDictionary { + @package + id _values[2]; +} + ++ (instancetype)dictionary { + return [[[self alloc] initWithObjects:NULL forKeys:NULL count:0] autorelease]; +} + ++ (instancetype)dictionaryWithObject:(id)object + forKey:(BOOL)key { + // Cast is needed so the compiler knows what class we are invoking initWithObjects:forKeys:count: + // on to get the type correct. + return [[(GPBBoolObjectDictionary*)[self alloc] initWithObjects:&object + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithObjects:(const id [])objects + forKeys:(const BOOL [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithObjects:forKeys:count: + // on to get the type correct. + return [[(GPBBoolObjectDictionary*)[self alloc] initWithObjects:objects + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBBoolObjectDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithDictionary: + // on to get the type correct. + return [[(GPBBoolObjectDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems { + return [[[self alloc] initWithCapacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithObjects:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithObjects:(const id [])objects + forKeys:(const BOOL [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + for (NSUInteger i = 0; i < count; ++i) { + if (!objects[i]) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil object to a Dictionary"]; + } + int idx = keys[i] ? 1 : 0; + [_values[idx] release]; + _values[idx] = (id)[objects[i] retain]; + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBBoolObjectDictionary *)dictionary { + self = [self initWithObjects:NULL forKeys:NULL count:0]; + if (self) { + if (dictionary) { + _values[0] = [dictionary->_values[0] retain]; + _values[1] = [dictionary->_values[1] retain]; + } + } + return self; +} + +- (instancetype)initWithCapacity:(NSUInteger)numItems { + #pragma unused(numItems) + return [self initWithObjects:NULL forKeys:NULL count:0]; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_values[0] release]; + [_values[1] release]; + [super dealloc]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBBoolObjectDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBBoolObjectDictionary class]]) { + return NO; + } + GPBBoolObjectDictionary *otherDictionary = other; + if (((_values[0] != nil) != (otherDictionary->_values[0] != nil)) || + ((_values[1] != nil) != (otherDictionary->_values[1] != nil))) { + return NO; + } + if (((_values[0] != nil) && (![_values[0] isEqual:otherDictionary->_values[0]])) || + ((_values[1] != nil) && (![_values[1] isEqual:otherDictionary->_values[1]]))) { + return NO; + } + return YES; +} + +- (NSUInteger)hash { + return ((_values[0] != nil) ? 1 : 0) + ((_values[1] != nil) ? 1 : 0); +} + +- (NSString *)description { + NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> {", [self class], self]; + if ((_values[0] != nil)) { + [result appendFormat:@"NO: %@", _values[0]]; + } + if ((_values[1] != nil)) { + [result appendFormat:@"YES: %@", _values[1]]; + } + [result appendString:@" }"]; + return result; +} + +- (NSUInteger)count { + return ((_values[0] != nil) ? 1 : 0) + ((_values[1] != nil) ? 1 : 0); +} + +- (id)objectForKey:(BOOL)key { + return _values[key ? 1 : 0]; +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + int idx = (key->valueBool ? 1 : 0); + [_values[idx] release]; + _values[idx] = [value->valueString retain]; +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + if (_values[0] != nil) { + block(@"false", _values[0]); + } + if ((_values[1] != nil)) { + block(@"true", _values[1]); + } +} + +- (void)enumerateKeysAndObjectsUsingBlock: + (void (^)(BOOL key, id object, BOOL *stop))block { + BOOL stop = NO; + if (_values[0] != nil) { + block(NO, _values[0], &stop); + } + if (!stop && (_values[1] != nil)) { + block(YES, _values[1], &stop); + } +} + +- (BOOL)isInitialized { + if (_values[0] && ![_values[0] isInitialized]) { + return NO; + } + if (_values[1] && ![_values[1] isInitialized]) { + return NO; + } + return YES; +} + +- (instancetype)deepCopyWithZone:(NSZone *)zone { + GPBBoolObjectDictionary *newDict = + [[GPBBoolObjectDictionary alloc] init]; + for (int i = 0; i < 2; ++i) { + if (_values[i] != nil) { + newDict->_values[i] = [_values[i] copyWithZone:zone]; + } + } + return newDict; +} + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + NSUInteger count = 0; + size_t result = 0; + for (int i = 0; i < 2; ++i) { + if (_values[i] != nil) { + ++count; + size_t msgSize = ComputeDictBoolFieldSize((i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + msgSize += ComputeDictObjectFieldSize(_values[i], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + for (int i = 0; i < 2; ++i) { + if (_values[i] != nil) { + // Write the tag. + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + size_t msgSize = ComputeDictBoolFieldSize((i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + msgSize += ComputeDictObjectFieldSize(_values[i], kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictBoolField(outputStream, (i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + WriteDictObjectField(outputStream, _values[i], kMapValueFieldNumber, valueDataType); + } + } +} + +- (void)addEntriesFromDictionary:(GPBBoolObjectDictionary *)otherDictionary { + if (otherDictionary) { + for (int i = 0; i < 2; ++i) { + if (otherDictionary->_values[i] != nil) { + [_values[i] release]; + _values[i] = [otherDictionary->_values[i] retain]; + } + } + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setObject:(id)object forKey:(BOOL)key { + if (!object) { + [NSException raise:NSInvalidArgumentException + format:@"Attempting to add nil object to a Dictionary"]; + } + int idx = (key ? 1 : 0); + [_values[idx] release]; + _values[idx] = [object retain]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeObjectForKey:(BOOL)aKey { + int idx = (aKey ? 1 : 0); + [_values[idx] release]; + _values[idx] = nil; +} + +- (void)removeAll { + for (int i = 0; i < 2; ++i) { + [_values[i] release]; + _values[i] = nil; + } +} + +@end + +//%PDDM-EXPAND-END (8 expansions) + +#pragma mark - Bool -> Enum + +@implementation GPBBoolEnumDictionary { + @package + GPBEnumValidationFunc _validationFunc; + int32_t _values[2]; + BOOL _valueSet[2]; +} + +@synthesize validationFunc = _validationFunc; + ++ (instancetype)dictionary { + return [[[self alloc] initWithValidationFunction:NULL + rawValues:NULL + forKeys:NULL + count:0] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func { + return [[[self alloc] initWithValidationFunction:func + rawValues:NULL + forKeys:NULL + count:0] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func + rawValue:(int32_t)rawValue + forKey:(BOOL)key { + // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count: + // on to get the type correct. + return [[(GPBBoolEnumDictionary*)[self alloc] initWithValidationFunction:func + rawValues:&rawValue + forKeys:&key + count:1] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func + rawValues:(const int32_t [])values + forKeys:(const BOOL [])keys + count:(NSUInteger)count { + // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count: + // on to get the type correct. + return [[(GPBBoolEnumDictionary*)[self alloc] initWithValidationFunction:func + rawValues:values + forKeys:keys + count:count] autorelease]; +} + ++ (instancetype)dictionaryWithDictionary:(GPBBoolEnumDictionary *)dictionary { + // Cast is needed so the compiler knows what class we are invoking initWithValues:forKeys:count: + // on to get the type correct. + return [[(GPBBoolEnumDictionary*)[self alloc] initWithDictionary:dictionary] autorelease]; +} + ++ (instancetype)dictionaryWithValidationFunction:(GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems { + return [[[self alloc] initWithValidationFunction:func capacity:numItems] autorelease]; +} + +- (instancetype)init { + return [self initWithValidationFunction:NULL rawValues:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func { + return [self initWithValidationFunction:func rawValues:NULL forKeys:NULL count:0]; +} + +- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func + rawValues:(const int32_t [])rawValues + forKeys:(const BOOL [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _validationFunc = (func != NULL ? func : DictDefault_IsValidValue); + for (NSUInteger i = 0; i < count; ++i) { + int idx = keys[i] ? 1 : 0; + _values[idx] = rawValues[i]; + _valueSet[idx] = YES; + } + } + return self; +} + +- (instancetype)initWithDictionary:(GPBBoolEnumDictionary *)dictionary { + self = [self initWithValidationFunction:dictionary.validationFunc + rawValues:NULL + forKeys:NULL + count:0]; + if (self) { + if (dictionary) { + for (int i = 0; i < 2; ++i) { + if (dictionary->_valueSet[i]) { + _values[i] = dictionary->_values[i]; + _valueSet[i] = YES; + } + } + } + } + return self; +} + +- (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func + capacity:(NSUInteger)numItems { +#pragma unused(numItems) + return [self initWithValidationFunction:func rawValues:NULL forKeys:NULL count:0]; +} + +#if !defined(NS_BLOCK_ASSERTIONS) +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [super dealloc]; +} +#endif // !defined(NS_BLOCK_ASSERTIONS) + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[GPBBoolEnumDictionary allocWithZone:zone] initWithDictionary:self]; +} + +- (BOOL)isEqual:(id)other { + if (self == other) { + return YES; + } + if (![other isKindOfClass:[GPBBoolEnumDictionary class]]) { + return NO; + } + GPBBoolEnumDictionary *otherDictionary = other; + if ((_valueSet[0] != otherDictionary->_valueSet[0]) || + (_valueSet[1] != otherDictionary->_valueSet[1])) { + return NO; + } + if ((_valueSet[0] && (_values[0] != otherDictionary->_values[0])) || + (_valueSet[1] && (_values[1] != otherDictionary->_values[1]))) { + return NO; + } + return YES; +} + +- (NSUInteger)hash { + return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0); +} + +- (NSString *)description { + NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> {", [self class], self]; + if (_valueSet[0]) { + [result appendFormat:@"NO: %d", _values[0]]; + } + if (_valueSet[1]) { + [result appendFormat:@"YES: %d", _values[1]]; + } + [result appendString:@" }"]; + return result; +} + +- (NSUInteger)count { + return (_valueSet[0] ? 1 : 0) + (_valueSet[1] ? 1 : 0); +} + +- (BOOL)getEnum:(int32_t*)value forKey:(BOOL)key { + int idx = (key ? 1 : 0); + if (_valueSet[idx]) { + if (value) { + int32_t result = _values[idx]; + if (!_validationFunc(result)) { + result = kGPBUnrecognizedEnumeratorValue; + } + *value = result; + } + return YES; + } + return NO; +} + +- (BOOL)getRawValue:(int32_t*)rawValue forKey:(BOOL)key { + int idx = (key ? 1 : 0); + if (_valueSet[idx]) { + if (rawValue) { + *rawValue = _values[idx]; + } + return YES; + } + return NO; +} + +- (void)enumerateKeysAndRawValuesUsingBlock: + (void (^)(BOOL key, int32_t value, BOOL *stop))block { + BOOL stop = NO; + if (_valueSet[0]) { + block(NO, _values[0], &stop); + } + if (!stop && _valueSet[1]) { + block(YES, _values[1], &stop); + } +} + +- (void)enumerateKeysAndEnumsUsingBlock: + (void (^)(BOOL key, int32_t rawValue, BOOL *stop))block { + BOOL stop = NO; + GPBEnumValidationFunc func = _validationFunc; + int32_t validatedValue; + if (_valueSet[0]) { + validatedValue = _values[0]; + if (!func(validatedValue)) { + validatedValue = kGPBUnrecognizedEnumeratorValue; + } + block(NO, validatedValue, &stop); + } + if (!stop && _valueSet[1]) { + validatedValue = _values[1]; + if (!func(validatedValue)) { + validatedValue = kGPBUnrecognizedEnumeratorValue; + } + block(YES, validatedValue, &stop); + } +} + +//%PDDM-EXPAND SERIAL_DATA_FOR_ENTRY_POD_Enum(Bool) +// This block of code is generated, do not edit it directly. + +- (NSData *)serializedDataForUnknownValue:(int32_t)value + forKey:(GPBGenericValue *)key + keyDataType:(GPBDataType)keyDataType { + size_t msgSize = ComputeDictBoolFieldSize(key->valueBool, kMapKeyFieldNumber, keyDataType); + msgSize += ComputeDictEnumFieldSize(value, kMapValueFieldNumber, GPBDataTypeEnum); + NSMutableData *data = [NSMutableData dataWithLength:msgSize]; + GPBCodedOutputStream *outputStream = [[GPBCodedOutputStream alloc] initWithData:data]; + WriteDictBoolField(outputStream, key->valueBool, kMapKeyFieldNumber, keyDataType); + WriteDictEnumField(outputStream, value, kMapValueFieldNumber, GPBDataTypeEnum); + [outputStream release]; + return data; +} + +//%PDDM-EXPAND-END SERIAL_DATA_FOR_ENTRY_POD_Enum(Bool) + +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + NSUInteger count = 0; + size_t result = 0; + for (int i = 0; i < 2; ++i) { + if (_valueSet[i]) { + ++count; + size_t msgSize = ComputeDictBoolFieldSize((i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + msgSize += ComputeDictInt32FieldSize(_values[i], kMapValueFieldNumber, valueDataType); + result += GPBComputeRawVarint32SizeForInteger(msgSize) + msgSize; + } + } + size_t tagSize = GPBComputeWireFormatTagSize(GPBFieldNumber(field), GPBDataTypeMessage); + result += tagSize * count; + return result; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field { + GPBDataType valueDataType = GPBGetFieldDataType(field); + uint32_t tag = GPBWireFormatMakeTag(GPBFieldNumber(field), GPBWireFormatLengthDelimited); + for (int i = 0; i < 2; ++i) { + if (_valueSet[i]) { + // Write the tag. + [outputStream writeInt32NoTag:tag]; + // Write the size of the message. + size_t msgSize = ComputeDictBoolFieldSize((i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + msgSize += ComputeDictInt32FieldSize(_values[i], kMapValueFieldNumber, valueDataType); + [outputStream writeInt32NoTag:(int32_t)msgSize]; + // Write the fields. + WriteDictBoolField(outputStream, (i == 1), kMapKeyFieldNumber, GPBDataTypeBool); + WriteDictInt32Field(outputStream, _values[i], kMapValueFieldNumber, valueDataType); + } + } +} + +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block { + if (_valueSet[0]) { + block(@"false", @(_values[0])); + } + if (_valueSet[1]) { + block(@"true", @(_values[1])); + } +} + +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key { + int idx = (key->valueBool ? 1 : 0); + _values[idx] = value->valueInt32; + _valueSet[idx] = YES; +} + +- (void)addRawEntriesFromDictionary:(GPBBoolEnumDictionary *)otherDictionary { + if (otherDictionary) { + for (int i = 0; i < 2; ++i) { + if (otherDictionary->_valueSet[i]) { + _valueSet[i] = YES; + _values[i] = otherDictionary->_values[i]; + } + } + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } + } +} + +- (void)setEnum:(int32_t)value forKey:(BOOL)key { + if (!_validationFunc(value)) { + [NSException raise:NSInvalidArgumentException + format:@"GPBBoolEnumDictionary: Attempt to set an unknown enum value (%d)", + value]; + } + int idx = (key ? 1 : 0); + _values[idx] = value; + _valueSet[idx] = YES; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)setRawValue:(int32_t)rawValue forKey:(BOOL)key { + int idx = (key ? 1 : 0); + _values[idx] = rawValue; + _valueSet[idx] = YES; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeEnumForKey:(BOOL)aKey { + _valueSet[aKey ? 1 : 0] = NO; +} + +- (void)removeAll { + _valueSet[0] = NO; + _valueSet[1] = NO; +} + +@end + +#pragma mark - NSDictionary Subclass + +@implementation GPBAutocreatedDictionary { + NSMutableDictionary *_dictionary; +} + +- (void)dealloc { + NSAssert(!_autocreator, + @"%@: Autocreator must be cleared before release, autocreator: %@", + [self class], _autocreator); + [_dictionary release]; + [super dealloc]; +} + +#pragma mark Required NSDictionary overrides + +- (instancetype)initWithObjects:(const id [])objects + forKeys:(const id [])keys + count:(NSUInteger)count { + self = [super init]; + if (self) { + _dictionary = [[NSMutableDictionary alloc] initWithObjects:objects + forKeys:keys + count:count]; + } + return self; +} + +- (NSUInteger)count { + return [_dictionary count]; +} + +- (id)objectForKey:(id)aKey { + return [_dictionary objectForKey:aKey]; +} + +- (NSEnumerator *)keyEnumerator { + if (_dictionary == nil) { + _dictionary = [[NSMutableDictionary alloc] init]; + } + return [_dictionary keyEnumerator]; +} + +#pragma mark Required NSMutableDictionary overrides + +// Only need to call GPBAutocreatedDictionaryModified() when adding things +// since we only autocreate empty dictionaries. + +- (void)setObject:(id)anObject forKey:(id)aKey { + if (_dictionary == nil) { + _dictionary = [[NSMutableDictionary alloc] init]; + } + [_dictionary setObject:anObject forKey:aKey]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)removeObjectForKey:(id)aKey { + [_dictionary removeObjectForKey:aKey]; +} + +#pragma mark Extra things hooked + +- (id)copyWithZone:(NSZone *)zone { + if (_dictionary == nil) { + return [[NSMutableDictionary allocWithZone:zone] init]; + } + return [_dictionary copyWithZone:zone]; +} + +- (id)mutableCopyWithZone:(NSZone *)zone { + if (_dictionary == nil) { + return [[NSMutableDictionary allocWithZone:zone] init]; + } + return [_dictionary mutableCopyWithZone:zone]; +} + +// Not really needed, but subscripting is likely common enough it doesn't hurt +// to ensure it goes directly to the real NSMutableDictionary. +- (id)objectForKeyedSubscript:(id)key { + return [_dictionary objectForKeyedSubscript:key]; +} + +// Not really needed, but subscripting is likely common enough it doesn't hurt +// to ensure it goes directly to the real NSMutableDictionary. +- (void)setObject:(id)obj forKeyedSubscript:(id)key { + if (_dictionary == nil) { + _dictionary = [[NSMutableDictionary alloc] init]; + } + [_dictionary setObject:obj forKeyedSubscript:key]; + if (_autocreator) { + GPBAutocreatedDictionaryModified(_autocreator, self); + } +} + +- (void)enumerateKeysAndObjectsUsingBlock:(void (^)(id key, + id obj, + BOOL *stop))block { + [_dictionary enumerateKeysAndObjectsUsingBlock:block]; +} + +- (void)enumerateKeysAndObjectsWithOptions:(NSEnumerationOptions)opts + usingBlock:(void (^)(id key, + id obj, + BOOL *stop))block { + [_dictionary enumerateKeysAndObjectsWithOptions:opts usingBlock:block]; +} + +@end + +#pragma clang diagnostic pop diff --git a/Pods/Protobuf/objectivec/GPBDictionary_PackagePrivate.h b/Pods/Protobuf/objectivec/GPBDictionary_PackagePrivate.h new file mode 100644 index 0000000..7b921e8 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBDictionary_PackagePrivate.h @@ -0,0 +1,488 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import + +#import "GPBDictionary.h" + +@class GPBCodedInputStream; +@class GPBCodedOutputStream; +@class GPBExtensionRegistry; +@class GPBFieldDescriptor; + +@protocol GPBDictionaryInternalsProtocol +- (size_t)computeSerializedSizeAsField:(GPBFieldDescriptor *)field; +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)outputStream + asField:(GPBFieldDescriptor *)field; +- (void)setGPBGenericValue:(GPBGenericValue *)value + forGPBGenericValueKey:(GPBGenericValue *)key; +- (void)enumerateForTextFormat:(void (^)(id keyObj, id valueObj))block; +@end + +//%PDDM-DEFINE DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(KEY_NAME) +//%DICTIONARY_POD_PRIV_INTERFACES_FOR_KEY(KEY_NAME) +//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, Object, Object) +//%PDDM-DEFINE DICTIONARY_POD_PRIV_INTERFACES_FOR_KEY(KEY_NAME) +//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, UInt32, Basic) +//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, Int32, Basic) +//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, UInt64, Basic) +//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, Int64, Basic) +//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, Bool, Basic) +//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, Float, Basic) +//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, Double, Basic) +//%DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, Enum, Enum) + +//%PDDM-DEFINE DICTIONARY_PRIVATE_INTERFACES(KEY_NAME, VALUE_NAME, HELPER) +//%@interface GPB##KEY_NAME##VALUE_NAME##Dictionary () { +//% @package +//% GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +//%} +//%EXTRA_DICTIONARY_PRIVATE_INTERFACES_##HELPER()@end +//% + +//%PDDM-DEFINE EXTRA_DICTIONARY_PRIVATE_INTERFACES_Basic() +// Empty +//%PDDM-DEFINE EXTRA_DICTIONARY_PRIVATE_INTERFACES_Object() +//%- (BOOL)isInitialized; +//%- (instancetype)deepCopyWithZone:(NSZone *)zone +//% __attribute__((ns_returns_retained)); +//% +//%PDDM-DEFINE EXTRA_DICTIONARY_PRIVATE_INTERFACES_Enum() +//%- (NSData *)serializedDataForUnknownValue:(int32_t)value +//% forKey:(GPBGenericValue *)key +//% keyDataType:(GPBDataType)keyDataType; +//% + +//%PDDM-EXPAND DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(UInt32) +// This block of code is generated, do not edit it directly. + +@interface GPBUInt32UInt32Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBUInt32Int32Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBUInt32UInt64Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBUInt32Int64Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBUInt32BoolDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBUInt32FloatDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBUInt32DoubleDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBUInt32EnumDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +- (NSData *)serializedDataForUnknownValue:(int32_t)value + forKey:(GPBGenericValue *)key + keyDataType:(GPBDataType)keyDataType; +@end + +@interface GPBUInt32ObjectDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +- (BOOL)isInitialized; +- (instancetype)deepCopyWithZone:(NSZone *)zone + __attribute__((ns_returns_retained)); +@end + +//%PDDM-EXPAND DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(Int32) +// This block of code is generated, do not edit it directly. + +@interface GPBInt32UInt32Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBInt32Int32Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBInt32UInt64Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBInt32Int64Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBInt32BoolDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBInt32FloatDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBInt32DoubleDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBInt32EnumDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +- (NSData *)serializedDataForUnknownValue:(int32_t)value + forKey:(GPBGenericValue *)key + keyDataType:(GPBDataType)keyDataType; +@end + +@interface GPBInt32ObjectDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +- (BOOL)isInitialized; +- (instancetype)deepCopyWithZone:(NSZone *)zone + __attribute__((ns_returns_retained)); +@end + +//%PDDM-EXPAND DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(UInt64) +// This block of code is generated, do not edit it directly. + +@interface GPBUInt64UInt32Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBUInt64Int32Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBUInt64UInt64Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBUInt64Int64Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBUInt64BoolDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBUInt64FloatDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBUInt64DoubleDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBUInt64EnumDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +- (NSData *)serializedDataForUnknownValue:(int32_t)value + forKey:(GPBGenericValue *)key + keyDataType:(GPBDataType)keyDataType; +@end + +@interface GPBUInt64ObjectDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +- (BOOL)isInitialized; +- (instancetype)deepCopyWithZone:(NSZone *)zone + __attribute__((ns_returns_retained)); +@end + +//%PDDM-EXPAND DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(Int64) +// This block of code is generated, do not edit it directly. + +@interface GPBInt64UInt32Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBInt64Int32Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBInt64UInt64Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBInt64Int64Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBInt64BoolDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBInt64FloatDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBInt64DoubleDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBInt64EnumDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +- (NSData *)serializedDataForUnknownValue:(int32_t)value + forKey:(GPBGenericValue *)key + keyDataType:(GPBDataType)keyDataType; +@end + +@interface GPBInt64ObjectDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +- (BOOL)isInitialized; +- (instancetype)deepCopyWithZone:(NSZone *)zone + __attribute__((ns_returns_retained)); +@end + +//%PDDM-EXPAND DICTIONARY_PRIV_INTERFACES_FOR_POD_KEY(Bool) +// This block of code is generated, do not edit it directly. + +@interface GPBBoolUInt32Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBBoolInt32Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBBoolUInt64Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBBoolInt64Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBBoolBoolDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBBoolFloatDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBBoolDoubleDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBBoolEnumDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +- (NSData *)serializedDataForUnknownValue:(int32_t)value + forKey:(GPBGenericValue *)key + keyDataType:(GPBDataType)keyDataType; +@end + +@interface GPBBoolObjectDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +- (BOOL)isInitialized; +- (instancetype)deepCopyWithZone:(NSZone *)zone + __attribute__((ns_returns_retained)); +@end + +//%PDDM-EXPAND DICTIONARY_POD_PRIV_INTERFACES_FOR_KEY(String) +// This block of code is generated, do not edit it directly. + +@interface GPBStringUInt32Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBStringInt32Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBStringUInt64Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBStringInt64Dictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBStringBoolDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBStringFloatDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBStringDoubleDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +@interface GPBStringEnumDictionary () { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +- (NSData *)serializedDataForUnknownValue:(int32_t)value + forKey:(GPBGenericValue *)key + keyDataType:(GPBDataType)keyDataType; +@end + +//%PDDM-EXPAND-END (6 expansions) + +#pragma mark - NSDictionary Subclass + +@interface GPBAutocreatedDictionary : NSMutableDictionary { + @package + GPB_UNSAFE_UNRETAINED GPBMessage *_autocreator; +} +@end + +#pragma mark - Helpers + +CF_EXTERN_C_BEGIN + +// Helper to compute size when an NSDictionary is used for the map instead +// of a custom type. +size_t GPBDictionaryComputeSizeInternalHelper(NSDictionary *dict, + GPBFieldDescriptor *field); + +// Helper to write out when an NSDictionary is used for the map instead +// of a custom type. +void GPBDictionaryWriteToStreamInternalHelper( + GPBCodedOutputStream *outputStream, NSDictionary *dict, + GPBFieldDescriptor *field); + +// Helper to check message initialization when an NSDictionary is used for +// the map instead of a custom type. +BOOL GPBDictionaryIsInitializedInternalHelper(NSDictionary *dict, + GPBFieldDescriptor *field); + +// Helper to read a map instead. +void GPBDictionaryReadEntry(id mapDictionary, GPBCodedInputStream *stream, + GPBExtensionRegistry *registry, + GPBFieldDescriptor *field, + GPBMessage *parentMessage); + +CF_EXTERN_C_END diff --git a/Pods/Protobuf/objectivec/GPBExtensionInternals.h b/Pods/Protobuf/objectivec/GPBExtensionInternals.h new file mode 100644 index 0000000..2b980ae --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBExtensionInternals.h @@ -0,0 +1,50 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import + +#import "GPBDescriptor.h" + +@class GPBCodedInputStream; +@class GPBCodedOutputStream; +@class GPBExtensionRegistry; + +void GPBExtensionMergeFromInputStream(GPBExtensionDescriptor *extension, + BOOL isPackedOnStream, + GPBCodedInputStream *input, + GPBExtensionRegistry *extensionRegistry, + GPBMessage *message); + +size_t GPBComputeExtensionSerializedSizeIncludingTag( + GPBExtensionDescriptor *extension, id value); + +void GPBWriteExtensionValueToOutputStream(GPBExtensionDescriptor *extension, + id value, + GPBCodedOutputStream *output); diff --git a/Pods/Protobuf/objectivec/GPBExtensionInternals.m b/Pods/Protobuf/objectivec/GPBExtensionInternals.m new file mode 100644 index 0000000..290c82a --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBExtensionInternals.m @@ -0,0 +1,391 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import "GPBExtensionInternals.h" + +#import + +#import "GPBCodedInputStream_PackagePrivate.h" +#import "GPBCodedOutputStream_PackagePrivate.h" +#import "GPBDescriptor_PackagePrivate.h" +#import "GPBMessage_PackagePrivate.h" +#import "GPBUtilities_PackagePrivate.h" + +static id NewSingleValueFromInputStream(GPBExtensionDescriptor *extension, + GPBCodedInputStream *input, + GPBExtensionRegistry *extensionRegistry, + GPBMessage *existingValue) + __attribute__((ns_returns_retained)); + +GPB_INLINE size_t DataTypeSize(GPBDataType dataType) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wswitch-enum" + switch (dataType) { + case GPBDataTypeBool: + return 1; + case GPBDataTypeFixed32: + case GPBDataTypeSFixed32: + case GPBDataTypeFloat: + return 4; + case GPBDataTypeFixed64: + case GPBDataTypeSFixed64: + case GPBDataTypeDouble: + return 8; + default: + return 0; + } +#pragma clang diagnostic pop +} + +static size_t ComputePBSerializedSizeNoTagOfObject(GPBDataType dataType, id object) { +#define FIELD_CASE(TYPE, ACCESSOR) \ + case GPBDataType##TYPE: \ + return GPBCompute##TYPE##SizeNoTag([(NSNumber *)object ACCESSOR]); +#define FIELD_CASE2(TYPE) \ + case GPBDataType##TYPE: \ + return GPBCompute##TYPE##SizeNoTag(object); + switch (dataType) { + FIELD_CASE(Bool, boolValue) + FIELD_CASE(Float, floatValue) + FIELD_CASE(Double, doubleValue) + FIELD_CASE(Int32, intValue) + FIELD_CASE(SFixed32, intValue) + FIELD_CASE(SInt32, intValue) + FIELD_CASE(Enum, intValue) + FIELD_CASE(Int64, longLongValue) + FIELD_CASE(SInt64, longLongValue) + FIELD_CASE(SFixed64, longLongValue) + FIELD_CASE(UInt32, unsignedIntValue) + FIELD_CASE(Fixed32, unsignedIntValue) + FIELD_CASE(UInt64, unsignedLongLongValue) + FIELD_CASE(Fixed64, unsignedLongLongValue) + FIELD_CASE2(Bytes) + FIELD_CASE2(String) + FIELD_CASE2(Message) + FIELD_CASE2(Group) + } +#undef FIELD_CASE +#undef FIELD_CASE2 +} + +static size_t ComputeSerializedSizeIncludingTagOfObject( + GPBExtensionDescription *description, id object) { +#define FIELD_CASE(TYPE, ACCESSOR) \ + case GPBDataType##TYPE: \ + return GPBCompute##TYPE##Size(description->fieldNumber, \ + [(NSNumber *)object ACCESSOR]); +#define FIELD_CASE2(TYPE) \ + case GPBDataType##TYPE: \ + return GPBCompute##TYPE##Size(description->fieldNumber, object); + switch (description->dataType) { + FIELD_CASE(Bool, boolValue) + FIELD_CASE(Float, floatValue) + FIELD_CASE(Double, doubleValue) + FIELD_CASE(Int32, intValue) + FIELD_CASE(SFixed32, intValue) + FIELD_CASE(SInt32, intValue) + FIELD_CASE(Enum, intValue) + FIELD_CASE(Int64, longLongValue) + FIELD_CASE(SInt64, longLongValue) + FIELD_CASE(SFixed64, longLongValue) + FIELD_CASE(UInt32, unsignedIntValue) + FIELD_CASE(Fixed32, unsignedIntValue) + FIELD_CASE(UInt64, unsignedLongLongValue) + FIELD_CASE(Fixed64, unsignedLongLongValue) + FIELD_CASE2(Bytes) + FIELD_CASE2(String) + FIELD_CASE2(Group) + case GPBDataTypeMessage: + if (GPBExtensionIsWireFormat(description)) { + return GPBComputeMessageSetExtensionSize(description->fieldNumber, + object); + } else { + return GPBComputeMessageSize(description->fieldNumber, object); + } + } +#undef FIELD_CASE +#undef FIELD_CASE2 +} + +static size_t ComputeSerializedSizeIncludingTagOfArray( + GPBExtensionDescription *description, NSArray *values) { + if (GPBExtensionIsPacked(description)) { + size_t size = 0; + size_t typeSize = DataTypeSize(description->dataType); + if (typeSize != 0) { + size = values.count * typeSize; + } else { + for (id value in values) { + size += + ComputePBSerializedSizeNoTagOfObject(description->dataType, value); + } + } + return size + GPBComputeTagSize(description->fieldNumber) + + GPBComputeRawVarint32SizeForInteger(size); + } else { + size_t size = 0; + for (id value in values) { + size += ComputeSerializedSizeIncludingTagOfObject(description, value); + } + return size; + } +} + +static void WriteObjectIncludingTagToCodedOutputStream( + id object, GPBExtensionDescription *description, + GPBCodedOutputStream *output) { +#define FIELD_CASE(TYPE, ACCESSOR) \ + case GPBDataType##TYPE: \ + [output write##TYPE:description->fieldNumber \ + value:[(NSNumber *)object ACCESSOR]]; \ + return; +#define FIELD_CASE2(TYPE) \ + case GPBDataType##TYPE: \ + [output write##TYPE:description->fieldNumber value:object]; \ + return; + switch (description->dataType) { + FIELD_CASE(Bool, boolValue) + FIELD_CASE(Float, floatValue) + FIELD_CASE(Double, doubleValue) + FIELD_CASE(Int32, intValue) + FIELD_CASE(SFixed32, intValue) + FIELD_CASE(SInt32, intValue) + FIELD_CASE(Enum, intValue) + FIELD_CASE(Int64, longLongValue) + FIELD_CASE(SInt64, longLongValue) + FIELD_CASE(SFixed64, longLongValue) + FIELD_CASE(UInt32, unsignedIntValue) + FIELD_CASE(Fixed32, unsignedIntValue) + FIELD_CASE(UInt64, unsignedLongLongValue) + FIELD_CASE(Fixed64, unsignedLongLongValue) + FIELD_CASE2(Bytes) + FIELD_CASE2(String) + FIELD_CASE2(Group) + case GPBDataTypeMessage: + if (GPBExtensionIsWireFormat(description)) { + [output writeMessageSetExtension:description->fieldNumber value:object]; + } else { + [output writeMessage:description->fieldNumber value:object]; + } + return; + } +#undef FIELD_CASE +#undef FIELD_CASE2 +} + +static void WriteObjectNoTagToCodedOutputStream( + id object, GPBExtensionDescription *description, + GPBCodedOutputStream *output) { +#define FIELD_CASE(TYPE, ACCESSOR) \ + case GPBDataType##TYPE: \ + [output write##TYPE##NoTag:[(NSNumber *)object ACCESSOR]]; \ + return; +#define FIELD_CASE2(TYPE) \ + case GPBDataType##TYPE: \ + [output write##TYPE##NoTag:object]; \ + return; + switch (description->dataType) { + FIELD_CASE(Bool, boolValue) + FIELD_CASE(Float, floatValue) + FIELD_CASE(Double, doubleValue) + FIELD_CASE(Int32, intValue) + FIELD_CASE(SFixed32, intValue) + FIELD_CASE(SInt32, intValue) + FIELD_CASE(Enum, intValue) + FIELD_CASE(Int64, longLongValue) + FIELD_CASE(SInt64, longLongValue) + FIELD_CASE(SFixed64, longLongValue) + FIELD_CASE(UInt32, unsignedIntValue) + FIELD_CASE(Fixed32, unsignedIntValue) + FIELD_CASE(UInt64, unsignedLongLongValue) + FIELD_CASE(Fixed64, unsignedLongLongValue) + FIELD_CASE2(Bytes) + FIELD_CASE2(String) + FIELD_CASE2(Message) + case GPBDataTypeGroup: + [output writeGroupNoTag:description->fieldNumber value:object]; + return; + } +#undef FIELD_CASE +#undef FIELD_CASE2 +} + +static void WriteArrayIncludingTagsToCodedOutputStream( + NSArray *values, GPBExtensionDescription *description, + GPBCodedOutputStream *output) { + if (GPBExtensionIsPacked(description)) { + [output writeTag:description->fieldNumber + format:GPBWireFormatLengthDelimited]; + size_t dataSize = 0; + size_t typeSize = DataTypeSize(description->dataType); + if (typeSize != 0) { + dataSize = values.count * typeSize; + } else { + for (id value in values) { + dataSize += + ComputePBSerializedSizeNoTagOfObject(description->dataType, value); + } + } + [output writeRawVarintSizeTAs32:dataSize]; + for (id value in values) { + WriteObjectNoTagToCodedOutputStream(value, description, output); + } + } else { + for (id value in values) { + WriteObjectIncludingTagToCodedOutputStream(value, description, output); + } + } +} + +// Direct access is use for speed, to avoid even internally declaring things +// read/write, etc. The warning is enabled in the project to ensure code calling +// protos can turn on -Wdirect-ivar-access without issues. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdirect-ivar-access" + +void GPBExtensionMergeFromInputStream(GPBExtensionDescriptor *extension, + BOOL isPackedOnStream, + GPBCodedInputStream *input, + GPBExtensionRegistry *extensionRegistry, + GPBMessage *message) { + GPBExtensionDescription *description = extension->description_; + GPBCodedInputStreamState *state = &input->state_; + if (isPackedOnStream) { + NSCAssert(GPBExtensionIsRepeated(description), + @"How was it packed if it isn't repeated?"); + int32_t length = GPBCodedInputStreamReadInt32(state); + size_t limit = GPBCodedInputStreamPushLimit(state, length); + while (GPBCodedInputStreamBytesUntilLimit(state) > 0) { + id value = NewSingleValueFromInputStream(extension, + input, + extensionRegistry, + nil); + [message addExtension:extension value:value]; + [value release]; + } + GPBCodedInputStreamPopLimit(state, limit); + } else { + id existingValue = nil; + BOOL isRepeated = GPBExtensionIsRepeated(description); + if (!isRepeated && GPBDataTypeIsMessage(description->dataType)) { + existingValue = [message getExistingExtension:extension]; + } + id value = NewSingleValueFromInputStream(extension, + input, + extensionRegistry, + existingValue); + if (isRepeated) { + [message addExtension:extension value:value]; + } else { + [message setExtension:extension value:value]; + } + [value release]; + } +} + +void GPBWriteExtensionValueToOutputStream(GPBExtensionDescriptor *extension, + id value, + GPBCodedOutputStream *output) { + GPBExtensionDescription *description = extension->description_; + if (GPBExtensionIsRepeated(description)) { + WriteArrayIncludingTagsToCodedOutputStream(value, description, output); + } else { + WriteObjectIncludingTagToCodedOutputStream(value, description, output); + } +} + +size_t GPBComputeExtensionSerializedSizeIncludingTag( + GPBExtensionDescriptor *extension, id value) { + GPBExtensionDescription *description = extension->description_; + if (GPBExtensionIsRepeated(description)) { + return ComputeSerializedSizeIncludingTagOfArray(description, value); + } else { + return ComputeSerializedSizeIncludingTagOfObject(description, value); + } +} + +// Note that this returns a retained value intentionally. +static id NewSingleValueFromInputStream(GPBExtensionDescriptor *extension, + GPBCodedInputStream *input, + GPBExtensionRegistry *extensionRegistry, + GPBMessage *existingValue) { + GPBExtensionDescription *description = extension->description_; + GPBCodedInputStreamState *state = &input->state_; + switch (description->dataType) { + case GPBDataTypeBool: return [[NSNumber alloc] initWithBool:GPBCodedInputStreamReadBool(state)]; + case GPBDataTypeFixed32: return [[NSNumber alloc] initWithUnsignedInt:GPBCodedInputStreamReadFixed32(state)]; + case GPBDataTypeSFixed32: return [[NSNumber alloc] initWithInt:GPBCodedInputStreamReadSFixed32(state)]; + case GPBDataTypeFloat: return [[NSNumber alloc] initWithFloat:GPBCodedInputStreamReadFloat(state)]; + case GPBDataTypeFixed64: return [[NSNumber alloc] initWithUnsignedLongLong:GPBCodedInputStreamReadFixed64(state)]; + case GPBDataTypeSFixed64: return [[NSNumber alloc] initWithLongLong:GPBCodedInputStreamReadSFixed64(state)]; + case GPBDataTypeDouble: return [[NSNumber alloc] initWithDouble:GPBCodedInputStreamReadDouble(state)]; + case GPBDataTypeInt32: return [[NSNumber alloc] initWithInt:GPBCodedInputStreamReadInt32(state)]; + case GPBDataTypeInt64: return [[NSNumber alloc] initWithLongLong:GPBCodedInputStreamReadInt64(state)]; + case GPBDataTypeSInt32: return [[NSNumber alloc] initWithInt:GPBCodedInputStreamReadSInt32(state)]; + case GPBDataTypeSInt64: return [[NSNumber alloc] initWithLongLong:GPBCodedInputStreamReadSInt64(state)]; + case GPBDataTypeUInt32: return [[NSNumber alloc] initWithUnsignedInt:GPBCodedInputStreamReadUInt32(state)]; + case GPBDataTypeUInt64: return [[NSNumber alloc] initWithUnsignedLongLong:GPBCodedInputStreamReadUInt64(state)]; + case GPBDataTypeBytes: return GPBCodedInputStreamReadRetainedBytes(state); + case GPBDataTypeString: return GPBCodedInputStreamReadRetainedString(state); + case GPBDataTypeEnum: return [[NSNumber alloc] initWithInt:GPBCodedInputStreamReadEnum(state)]; + case GPBDataTypeGroup: + case GPBDataTypeMessage: { + GPBMessage *message; + if (existingValue) { + message = [existingValue retain]; + } else { + GPBDescriptor *decriptor = [extension.msgClass descriptor]; + message = [[decriptor.messageClass alloc] init]; + } + + if (description->dataType == GPBDataTypeGroup) { + [input readGroup:description->fieldNumber + message:message + extensionRegistry:extensionRegistry]; + } else { + // description->dataType == GPBDataTypeMessage + if (GPBExtensionIsWireFormat(description)) { + // For MessageSet fields the message length will have already been + // read. + [message mergeFromCodedInputStream:input + extensionRegistry:extensionRegistry]; + } else { + [input readMessage:message extensionRegistry:extensionRegistry]; + } + } + + return message; + } + } + + return nil; +} + +#pragma clang diagnostic pop diff --git a/Pods/Protobuf/objectivec/GPBExtensionRegistry.h b/Pods/Protobuf/objectivec/GPBExtensionRegistry.h new file mode 100644 index 0000000..d79632d --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBExtensionRegistry.h @@ -0,0 +1,87 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import + +@class GPBDescriptor; +@class GPBExtensionDescriptor; + +NS_ASSUME_NONNULL_BEGIN + +/** + * A table of known extensions, searchable by name or field number. When + * parsing a protocol message that might have extensions, you must provide a + * GPBExtensionRegistry in which you have registered any extensions that you + * want to be able to parse. Otherwise, those extensions will just be treated + * like unknown fields. + * + * The *Root classes provide `+extensionRegistry` for the extensions defined + * in a given file *and* all files it imports. You can also create a + * GPBExtensionRegistry, and merge those registries to handle parsing + * extensions defined from non overlapping files. + * + * ``` + * GPBExtensionRegistry *registry = [[MyProtoFileRoot extensionRegistry] copy]; + * [registry addExtension:[OtherMessage neededExtension]]; // Not in MyProtoFile + * NSError *parseError; + * MyMessage *msg = [MyMessage parseData:data extensionRegistry:registry error:&parseError]; + * ``` + **/ +@interface GPBExtensionRegistry : NSObject + +/** + * Adds the given GPBExtensionDescriptor to this registry. + * + * @param extension The extension description to add. + **/ +- (void)addExtension:(GPBExtensionDescriptor *)extension; + +/** + * Adds all the extensions from another registry to this registry. + * + * @param registry The registry to merge into this registry. + **/ +- (void)addExtensions:(GPBExtensionRegistry *)registry; + +/** + * Looks for the extension registered for the given field number on a given + * GPBDescriptor. + * + * @param descriptor The descriptor to look for a registered extension on. + * @param fieldNumber The field number of the extension to look for. + * + * @return The registered GPBExtensionDescriptor or nil if none was found. + **/ +- (nullable GPBExtensionDescriptor *)extensionForDescriptor:(GPBDescriptor *)descriptor + fieldNumber:(NSInteger)fieldNumber; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Pods/Protobuf/objectivec/GPBExtensionRegistry.m b/Pods/Protobuf/objectivec/GPBExtensionRegistry.m new file mode 100644 index 0000000..b056a52 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBExtensionRegistry.m @@ -0,0 +1,130 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import "GPBExtensionRegistry.h" + +#import "GPBBootstrap.h" +#import "GPBDescriptor.h" + +@implementation GPBExtensionRegistry { + NSMutableDictionary *mutableClassMap_; +} + +- (instancetype)init { + if ((self = [super init])) { + mutableClassMap_ = [[NSMutableDictionary alloc] init]; + } + return self; +} + +- (void)dealloc { + [mutableClassMap_ release]; + [super dealloc]; +} + +// Direct access is use for speed, to avoid even internally declaring things +// read/write, etc. The warning is enabled in the project to ensure code calling +// protos can turn on -Wdirect-ivar-access without issues. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdirect-ivar-access" + +- (instancetype)copyWithZone:(NSZone *)zone { + GPBExtensionRegistry *result = [[[self class] allocWithZone:zone] init]; + [result addExtensions:self]; + return result; +} + +- (void)addExtension:(GPBExtensionDescriptor *)extension { + if (extension == nil) { + return; + } + + Class containingMessageClass = extension.containingMessageClass; + CFMutableDictionaryRef extensionMap = (CFMutableDictionaryRef) + [mutableClassMap_ objectForKey:containingMessageClass]; + if (extensionMap == nil) { + // Use a custom dictionary here because the keys are numbers and conversion + // back and forth from NSNumber isn't worth the cost. + extensionMap = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL, + &kCFTypeDictionaryValueCallBacks); + [mutableClassMap_ setObject:(id)extensionMap + forKey:(id)containingMessageClass]; + CFRelease(extensionMap); + } + + ssize_t key = extension.fieldNumber; + CFDictionarySetValue(extensionMap, (const void *)key, extension); +} + +- (GPBExtensionDescriptor *)extensionForDescriptor:(GPBDescriptor *)descriptor + fieldNumber:(NSInteger)fieldNumber { + Class messageClass = descriptor.messageClass; + CFMutableDictionaryRef extensionMap = (CFMutableDictionaryRef) + [mutableClassMap_ objectForKey:messageClass]; + ssize_t key = fieldNumber; + GPBExtensionDescriptor *result = + (extensionMap + ? CFDictionaryGetValue(extensionMap, (const void *)key) + : nil); + return result; +} + +static void CopyKeyValue(const void *key, const void *value, void *context) { + CFMutableDictionaryRef extensionMap = (CFMutableDictionaryRef)context; + CFDictionarySetValue(extensionMap, key, value); +} + +- (void)addExtensions:(GPBExtensionRegistry *)registry { + if (registry == nil) { + // In the case where there are no extensions just ignore. + return; + } + NSMutableDictionary *otherClassMap = registry->mutableClassMap_; + [otherClassMap enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL * stop) { +#pragma unused(stop) + Class containingMessageClass = key; + CFMutableDictionaryRef otherExtensionMap = (CFMutableDictionaryRef)value; + + CFMutableDictionaryRef extensionMap = (CFMutableDictionaryRef) + [mutableClassMap_ objectForKey:containingMessageClass]; + if (extensionMap == nil) { + extensionMap = CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, otherExtensionMap); + [mutableClassMap_ setObject:(id)extensionMap + forKey:(id)containingMessageClass]; + CFRelease(extensionMap); + } else { + CFDictionaryApplyFunction(otherExtensionMap, CopyKeyValue, extensionMap); + } + }]; +} + +#pragma clang diagnostic pop + +@end diff --git a/Pods/Protobuf/objectivec/GPBMessage.h b/Pods/Protobuf/objectivec/GPBMessage.h new file mode 100644 index 0000000..276740d --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBMessage.h @@ -0,0 +1,470 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import + +#import "GPBBootstrap.h" + +@class GPBDescriptor; +@class GPBCodedInputStream; +@class GPBCodedOutputStream; +@class GPBExtensionDescriptor; +@class GPBExtensionRegistry; +@class GPBFieldDescriptor; +@class GPBUnknownFieldSet; + +NS_ASSUME_NONNULL_BEGIN + +CF_EXTERN_C_BEGIN + +/** NSError domain used for errors. */ +extern NSString *const GPBMessageErrorDomain; + +/** Error codes for NSErrors originated in GPBMessage. */ +typedef NS_ENUM(NSInteger, GPBMessageErrorCode) { + /** Uncategorized error. */ + GPBMessageErrorCodeOther = -100, + /** Message couldn't be serialized because it is missing required fields. */ + GPBMessageErrorCodeMissingRequiredField = -101, +}; + +/** + * Key under which the GPBMessage error's reason is stored inside the userInfo + * dictionary. + **/ +extern NSString *const GPBErrorReasonKey; + +CF_EXTERN_C_END + +/** + * Base class that each generated message subclasses from. + * + * @note @c NSCopying support is a "deep copy", in that all sub objects are + * copied. Just like you wouldn't want a UIView/NSView trying to + * exist in two places, you don't want a sub message to be a property + * property of two other messages. + * + * @note While the class support NSSecureCoding, if the message has any + * extensions, they will end up reloaded in @c unknownFields as there is + * no way for the @c NSCoding plumbing to pass through a + * @c GPBExtensionRegistry. To support extensions, instead of passing the + * calls off to the Message, simple store the result of @c data, and then + * when loading, fetch the data and use + * @c +parseFromData:extensionRegistry:error: to provide an extension + * registry. + **/ +@interface GPBMessage : NSObject + +// If you add an instance method/property to this class that may conflict with +// fields declared in protos, you need to update objective_helpers.cc. The main +// cases are methods that take no arguments, or setFoo:/hasFoo: type methods. + +/** + * The set of unknown fields for this message. + * + * Only messages from proto files declared with "proto2" syntax support unknown + * fields. For "proto3" syntax, any unknown fields found while parsing are + * dropped. + **/ +@property(nonatomic, copy, nullable) GPBUnknownFieldSet *unknownFields; + +/** + * Whether the message, along with all submessages, have the required fields + * set. This is only applicable for files declared with "proto2" syntax, as + * there are no required fields for "proto3" syntax. + **/ +@property(nonatomic, readonly, getter=isInitialized) BOOL initialized; + +/** + * @return An autoreleased message with the default values set. + **/ ++ (instancetype)message; + +/** + * Creates a new instance by parsing the provided data. This method should be + * sent to the generated message class that the data should be interpreted as. + * If there is an error the method returns nil and the error is returned in + * errorPtr (when provided). + * + * @note In DEBUG builds, the parsed message is checked to be sure all required + * fields were provided, and the parse will fail if some are missing. + * + * @note The errors returned are likely coming from the domain and codes listed + * at the top of this file and GPBCodedInputStream.h. + * + * @param data The data to parse. + * @param errorPtr An optional error pointer to fill in with a failure reason if + * the data can not be parsed. + * + * @return A new instance of the generated class. + **/ ++ (nullable instancetype)parseFromData:(NSData *)data error:(NSError **)errorPtr; + +/** + * Creates a new instance by parsing the data. This method should be sent to + * the generated message class that the data should be interpreted as. If + * there is an error the method returns nil and the error is returned in + * errorPtr (when provided). + * + * @note In DEBUG builds, the parsed message is checked to be sure all required + * fields were provided, and the parse will fail if some are missing. + * + * @note The errors returned are likely coming from the domain and codes listed + * at the top of this file and GPBCodedInputStream.h. + * + * @param data The data to parse. + * @param extensionRegistry The extension registry to use to look up extensions. + * @param errorPtr An optional error pointer to fill in with a failure + * reason if the data can not be parsed. + * + * @return A new instance of the generated class. + **/ ++ (nullable instancetype)parseFromData:(NSData *)data + extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry + error:(NSError **)errorPtr; + +/** + * Creates a new instance by parsing the data from the given input stream. This + * method should be sent to the generated message class that the data should + * be interpreted as. If there is an error the method returns nil and the error + * is returned in errorPtr (when provided). + * + * @note In DEBUG builds, the parsed message is checked to be sure all required + * fields were provided, and the parse will fail if some are missing. + * + * @note The errors returned are likely coming from the domain and codes listed + * at the top of this file and GPBCodedInputStream.h. + * + * @param input The stream to read data from. + * @param extensionRegistry The extension registry to use to look up extensions. + * @param errorPtr An optional error pointer to fill in with a failure + * reason if the data can not be parsed. + * + * @return A new instance of the generated class. + **/ ++ (nullable instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input + extensionRegistry: + (nullable GPBExtensionRegistry *)extensionRegistry + error:(NSError **)errorPtr; + +/** + * Creates a new instance by parsing the data from the given input stream. This + * method should be sent to the generated message class that the data should + * be interpreted as. If there is an error the method returns nil and the error + * is returned in errorPtr (when provided). + * + * @note Unlike the parseFrom... methods, this never checks to see if all of + * the required fields are set. So this method can be used to reload + * messages that may not be complete. + * + * @note The errors returned are likely coming from the domain and codes listed + * at the top of this file and GPBCodedInputStream.h. + * + * @param input The stream to read data from. + * @param extensionRegistry The extension registry to use to look up extensions. + * @param errorPtr An optional error pointer to fill in with a failure + * reason if the data can not be parsed. + * + * @return A new instance of the generated class. + **/ ++ (nullable instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input + extensionRegistry: + (nullable GPBExtensionRegistry *)extensionRegistry + error:(NSError **)errorPtr; + +/** + * Initializes an instance by parsing the data. This method should be sent to + * the generated message class that the data should be interpreted as. If + * there is an error the method returns nil and the error is returned in + * errorPtr (when provided). + * + * @note In DEBUG builds, the parsed message is checked to be sure all required + * fields were provided, and the parse will fail if some are missing. + * + * @note The errors returned are likely coming from the domain and codes listed + * at the top of this file and GPBCodedInputStream.h. + * + * @param data The data to parse. + * @param errorPtr An optional error pointer to fill in with a failure reason if + * the data can not be parsed. + * + * @return An initialized instance of the generated class. + **/ +- (nullable instancetype)initWithData:(NSData *)data error:(NSError **)errorPtr; + +/** + * Initializes an instance by parsing the data. This method should be sent to + * the generated message class that the data should be interpreted as. If + * there is an error the method returns nil and the error is returned in + * errorPtr (when provided). + * + * @note In DEBUG builds, the parsed message is checked to be sure all required + * fields were provided, and the parse will fail if some are missing. + * + * @note The errors returned are likely coming from the domain and codes listed + * at the top of this file and GPBCodedInputStream.h. + * + * @param data The data to parse. + * @param extensionRegistry The extension registry to use to look up extensions. + * @param errorPtr An optional error pointer to fill in with a failure + * reason if the data can not be parsed. + * + * @return An initialized instance of the generated class. + **/ +- (nullable instancetype)initWithData:(NSData *)data + extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry + error:(NSError **)errorPtr; + +/** + * Initializes an instance by parsing the data from the given input stream. This + * method should be sent to the generated message class that the data should + * be interpreted as. If there is an error the method returns nil and the error + * is returned in errorPtr (when provided). + * + * @note Unlike the parseFrom... methods, this never checks to see if all of + * the required fields are set. So this method can be used to reload + * messages that may not be complete. + * + * @note The errors returned are likely coming from the domain and codes listed + * at the top of this file and GPBCodedInputStream.h. + * + * @param input The stream to read data from. + * @param extensionRegistry The extension registry to use to look up extensions. + * @param errorPtr An optional error pointer to fill in with a failure + * reason if the data can not be parsed. + * + * @return An initialized instance of the generated class. + **/ +- (nullable instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input + extensionRegistry: + (nullable GPBExtensionRegistry *)extensionRegistry + error:(NSError **)errorPtr; + +/** + * Parses the given data as this message's class, and merges those values into + * this message. + * + * @param data The binary representation of the message to merge. + * @param extensionRegistry The extension registry to use to look up extensions. + * + * @exception GPBCodedInputStreamException Exception thrown when parsing was + * unsuccessful. + **/ +- (void)mergeFromData:(NSData *)data + extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry; + +/** + * Merges the fields from another message (of the same type) into this + * message. + * + * @param other Message to merge into this message. + **/ +- (void)mergeFrom:(GPBMessage *)other; + +/** + * Writes out the message to the given coded output stream. + * + * @param output The coded output stream into which to write the message. + * + * @note This can raise the GPBCodedOutputStreamException_* exceptions. + * + **/ +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)output; + +/** + * Writes out the message to the given output stream. + * + * @param output The output stream into which to write the message. + * + * @note This can raise the GPBCodedOutputStreamException_* exceptions. + **/ +- (void)writeToOutputStream:(NSOutputStream *)output; + +/** + * Writes out a varint for the message size followed by the the message to + * the given output stream. + * + * @param output The coded output stream into which to write the message. + * + * @note This can raise the GPBCodedOutputStreamException_* exceptions. + **/ +- (void)writeDelimitedToCodedOutputStream:(GPBCodedOutputStream *)output; + +/** + * Writes out a varint for the message size followed by the the message to + * the given output stream. + * + * @param output The output stream into which to write the message. + * + * @note This can raise the GPBCodedOutputStreamException_* exceptions. + **/ +- (void)writeDelimitedToOutputStream:(NSOutputStream *)output; + +/** + * Serializes the message to an NSData. + * + * If there is an error while generating the data, nil is returned. + * + * @note This value is not cached, so if you are using it repeatedly, cache + * it yourself. + * + * @note In DEBUG ONLY, the message is also checked for all required field, + * if one is missing, nil will be returned. + * + * @return The binary representation of the message. + **/ +- (nullable NSData *)data; + +/** + * Serializes a varint with the message size followed by the message data, + * returning that as an NSData. + * + * @note This value is not cached, so if you are using it repeatedly, it is + * recommended to keep a local copy. + * + * @return The binary representation of the size along with the message. + **/ +- (NSData *)delimitedData; + +/** + * Calculates the size of the object if it were serialized. + * + * This is not a cached value. If you are following a pattern like this: + * + * ``` + * size_t size = [aMsg serializedSize]; + * NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)]; + * [foo writeSize:size]; + * [foo appendData:[aMsg data]]; + * ``` + * + * you would be better doing: + * + * ``` + * NSData *data = [aMsg data]; + * NSUInteger size = [aMsg length]; + * NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)]; + * [foo writeSize:size]; + * [foo appendData:data]; + * ``` + * + * @return The size of the message in it's binary representation. + **/ +- (size_t)serializedSize; + +/** + * @return The descriptor for the message class. + **/ ++ (GPBDescriptor *)descriptor; + +/** + * Return the descriptor for the message. + **/ +- (GPBDescriptor *)descriptor; + +/** + * @return An array with the extension descriptors that are currently set on the + * message. + **/ +- (NSArray *)extensionsCurrentlySet; + +/** + * Checks whether there is an extension set on the message which matches the + * given extension descriptor. + * + * @param extension Extension descriptor to check if it's set on the message. + * + * @return Whether the extension is currently set on the message. + **/ +- (BOOL)hasExtension:(GPBExtensionDescriptor *)extension; + +/* + * Fetches the given extension's value for this message. + * + * Extensions use boxed values (NSNumbers) for PODs and NSMutableArrays for + * repeated fields. If the extension is a Message one will be auto created for + * you and returned similar to fields. + * + * @param extension The extension descriptor of the extension to fetch. + * + * @return The extension matching the given descriptor, or nil if none found. + **/ +- (nullable id)getExtension:(GPBExtensionDescriptor *)extension; + +/** + * Sets the given extension's value for this message. This only applies for + * single field extensions (i.e. - not repeated fields). + * + * Extensions use boxed values (NSNumbers). + * + * @param extension The extension descriptor under which to set the value. + * @param value The value to be set as the extension. + **/ +- (void)setExtension:(GPBExtensionDescriptor *)extension + value:(nullable id)value; + +/** + * Adds the given value to the extension for this message. This only applies + * to repeated field extensions. If the field is a repeated POD type, the value + * should be an NSNumber. + * + * @param extension The extension descriptor under which to add the value. + * @param value The value to be added to the repeated extension. + **/ +- (void)addExtension:(GPBExtensionDescriptor *)extension value:(id)value; + +/** + * Replaces the value at the given index with the given value for the extension + * on this message. This only applies to repeated field extensions. If the field + * is a repeated POD type, the value is should be an NSNumber. + * + * @param extension The extension descriptor under which to replace the value. + * @param index The index of the extension to be replaced. + * @param value The value to be replaced in the repeated extension. + **/ +- (void)setExtension:(GPBExtensionDescriptor *)extension + index:(NSUInteger)index + value:(id)value; + +/** + * Clears the given extension for this message. + * + * @param extension The extension descriptor to be cleared from this message. + **/ +- (void)clearExtension:(GPBExtensionDescriptor *)extension; + +/** + * Resets all of the fields of this message to their default values. + **/ +- (void)clear; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Pods/Protobuf/objectivec/GPBMessage.m b/Pods/Protobuf/objectivec/GPBMessage.m new file mode 100644 index 0000000..37cff6c --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBMessage.m @@ -0,0 +1,3256 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import "GPBMessage_PackagePrivate.h" + +#import +#import + +#import "GPBArray_PackagePrivate.h" +#import "GPBCodedInputStream_PackagePrivate.h" +#import "GPBCodedOutputStream_PackagePrivate.h" +#import "GPBDescriptor_PackagePrivate.h" +#import "GPBDictionary_PackagePrivate.h" +#import "GPBExtensionInternals.h" +#import "GPBExtensionRegistry.h" +#import "GPBRootObject_PackagePrivate.h" +#import "GPBUnknownFieldSet_PackagePrivate.h" +#import "GPBUtilities_PackagePrivate.h" + +// Direct access is use for speed, to avoid even internally declaring things +// read/write, etc. The warning is enabled in the project to ensure code calling +// protos can turn on -Wdirect-ivar-access without issues. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdirect-ivar-access" + +NSString *const GPBMessageErrorDomain = + GPBNSStringifySymbol(GPBMessageErrorDomain); + +NSString *const GPBErrorReasonKey = @"Reason"; + +static NSString *const kGPBDataCoderKey = @"GPBData"; + +// +// PLEASE REMEMBER: +// +// This is the base class for *all* messages generated, so any selector defined, +// *public* or *private* could end up colliding with a proto message field. So +// avoid using selectors that could match a property, use C functions to hide +// them, etc. +// + +@interface GPBMessage () { + @package + GPBUnknownFieldSet *unknownFields_; + NSMutableDictionary *extensionMap_; + NSMutableDictionary *autocreatedExtensionMap_; + + // If the object was autocreated, we remember the creator so that if we get + // mutated, we can inform the creator to make our field visible. + GPBMessage *autocreator_; + GPBFieldDescriptor *autocreatorField_; + GPBExtensionDescriptor *autocreatorExtension_; +} +@end + +static id CreateArrayForField(GPBFieldDescriptor *field, + GPBMessage *autocreator) + __attribute__((ns_returns_retained)); +static id GetOrCreateArrayIvarWithField(GPBMessage *self, + GPBFieldDescriptor *field, + GPBFileSyntax syntax); +static id GetArrayIvarWithField(GPBMessage *self, GPBFieldDescriptor *field); +static id CreateMapForField(GPBFieldDescriptor *field, + GPBMessage *autocreator) + __attribute__((ns_returns_retained)); +static id GetOrCreateMapIvarWithField(GPBMessage *self, + GPBFieldDescriptor *field, + GPBFileSyntax syntax); +static id GetMapIvarWithField(GPBMessage *self, GPBFieldDescriptor *field); +static NSMutableDictionary *CloneExtensionMap(NSDictionary *extensionMap, + NSZone *zone) + __attribute__((ns_returns_retained)); + +#ifdef DEBUG +static NSError *MessageError(NSInteger code, NSDictionary *userInfo) { + return [NSError errorWithDomain:GPBMessageErrorDomain + code:code + userInfo:userInfo]; +} +#endif + +static NSError *ErrorFromException(NSException *exception) { + NSError *error = nil; + + if ([exception.name isEqual:GPBCodedInputStreamException]) { + NSDictionary *exceptionInfo = exception.userInfo; + error = exceptionInfo[GPBCodedInputStreamUnderlyingErrorKey]; + } + + if (!error) { + NSString *reason = exception.reason; + NSDictionary *userInfo = nil; + if ([reason length]) { + userInfo = @{ GPBErrorReasonKey : reason }; + } + + error = [NSError errorWithDomain:GPBMessageErrorDomain + code:GPBMessageErrorCodeOther + userInfo:userInfo]; + } + return error; +} + +static void CheckExtension(GPBMessage *self, + GPBExtensionDescriptor *extension) { + if (![self isKindOfClass:extension.containingMessageClass]) { + [NSException + raise:NSInvalidArgumentException + format:@"Extension %@ used on wrong class (%@ instead of %@)", + extension.singletonName, + [self class], extension.containingMessageClass]; + } +} + +static NSMutableDictionary *CloneExtensionMap(NSDictionary *extensionMap, + NSZone *zone) { + if (extensionMap.count == 0) { + return nil; + } + NSMutableDictionary *result = [[NSMutableDictionary allocWithZone:zone] + initWithCapacity:extensionMap.count]; + + for (GPBExtensionDescriptor *extension in extensionMap) { + id value = [extensionMap objectForKey:extension]; + BOOL isMessageExtension = GPBExtensionIsMessage(extension); + + if (extension.repeated) { + if (isMessageExtension) { + NSMutableArray *list = + [[NSMutableArray alloc] initWithCapacity:[value count]]; + for (GPBMessage *listValue in value) { + GPBMessage *copiedValue = [listValue copyWithZone:zone]; + [list addObject:copiedValue]; + [copiedValue release]; + } + [result setObject:list forKey:extension]; + [list release]; + } else { + NSMutableArray *copiedValue = [value mutableCopyWithZone:zone]; + [result setObject:copiedValue forKey:extension]; + [copiedValue release]; + } + } else { + if (isMessageExtension) { + GPBMessage *copiedValue = [value copyWithZone:zone]; + [result setObject:copiedValue forKey:extension]; + [copiedValue release]; + } else { + [result setObject:value forKey:extension]; + } + } + } + + return result; +} + +static id CreateArrayForField(GPBFieldDescriptor *field, + GPBMessage *autocreator) { + id result; + GPBDataType fieldDataType = GPBGetFieldDataType(field); + switch (fieldDataType) { + case GPBDataTypeBool: + result = [[GPBBoolArray alloc] init]; + break; + case GPBDataTypeFixed32: + case GPBDataTypeUInt32: + result = [[GPBUInt32Array alloc] init]; + break; + case GPBDataTypeInt32: + case GPBDataTypeSFixed32: + case GPBDataTypeSInt32: + result = [[GPBInt32Array alloc] init]; + break; + case GPBDataTypeFixed64: + case GPBDataTypeUInt64: + result = [[GPBUInt64Array alloc] init]; + break; + case GPBDataTypeInt64: + case GPBDataTypeSFixed64: + case GPBDataTypeSInt64: + result = [[GPBInt64Array alloc] init]; + break; + case GPBDataTypeFloat: + result = [[GPBFloatArray alloc] init]; + break; + case GPBDataTypeDouble: + result = [[GPBDoubleArray alloc] init]; + break; + + case GPBDataTypeEnum: + result = [[GPBEnumArray alloc] + initWithValidationFunction:field.enumDescriptor.enumVerifier]; + break; + + case GPBDataTypeBytes: + case GPBDataTypeGroup: + case GPBDataTypeMessage: + case GPBDataTypeString: + if (autocreator) { + result = [[GPBAutocreatedArray alloc] init]; + } else { + result = [[NSMutableArray alloc] init]; + } + break; + } + + if (autocreator) { + if (GPBDataTypeIsObject(fieldDataType)) { + GPBAutocreatedArray *autoArray = result; + autoArray->_autocreator = autocreator; + } else { + GPBInt32Array *gpbArray = result; + gpbArray->_autocreator = autocreator; + } + } + + return result; +} + +static id CreateMapForField(GPBFieldDescriptor *field, + GPBMessage *autocreator) { + id result; + GPBDataType keyDataType = field.mapKeyDataType; + GPBDataType valueDataType = GPBGetFieldDataType(field); + switch (keyDataType) { + case GPBDataTypeBool: + switch (valueDataType) { + case GPBDataTypeBool: + result = [[GPBBoolBoolDictionary alloc] init]; + break; + case GPBDataTypeFixed32: + case GPBDataTypeUInt32: + result = [[GPBBoolUInt32Dictionary alloc] init]; + break; + case GPBDataTypeInt32: + case GPBDataTypeSFixed32: + case GPBDataTypeSInt32: + result = [[GPBBoolInt32Dictionary alloc] init]; + break; + case GPBDataTypeFixed64: + case GPBDataTypeUInt64: + result = [[GPBBoolUInt64Dictionary alloc] init]; + break; + case GPBDataTypeInt64: + case GPBDataTypeSFixed64: + case GPBDataTypeSInt64: + result = [[GPBBoolInt64Dictionary alloc] init]; + break; + case GPBDataTypeFloat: + result = [[GPBBoolFloatDictionary alloc] init]; + break; + case GPBDataTypeDouble: + result = [[GPBBoolDoubleDictionary alloc] init]; + break; + case GPBDataTypeEnum: + result = [[GPBBoolEnumDictionary alloc] + initWithValidationFunction:field.enumDescriptor.enumVerifier]; + break; + case GPBDataTypeBytes: + case GPBDataTypeMessage: + case GPBDataTypeString: + result = [[GPBBoolObjectDictionary alloc] init]; + break; + case GPBDataTypeGroup: + NSCAssert(NO, @"shouldn't happen"); + return nil; + } + break; + case GPBDataTypeFixed32: + case GPBDataTypeUInt32: + switch (valueDataType) { + case GPBDataTypeBool: + result = [[GPBUInt32BoolDictionary alloc] init]; + break; + case GPBDataTypeFixed32: + case GPBDataTypeUInt32: + result = [[GPBUInt32UInt32Dictionary alloc] init]; + break; + case GPBDataTypeInt32: + case GPBDataTypeSFixed32: + case GPBDataTypeSInt32: + result = [[GPBUInt32Int32Dictionary alloc] init]; + break; + case GPBDataTypeFixed64: + case GPBDataTypeUInt64: + result = [[GPBUInt32UInt64Dictionary alloc] init]; + break; + case GPBDataTypeInt64: + case GPBDataTypeSFixed64: + case GPBDataTypeSInt64: + result = [[GPBUInt32Int64Dictionary alloc] init]; + break; + case GPBDataTypeFloat: + result = [[GPBUInt32FloatDictionary alloc] init]; + break; + case GPBDataTypeDouble: + result = [[GPBUInt32DoubleDictionary alloc] init]; + break; + case GPBDataTypeEnum: + result = [[GPBUInt32EnumDictionary alloc] + initWithValidationFunction:field.enumDescriptor.enumVerifier]; + break; + case GPBDataTypeBytes: + case GPBDataTypeMessage: + case GPBDataTypeString: + result = [[GPBUInt32ObjectDictionary alloc] init]; + break; + case GPBDataTypeGroup: + NSCAssert(NO, @"shouldn't happen"); + return nil; + } + break; + case GPBDataTypeInt32: + case GPBDataTypeSFixed32: + case GPBDataTypeSInt32: + switch (valueDataType) { + case GPBDataTypeBool: + result = [[GPBInt32BoolDictionary alloc] init]; + break; + case GPBDataTypeFixed32: + case GPBDataTypeUInt32: + result = [[GPBInt32UInt32Dictionary alloc] init]; + break; + case GPBDataTypeInt32: + case GPBDataTypeSFixed32: + case GPBDataTypeSInt32: + result = [[GPBInt32Int32Dictionary alloc] init]; + break; + case GPBDataTypeFixed64: + case GPBDataTypeUInt64: + result = [[GPBInt32UInt64Dictionary alloc] init]; + break; + case GPBDataTypeInt64: + case GPBDataTypeSFixed64: + case GPBDataTypeSInt64: + result = [[GPBInt32Int64Dictionary alloc] init]; + break; + case GPBDataTypeFloat: + result = [[GPBInt32FloatDictionary alloc] init]; + break; + case GPBDataTypeDouble: + result = [[GPBInt32DoubleDictionary alloc] init]; + break; + case GPBDataTypeEnum: + result = [[GPBInt32EnumDictionary alloc] + initWithValidationFunction:field.enumDescriptor.enumVerifier]; + break; + case GPBDataTypeBytes: + case GPBDataTypeMessage: + case GPBDataTypeString: + result = [[GPBInt32ObjectDictionary alloc] init]; + break; + case GPBDataTypeGroup: + NSCAssert(NO, @"shouldn't happen"); + return nil; + } + break; + case GPBDataTypeFixed64: + case GPBDataTypeUInt64: + switch (valueDataType) { + case GPBDataTypeBool: + result = [[GPBUInt64BoolDictionary alloc] init]; + break; + case GPBDataTypeFixed32: + case GPBDataTypeUInt32: + result = [[GPBUInt64UInt32Dictionary alloc] init]; + break; + case GPBDataTypeInt32: + case GPBDataTypeSFixed32: + case GPBDataTypeSInt32: + result = [[GPBUInt64Int32Dictionary alloc] init]; + break; + case GPBDataTypeFixed64: + case GPBDataTypeUInt64: + result = [[GPBUInt64UInt64Dictionary alloc] init]; + break; + case GPBDataTypeInt64: + case GPBDataTypeSFixed64: + case GPBDataTypeSInt64: + result = [[GPBUInt64Int64Dictionary alloc] init]; + break; + case GPBDataTypeFloat: + result = [[GPBUInt64FloatDictionary alloc] init]; + break; + case GPBDataTypeDouble: + result = [[GPBUInt64DoubleDictionary alloc] init]; + break; + case GPBDataTypeEnum: + result = [[GPBUInt64EnumDictionary alloc] + initWithValidationFunction:field.enumDescriptor.enumVerifier]; + break; + case GPBDataTypeBytes: + case GPBDataTypeMessage: + case GPBDataTypeString: + result = [[GPBUInt64ObjectDictionary alloc] init]; + break; + case GPBDataTypeGroup: + NSCAssert(NO, @"shouldn't happen"); + return nil; + } + break; + case GPBDataTypeInt64: + case GPBDataTypeSFixed64: + case GPBDataTypeSInt64: + switch (valueDataType) { + case GPBDataTypeBool: + result = [[GPBInt64BoolDictionary alloc] init]; + break; + case GPBDataTypeFixed32: + case GPBDataTypeUInt32: + result = [[GPBInt64UInt32Dictionary alloc] init]; + break; + case GPBDataTypeInt32: + case GPBDataTypeSFixed32: + case GPBDataTypeSInt32: + result = [[GPBInt64Int32Dictionary alloc] init]; + break; + case GPBDataTypeFixed64: + case GPBDataTypeUInt64: + result = [[GPBInt64UInt64Dictionary alloc] init]; + break; + case GPBDataTypeInt64: + case GPBDataTypeSFixed64: + case GPBDataTypeSInt64: + result = [[GPBInt64Int64Dictionary alloc] init]; + break; + case GPBDataTypeFloat: + result = [[GPBInt64FloatDictionary alloc] init]; + break; + case GPBDataTypeDouble: + result = [[GPBInt64DoubleDictionary alloc] init]; + break; + case GPBDataTypeEnum: + result = [[GPBInt64EnumDictionary alloc] + initWithValidationFunction:field.enumDescriptor.enumVerifier]; + break; + case GPBDataTypeBytes: + case GPBDataTypeMessage: + case GPBDataTypeString: + result = [[GPBInt64ObjectDictionary alloc] init]; + break; + case GPBDataTypeGroup: + NSCAssert(NO, @"shouldn't happen"); + return nil; + } + break; + case GPBDataTypeString: + switch (valueDataType) { + case GPBDataTypeBool: + result = [[GPBStringBoolDictionary alloc] init]; + break; + case GPBDataTypeFixed32: + case GPBDataTypeUInt32: + result = [[GPBStringUInt32Dictionary alloc] init]; + break; + case GPBDataTypeInt32: + case GPBDataTypeSFixed32: + case GPBDataTypeSInt32: + result = [[GPBStringInt32Dictionary alloc] init]; + break; + case GPBDataTypeFixed64: + case GPBDataTypeUInt64: + result = [[GPBStringUInt64Dictionary alloc] init]; + break; + case GPBDataTypeInt64: + case GPBDataTypeSFixed64: + case GPBDataTypeSInt64: + result = [[GPBStringInt64Dictionary alloc] init]; + break; + case GPBDataTypeFloat: + result = [[GPBStringFloatDictionary alloc] init]; + break; + case GPBDataTypeDouble: + result = [[GPBStringDoubleDictionary alloc] init]; + break; + case GPBDataTypeEnum: + result = [[GPBStringEnumDictionary alloc] + initWithValidationFunction:field.enumDescriptor.enumVerifier]; + break; + case GPBDataTypeBytes: + case GPBDataTypeMessage: + case GPBDataTypeString: + if (autocreator) { + result = [[GPBAutocreatedDictionary alloc] init]; + } else { + result = [[NSMutableDictionary alloc] init]; + } + break; + case GPBDataTypeGroup: + NSCAssert(NO, @"shouldn't happen"); + return nil; + } + break; + + case GPBDataTypeFloat: + case GPBDataTypeDouble: + case GPBDataTypeEnum: + case GPBDataTypeBytes: + case GPBDataTypeGroup: + case GPBDataTypeMessage: + NSCAssert(NO, @"shouldn't happen"); + return nil; + } + + if (autocreator) { + if ((keyDataType == GPBDataTypeString) && + GPBDataTypeIsObject(valueDataType)) { + GPBAutocreatedDictionary *autoDict = result; + autoDict->_autocreator = autocreator; + } else { + GPBInt32Int32Dictionary *gpbDict = result; + gpbDict->_autocreator = autocreator; + } + } + + return result; +} + +#if !defined(__clang_analyzer__) +// These functions are blocked from the analyzer because the analyzer sees the +// GPBSetRetainedObjectIvarWithFieldInternal() call as consuming the array/map, +// so use of the array/map after the call returns is flagged as a use after +// free. +// But GPBSetRetainedObjectIvarWithFieldInternal() is "consuming" the retain +// count be holding onto the object (it is transfering it), the object is +// still valid after returning from the call. The other way to avoid this +// would be to add a -retain/-autorelease, but that would force every +// repeated/map field parsed into the autorelease pool which is both a memory +// and performance hit. + +static id GetOrCreateArrayIvarWithField(GPBMessage *self, + GPBFieldDescriptor *field, + GPBFileSyntax syntax) { + id array = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + if (!array) { + // No lock needed, this is called from places expecting to mutate + // so no threading protection is needed. + array = CreateArrayForField(field, nil); + GPBSetRetainedObjectIvarWithFieldInternal(self, field, array, syntax); + } + return array; +} + +// This is like GPBGetObjectIvarWithField(), but for arrays, it should +// only be used to wire the method into the class. +static id GetArrayIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) { + id array = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + if (!array) { + // Check again after getting the lock. + GPBPrepareReadOnlySemaphore(self); + dispatch_semaphore_wait(self->readOnlySemaphore_, DISPATCH_TIME_FOREVER); + array = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + if (!array) { + array = CreateArrayForField(field, self); + GPBSetAutocreatedRetainedObjectIvarWithField(self, field, array); + } + dispatch_semaphore_signal(self->readOnlySemaphore_); + } + return array; +} + +static id GetOrCreateMapIvarWithField(GPBMessage *self, + GPBFieldDescriptor *field, + GPBFileSyntax syntax) { + id dict = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + if (!dict) { + // No lock needed, this is called from places expecting to mutate + // so no threading protection is needed. + dict = CreateMapForField(field, nil); + GPBSetRetainedObjectIvarWithFieldInternal(self, field, dict, syntax); + } + return dict; +} + +// This is like GPBGetObjectIvarWithField(), but for maps, it should +// only be used to wire the method into the class. +static id GetMapIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) { + id dict = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + if (!dict) { + // Check again after getting the lock. + GPBPrepareReadOnlySemaphore(self); + dispatch_semaphore_wait(self->readOnlySemaphore_, DISPATCH_TIME_FOREVER); + dict = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + if (!dict) { + dict = CreateMapForField(field, self); + GPBSetAutocreatedRetainedObjectIvarWithField(self, field, dict); + } + dispatch_semaphore_signal(self->readOnlySemaphore_); + } + return dict; +} + +#endif // !defined(__clang_analyzer__) + +GPBMessage *GPBCreateMessageWithAutocreator(Class msgClass, + GPBMessage *autocreator, + GPBFieldDescriptor *field) { + GPBMessage *message = [[msgClass alloc] init]; + message->autocreator_ = autocreator; + message->autocreatorField_ = [field retain]; + return message; +} + +static GPBMessage *CreateMessageWithAutocreatorForExtension( + Class msgClass, GPBMessage *autocreator, GPBExtensionDescriptor *extension) + __attribute__((ns_returns_retained)); + +static GPBMessage *CreateMessageWithAutocreatorForExtension( + Class msgClass, GPBMessage *autocreator, + GPBExtensionDescriptor *extension) { + GPBMessage *message = [[msgClass alloc] init]; + message->autocreator_ = autocreator; + message->autocreatorExtension_ = [extension retain]; + return message; +} + +BOOL GPBWasMessageAutocreatedBy(GPBMessage *message, GPBMessage *parent) { + return (message->autocreator_ == parent); +} + +void GPBBecomeVisibleToAutocreator(GPBMessage *self) { + // Message objects that are implicitly created by accessing a message field + // are initially not visible via the hasX selector. This method makes them + // visible. + if (self->autocreator_) { + // This will recursively make all parent messages visible until it reaches a + // super-creator that's visible. + if (self->autocreatorField_) { + GPBFileSyntax syntax = [self->autocreator_ descriptor].file.syntax; + GPBSetObjectIvarWithFieldInternal(self->autocreator_, + self->autocreatorField_, self, syntax); + } else { + [self->autocreator_ setExtension:self->autocreatorExtension_ value:self]; + } + } +} + +void GPBAutocreatedArrayModified(GPBMessage *self, id array) { + // When one of our autocreated arrays adds elements, make it visible. + GPBDescriptor *descriptor = [[self class] descriptor]; + for (GPBFieldDescriptor *field in descriptor->fields_) { + if (field.fieldType == GPBFieldTypeRepeated) { + id curArray = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + if (curArray == array) { + if (GPBFieldDataTypeIsObject(field)) { + GPBAutocreatedArray *autoArray = array; + autoArray->_autocreator = nil; + } else { + GPBInt32Array *gpbArray = array; + gpbArray->_autocreator = nil; + } + GPBBecomeVisibleToAutocreator(self); + return; + } + } + } + NSCAssert(NO, @"Unknown autocreated %@ for %@.", [array class], self); +} + +void GPBAutocreatedDictionaryModified(GPBMessage *self, id dictionary) { + // When one of our autocreated dicts adds elements, make it visible. + GPBDescriptor *descriptor = [[self class] descriptor]; + for (GPBFieldDescriptor *field in descriptor->fields_) { + if (field.fieldType == GPBFieldTypeMap) { + id curDict = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + if (curDict == dictionary) { + if ((field.mapKeyDataType == GPBDataTypeString) && + GPBFieldDataTypeIsObject(field)) { + GPBAutocreatedDictionary *autoDict = dictionary; + autoDict->_autocreator = nil; + } else { + GPBInt32Int32Dictionary *gpbDict = dictionary; + gpbDict->_autocreator = nil; + } + GPBBecomeVisibleToAutocreator(self); + return; + } + } + } + NSCAssert(NO, @"Unknown autocreated %@ for %@.", [dictionary class], self); +} + +void GPBClearMessageAutocreator(GPBMessage *self) { + if ((self == nil) || !self->autocreator_) { + return; + } + +#if defined(DEBUG) && DEBUG && !defined(NS_BLOCK_ASSERTIONS) + // Either the autocreator must have its "has" flag set to YES, or it must be + // NO and not equal to ourselves. + BOOL autocreatorHas = + (self->autocreatorField_ + ? GPBGetHasIvarField(self->autocreator_, self->autocreatorField_) + : [self->autocreator_ hasExtension:self->autocreatorExtension_]); + GPBMessage *autocreatorFieldValue = + (self->autocreatorField_ + ? GPBGetObjectIvarWithFieldNoAutocreate(self->autocreator_, + self->autocreatorField_) + : [self->autocreator_->autocreatedExtensionMap_ + objectForKey:self->autocreatorExtension_]); + NSCAssert(autocreatorHas || autocreatorFieldValue != self, + @"Cannot clear autocreator because it still refers to self, self: %@.", + self); + +#endif // DEBUG && !defined(NS_BLOCK_ASSERTIONS) + + self->autocreator_ = nil; + [self->autocreatorField_ release]; + self->autocreatorField_ = nil; + [self->autocreatorExtension_ release]; + self->autocreatorExtension_ = nil; +} + +// Call this before using the readOnlySemaphore_. This ensures it is created only once. +void GPBPrepareReadOnlySemaphore(GPBMessage *self) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdirect-ivar-access" +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + + // Create the semaphore on demand (rather than init) as developers might not cause them + // to be needed, and the heap usage can add up. The atomic swap is used to avoid needing + // another lock around creating it. + if (self->readOnlySemaphore_ == nil) { + dispatch_semaphore_t worker = dispatch_semaphore_create(1); + if (!OSAtomicCompareAndSwapPtrBarrier(NULL, worker, (void * volatile *)&(self->readOnlySemaphore_))) { + dispatch_release(worker); + } + } + +#pragma clang diagnostic pop +} + +static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { + if (!self->unknownFields_) { + self->unknownFields_ = [[GPBUnknownFieldSet alloc] init]; + GPBBecomeVisibleToAutocreator(self); + } + return self->unknownFields_; +} + +@implementation GPBMessage + ++ (void)initialize { + Class pbMessageClass = [GPBMessage class]; + if ([self class] == pbMessageClass) { + // This is here to start up the "base" class descriptor. + [self descriptor]; + // Message shares extension method resolving with GPBRootObject so insure + // it is started up at the same time. + (void)[GPBRootObject class]; + } else if ([self superclass] == pbMessageClass) { + // This is here to start up all the "message" subclasses. Just needs to be + // done for the messages, not any of the subclasses. + // This must be done in initialize to enforce thread safety of start up of + // the protocol buffer library. + // Note: The generated code for -descriptor calls + // +[GPBDescriptor allocDescriptorForClass:...], passing the GPBRootObject + // subclass for the file. That call chain is what ensures that *Root class + // is started up to support extension resolution off the message class + // (+resolveClassMethod: below) in a thread safe manner. + [self descriptor]; + } +} + ++ (instancetype)allocWithZone:(NSZone *)zone { + // Override alloc to allocate our classes with the additional storage + // required for the instance variables. + GPBDescriptor *descriptor = [self descriptor]; + return NSAllocateObject(self, descriptor->storageSize_, zone); +} + ++ (instancetype)alloc { + return [self allocWithZone:nil]; +} + ++ (GPBDescriptor *)descriptor { + // This is thread safe because it is called from +initialize. + static GPBDescriptor *descriptor = NULL; + static GPBFileDescriptor *fileDescriptor = NULL; + if (!descriptor) { + // Use a dummy file that marks it as proto2 syntax so when used generically + // it supports unknowns/etc. + fileDescriptor = + [[GPBFileDescriptor alloc] initWithPackage:@"internal" + syntax:GPBFileSyntaxProto2]; + + descriptor = [GPBDescriptor allocDescriptorForClass:[GPBMessage class] + rootClass:Nil + file:fileDescriptor + fields:NULL + fieldCount:0 + storageSize:0 + flags:0]; + } + return descriptor; +} + ++ (instancetype)message { + return [[[self alloc] init] autorelease]; +} + +- (instancetype)init { + if ((self = [super init])) { + messageStorage_ = (GPBMessage_StoragePtr)( + ((uint8_t *)self) + class_getInstanceSize([self class])); + } + + return self; +} + +- (instancetype)initWithData:(NSData *)data error:(NSError **)errorPtr { + return [self initWithData:data extensionRegistry:nil error:errorPtr]; +} + +- (instancetype)initWithData:(NSData *)data + extensionRegistry:(GPBExtensionRegistry *)extensionRegistry + error:(NSError **)errorPtr { + if ((self = [self init])) { + @try { + [self mergeFromData:data extensionRegistry:extensionRegistry]; + if (errorPtr) { + *errorPtr = nil; + } + } + @catch (NSException *exception) { + [self release]; + self = nil; + if (errorPtr) { + *errorPtr = ErrorFromException(exception); + } + } +#ifdef DEBUG + if (self && !self.initialized) { + [self release]; + self = nil; + if (errorPtr) { + *errorPtr = MessageError(GPBMessageErrorCodeMissingRequiredField, nil); + } + } +#endif + } + return self; +} + +- (instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input + extensionRegistry: + (GPBExtensionRegistry *)extensionRegistry + error:(NSError **)errorPtr { + if ((self = [self init])) { + @try { + [self mergeFromCodedInputStream:input extensionRegistry:extensionRegistry]; + if (errorPtr) { + *errorPtr = nil; + } + } + @catch (NSException *exception) { + [self release]; + self = nil; + if (errorPtr) { + *errorPtr = ErrorFromException(exception); + } + } +#ifdef DEBUG + if (self && !self.initialized) { + [self release]; + self = nil; + if (errorPtr) { + *errorPtr = MessageError(GPBMessageErrorCodeMissingRequiredField, nil); + } + } +#endif + } + return self; +} + +- (void)dealloc { + [self internalClear:NO]; + NSCAssert(!autocreator_, @"Autocreator was not cleared before dealloc."); + if (readOnlySemaphore_) { + dispatch_release(readOnlySemaphore_); + } + [super dealloc]; +} + +- (void)copyFieldsInto:(GPBMessage *)message + zone:(NSZone *)zone + descriptor:(GPBDescriptor *)descriptor { + // Copy all the storage... + memcpy(message->messageStorage_, messageStorage_, descriptor->storageSize_); + + GPBFileSyntax syntax = descriptor.file.syntax; + + // Loop over the fields doing fixup... + for (GPBFieldDescriptor *field in descriptor->fields_) { + if (GPBFieldIsMapOrArray(field)) { + id value = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + if (value) { + // We need to copy the array/map, but the catch is for message fields, + // we also need to ensure all the messages as those need copying also. + id newValue; + if (GPBFieldDataTypeIsMessage(field)) { + if (field.fieldType == GPBFieldTypeRepeated) { + NSArray *existingArray = (NSArray *)value; + NSMutableArray *newArray = + [[NSMutableArray alloc] initWithCapacity:existingArray.count]; + newValue = newArray; + for (GPBMessage *msg in existingArray) { + GPBMessage *copiedMsg = [msg copyWithZone:zone]; + [newArray addObject:copiedMsg]; + [copiedMsg release]; + } + } else { + if (field.mapKeyDataType == GPBDataTypeString) { + // Map is an NSDictionary. + NSDictionary *existingDict = value; + NSMutableDictionary *newDict = [[NSMutableDictionary alloc] + initWithCapacity:existingDict.count]; + newValue = newDict; + [existingDict enumerateKeysAndObjectsUsingBlock:^(NSString *key, + GPBMessage *msg, + BOOL *stop) { +#pragma unused(stop) + GPBMessage *copiedMsg = [msg copyWithZone:zone]; + [newDict setObject:copiedMsg forKey:key]; + [copiedMsg release]; + }]; + } else { + // Is one of the GPB*ObjectDictionary classes. Type doesn't + // matter, just need one to invoke the selector. + GPBInt32ObjectDictionary *existingDict = value; + newValue = [existingDict deepCopyWithZone:zone]; + } + } + } else { + // Not messages (but is a map/array)... + if (field.fieldType == GPBFieldTypeRepeated) { + if (GPBFieldDataTypeIsObject(field)) { + // NSArray + newValue = [value mutableCopyWithZone:zone]; + } else { + // GPB*Array + newValue = [value copyWithZone:zone]; + } + } else { + if (field.mapKeyDataType == GPBDataTypeString) { + // NSDictionary + newValue = [value mutableCopyWithZone:zone]; + } else { + // Is one of the GPB*Dictionary classes. Type doesn't matter, + // just need one to invoke the selector. + GPBInt32Int32Dictionary *existingDict = value; + newValue = [existingDict copyWithZone:zone]; + } + } + } + // We retain here because the memcpy picked up the pointer value and + // the next call to SetRetainedObject... will release the current value. + [value retain]; + GPBSetRetainedObjectIvarWithFieldInternal(message, field, newValue, + syntax); + } + } else if (GPBFieldDataTypeIsMessage(field)) { + // For object types, if we have a value, copy it. If we don't, + // zero it to remove the pointer to something that was autocreated + // (and the ptr just got memcpyed). + if (GPBGetHasIvarField(self, field)) { + GPBMessage *value = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + GPBMessage *newValue = [value copyWithZone:zone]; + // We retain here because the memcpy picked up the pointer value and + // the next call to SetRetainedObject... will release the current value. + [value retain]; + GPBSetRetainedObjectIvarWithFieldInternal(message, field, newValue, + syntax); + } else { + uint8_t *storage = (uint8_t *)message->messageStorage_; + id *typePtr = (id *)&storage[field->description_->offset]; + *typePtr = NULL; + } + } else if (GPBFieldDataTypeIsObject(field) && + GPBGetHasIvarField(self, field)) { + // A set string/data value (message picked off above), copy it. + id value = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + id newValue = [value copyWithZone:zone]; + // We retain here because the memcpy picked up the pointer value and + // the next call to SetRetainedObject... will release the current value. + [value retain]; + GPBSetRetainedObjectIvarWithFieldInternal(message, field, newValue, + syntax); + } else { + // memcpy took care of the rest of the primitive fields if they were set. + } + } // for (field in descriptor->fields_) +} + +- (id)copyWithZone:(NSZone *)zone { + GPBDescriptor *descriptor = [self descriptor]; + GPBMessage *result = [[descriptor.messageClass allocWithZone:zone] init]; + + [self copyFieldsInto:result zone:zone descriptor:descriptor]; + // Make immutable copies of the extra bits. + result->unknownFields_ = [unknownFields_ copyWithZone:zone]; + result->extensionMap_ = CloneExtensionMap(extensionMap_, zone); + return result; +} + +- (void)clear { + [self internalClear:YES]; +} + +- (void)internalClear:(BOOL)zeroStorage { + GPBDescriptor *descriptor = [self descriptor]; + for (GPBFieldDescriptor *field in descriptor->fields_) { + if (GPBFieldIsMapOrArray(field)) { + id arrayOrMap = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + if (arrayOrMap) { + if (field.fieldType == GPBFieldTypeRepeated) { + if (GPBFieldDataTypeIsObject(field)) { + if ([arrayOrMap isKindOfClass:[GPBAutocreatedArray class]]) { + GPBAutocreatedArray *autoArray = arrayOrMap; + if (autoArray->_autocreator == self) { + autoArray->_autocreator = nil; + } + } + } else { + // Type doesn't matter, it is a GPB*Array. + GPBInt32Array *gpbArray = arrayOrMap; + if (gpbArray->_autocreator == self) { + gpbArray->_autocreator = nil; + } + } + } else { + if ((field.mapKeyDataType == GPBDataTypeString) && + GPBFieldDataTypeIsObject(field)) { + if ([arrayOrMap isKindOfClass:[GPBAutocreatedDictionary class]]) { + GPBAutocreatedDictionary *autoDict = arrayOrMap; + if (autoDict->_autocreator == self) { + autoDict->_autocreator = nil; + } + } + } else { + // Type doesn't matter, it is a GPB*Dictionary. + GPBInt32Int32Dictionary *gpbDict = arrayOrMap; + if (gpbDict->_autocreator == self) { + gpbDict->_autocreator = nil; + } + } + } + [arrayOrMap release]; + } + } else if (GPBFieldDataTypeIsMessage(field)) { + GPBClearAutocreatedMessageIvarWithField(self, field); + GPBMessage *value = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [value release]; + } else if (GPBFieldDataTypeIsObject(field) && + GPBGetHasIvarField(self, field)) { + id value = GPBGetObjectIvarWithField(self, field); + [value release]; + } + } + + // GPBClearMessageAutocreator() expects that its caller has already been + // removed from autocreatedExtensionMap_ so we set to nil first. + NSArray *autocreatedValues = [autocreatedExtensionMap_ allValues]; + [autocreatedExtensionMap_ release]; + autocreatedExtensionMap_ = nil; + + // Since we're clearing all of our extensions, make sure that we clear the + // autocreator on any that we've created so they no longer refer to us. + for (GPBMessage *value in autocreatedValues) { + NSCAssert(GPBWasMessageAutocreatedBy(value, self), + @"Autocreated extension does not refer back to self."); + GPBClearMessageAutocreator(value); + } + + [extensionMap_ release]; + extensionMap_ = nil; + [unknownFields_ release]; + unknownFields_ = nil; + + // Note that clearing does not affect autocreator_. If we are being cleared + // because of a dealloc, then autocreator_ should be nil anyway. If we are + // being cleared because someone explicitly clears us, we don't want to + // sever our relationship with our autocreator. + + if (zeroStorage) { + memset(messageStorage_, 0, descriptor->storageSize_); + } +} + +- (BOOL)isInitialized { + GPBDescriptor *descriptor = [self descriptor]; + for (GPBFieldDescriptor *field in descriptor->fields_) { + if (field.isRequired) { + if (!GPBGetHasIvarField(self, field)) { + return NO; + } + } + if (GPBFieldDataTypeIsMessage(field)) { + GPBFieldType fieldType = field.fieldType; + if (fieldType == GPBFieldTypeSingle) { + if (field.isRequired) { + GPBMessage *message = GPBGetMessageMessageField(self, field); + if (!message.initialized) { + return NO; + } + } else { + NSAssert(field.isOptional, + @"%@: Single message field %@ not required or optional?", + [self class], field.name); + if (GPBGetHasIvarField(self, field)) { + GPBMessage *message = GPBGetMessageMessageField(self, field); + if (!message.initialized) { + return NO; + } + } + } + } else if (fieldType == GPBFieldTypeRepeated) { + NSArray *array = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + for (GPBMessage *message in array) { + if (!message.initialized) { + return NO; + } + } + } else { // fieldType == GPBFieldTypeMap + if (field.mapKeyDataType == GPBDataTypeString) { + NSDictionary *map = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + if (map && !GPBDictionaryIsInitializedInternalHelper(map, field)) { + return NO; + } + } else { + // Real type is GPB*ObjectDictionary, exact type doesn't matter. + GPBInt32ObjectDictionary *map = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + if (map && ![map isInitialized]) { + return NO; + } + } + } + } + } + + __block BOOL result = YES; + [extensionMap_ + enumerateKeysAndObjectsUsingBlock:^(GPBExtensionDescriptor *extension, + id obj, + BOOL *stop) { + if (GPBExtensionIsMessage(extension)) { + if (extension.isRepeated) { + for (GPBMessage *msg in obj) { + if (!msg.initialized) { + result = NO; + *stop = YES; + break; + } + } + } else { + GPBMessage *asMsg = obj; + if (!asMsg.initialized) { + result = NO; + *stop = YES; + } + } + } + }]; + return result; +} + +- (GPBDescriptor *)descriptor { + return [[self class] descriptor]; +} + +- (NSData *)data { +#ifdef DEBUG + if (!self.initialized) { + return nil; + } +#endif + NSMutableData *data = [NSMutableData dataWithLength:[self serializedSize]]; + GPBCodedOutputStream *stream = + [[GPBCodedOutputStream alloc] initWithData:data]; + @try { + [self writeToCodedOutputStream:stream]; + } + @catch (NSException *exception) { + // This really shouldn't happen. The only way writeToCodedOutputStream: + // could throw is if something in the library has a bug and the + // serializedSize was wrong. +#ifdef DEBUG + NSLog(@"%@: Internal exception while building message data: %@", + [self class], exception); +#endif + data = nil; + } + [stream release]; + return data; +} + +- (NSData *)delimitedData { + size_t serializedSize = [self serializedSize]; + size_t varintSize = GPBComputeRawVarint32SizeForInteger(serializedSize); + NSMutableData *data = + [NSMutableData dataWithLength:(serializedSize + varintSize)]; + GPBCodedOutputStream *stream = + [[GPBCodedOutputStream alloc] initWithData:data]; + @try { + [self writeDelimitedToCodedOutputStream:stream]; + } + @catch (NSException *exception) { + // This really shouldn't happen. The only way writeToCodedOutputStream: + // could throw is if something in the library has a bug and the + // serializedSize was wrong. +#ifdef DEBUG + NSLog(@"%@: Internal exception while building message delimitedData: %@", + [self class], exception); +#endif + // If it happens, truncate. + data.length = 0; + } + [stream release]; + return data; +} + +- (void)writeToOutputStream:(NSOutputStream *)output { + GPBCodedOutputStream *stream = + [[GPBCodedOutputStream alloc] initWithOutputStream:output]; + [self writeToCodedOutputStream:stream]; + [stream release]; +} + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)output { + GPBDescriptor *descriptor = [self descriptor]; + NSArray *fieldsArray = descriptor->fields_; + NSUInteger fieldCount = fieldsArray.count; + const GPBExtensionRange *extensionRanges = descriptor.extensionRanges; + NSUInteger extensionRangesCount = descriptor.extensionRangesCount; + for (NSUInteger i = 0, j = 0; i < fieldCount || j < extensionRangesCount;) { + if (i == fieldCount) { + [self writeExtensionsToCodedOutputStream:output + range:extensionRanges[j++]]; + } else if (j == extensionRangesCount || + GPBFieldNumber(fieldsArray[i]) < extensionRanges[j].start) { + [self writeField:fieldsArray[i++] toCodedOutputStream:output]; + } else { + [self writeExtensionsToCodedOutputStream:output + range:extensionRanges[j++]]; + } + } + if (descriptor.isWireFormat) { + [unknownFields_ writeAsMessageSetTo:output]; + } else { + [unknownFields_ writeToCodedOutputStream:output]; + } +} + +- (void)writeDelimitedToOutputStream:(NSOutputStream *)output { + GPBCodedOutputStream *codedOutput = + [[GPBCodedOutputStream alloc] initWithOutputStream:output]; + [self writeDelimitedToCodedOutputStream:codedOutput]; + [codedOutput release]; +} + +- (void)writeDelimitedToCodedOutputStream:(GPBCodedOutputStream *)output { + [output writeRawVarintSizeTAs32:[self serializedSize]]; + [self writeToCodedOutputStream:output]; +} + +- (void)writeField:(GPBFieldDescriptor *)field + toCodedOutputStream:(GPBCodedOutputStream *)output { + GPBFieldType fieldType = field.fieldType; + if (fieldType == GPBFieldTypeSingle) { + BOOL has = GPBGetHasIvarField(self, field); + if (!has) { + return; + } + } + uint32_t fieldNumber = GPBFieldNumber(field); + +//%PDDM-DEFINE FIELD_CASE(TYPE, REAL_TYPE) +//%FIELD_CASE_FULL(TYPE, REAL_TYPE, REAL_TYPE) +//%PDDM-DEFINE FIELD_CASE_FULL(TYPE, REAL_TYPE, ARRAY_TYPE) +//% case GPBDataType##TYPE: +//% if (fieldType == GPBFieldTypeRepeated) { +//% uint32_t tag = field.isPackable ? GPBFieldTag(field) : 0; +//% GPB##ARRAY_TYPE##Array *array = +//% GPBGetObjectIvarWithFieldNoAutocreate(self, field); +//% [output write##TYPE##Array:fieldNumber values:array tag:tag]; +//% } else if (fieldType == GPBFieldTypeSingle) { +//% [output write##TYPE:fieldNumber +//% TYPE$S value:GPBGetMessage##REAL_TYPE##Field(self, field)]; +//% } else { // fieldType == GPBFieldTypeMap +//% // Exact type here doesn't matter. +//% GPBInt32##ARRAY_TYPE##Dictionary *dict = +//% GPBGetObjectIvarWithFieldNoAutocreate(self, field); +//% [dict writeToCodedOutputStream:output asField:field]; +//% } +//% break; +//% +//%PDDM-DEFINE FIELD_CASE2(TYPE) +//% case GPBDataType##TYPE: +//% if (fieldType == GPBFieldTypeRepeated) { +//% NSArray *array = GPBGetObjectIvarWithFieldNoAutocreate(self, field); +//% [output write##TYPE##Array:fieldNumber values:array]; +//% } else if (fieldType == GPBFieldTypeSingle) { +//% // GPBGetObjectIvarWithFieldNoAutocreate() avoids doing the has check +//% // again. +//% [output write##TYPE:fieldNumber +//% TYPE$S value:GPBGetObjectIvarWithFieldNoAutocreate(self, field)]; +//% } else { // fieldType == GPBFieldTypeMap +//% // Exact type here doesn't matter. +//% id dict = GPBGetObjectIvarWithFieldNoAutocreate(self, field); +//% GPBDataType mapKeyDataType = field.mapKeyDataType; +//% if (mapKeyDataType == GPBDataTypeString) { +//% GPBDictionaryWriteToStreamInternalHelper(output, dict, field); +//% } else { +//% [dict writeToCodedOutputStream:output asField:field]; +//% } +//% } +//% break; +//% + + switch (GPBGetFieldDataType(field)) { + +//%PDDM-EXPAND FIELD_CASE(Bool, Bool) +// This block of code is generated, do not edit it directly. + + case GPBDataTypeBool: + if (fieldType == GPBFieldTypeRepeated) { + uint32_t tag = field.isPackable ? GPBFieldTag(field) : 0; + GPBBoolArray *array = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [output writeBoolArray:fieldNumber values:array tag:tag]; + } else if (fieldType == GPBFieldTypeSingle) { + [output writeBool:fieldNumber + value:GPBGetMessageBoolField(self, field)]; + } else { // fieldType == GPBFieldTypeMap + // Exact type here doesn't matter. + GPBInt32BoolDictionary *dict = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [dict writeToCodedOutputStream:output asField:field]; + } + break; + +//%PDDM-EXPAND FIELD_CASE(Fixed32, UInt32) +// This block of code is generated, do not edit it directly. + + case GPBDataTypeFixed32: + if (fieldType == GPBFieldTypeRepeated) { + uint32_t tag = field.isPackable ? GPBFieldTag(field) : 0; + GPBUInt32Array *array = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [output writeFixed32Array:fieldNumber values:array tag:tag]; + } else if (fieldType == GPBFieldTypeSingle) { + [output writeFixed32:fieldNumber + value:GPBGetMessageUInt32Field(self, field)]; + } else { // fieldType == GPBFieldTypeMap + // Exact type here doesn't matter. + GPBInt32UInt32Dictionary *dict = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [dict writeToCodedOutputStream:output asField:field]; + } + break; + +//%PDDM-EXPAND FIELD_CASE(SFixed32, Int32) +// This block of code is generated, do not edit it directly. + + case GPBDataTypeSFixed32: + if (fieldType == GPBFieldTypeRepeated) { + uint32_t tag = field.isPackable ? GPBFieldTag(field) : 0; + GPBInt32Array *array = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [output writeSFixed32Array:fieldNumber values:array tag:tag]; + } else if (fieldType == GPBFieldTypeSingle) { + [output writeSFixed32:fieldNumber + value:GPBGetMessageInt32Field(self, field)]; + } else { // fieldType == GPBFieldTypeMap + // Exact type here doesn't matter. + GPBInt32Int32Dictionary *dict = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [dict writeToCodedOutputStream:output asField:field]; + } + break; + +//%PDDM-EXPAND FIELD_CASE(Float, Float) +// This block of code is generated, do not edit it directly. + + case GPBDataTypeFloat: + if (fieldType == GPBFieldTypeRepeated) { + uint32_t tag = field.isPackable ? GPBFieldTag(field) : 0; + GPBFloatArray *array = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [output writeFloatArray:fieldNumber values:array tag:tag]; + } else if (fieldType == GPBFieldTypeSingle) { + [output writeFloat:fieldNumber + value:GPBGetMessageFloatField(self, field)]; + } else { // fieldType == GPBFieldTypeMap + // Exact type here doesn't matter. + GPBInt32FloatDictionary *dict = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [dict writeToCodedOutputStream:output asField:field]; + } + break; + +//%PDDM-EXPAND FIELD_CASE(Fixed64, UInt64) +// This block of code is generated, do not edit it directly. + + case GPBDataTypeFixed64: + if (fieldType == GPBFieldTypeRepeated) { + uint32_t tag = field.isPackable ? GPBFieldTag(field) : 0; + GPBUInt64Array *array = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [output writeFixed64Array:fieldNumber values:array tag:tag]; + } else if (fieldType == GPBFieldTypeSingle) { + [output writeFixed64:fieldNumber + value:GPBGetMessageUInt64Field(self, field)]; + } else { // fieldType == GPBFieldTypeMap + // Exact type here doesn't matter. + GPBInt32UInt64Dictionary *dict = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [dict writeToCodedOutputStream:output asField:field]; + } + break; + +//%PDDM-EXPAND FIELD_CASE(SFixed64, Int64) +// This block of code is generated, do not edit it directly. + + case GPBDataTypeSFixed64: + if (fieldType == GPBFieldTypeRepeated) { + uint32_t tag = field.isPackable ? GPBFieldTag(field) : 0; + GPBInt64Array *array = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [output writeSFixed64Array:fieldNumber values:array tag:tag]; + } else if (fieldType == GPBFieldTypeSingle) { + [output writeSFixed64:fieldNumber + value:GPBGetMessageInt64Field(self, field)]; + } else { // fieldType == GPBFieldTypeMap + // Exact type here doesn't matter. + GPBInt32Int64Dictionary *dict = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [dict writeToCodedOutputStream:output asField:field]; + } + break; + +//%PDDM-EXPAND FIELD_CASE(Double, Double) +// This block of code is generated, do not edit it directly. + + case GPBDataTypeDouble: + if (fieldType == GPBFieldTypeRepeated) { + uint32_t tag = field.isPackable ? GPBFieldTag(field) : 0; + GPBDoubleArray *array = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [output writeDoubleArray:fieldNumber values:array tag:tag]; + } else if (fieldType == GPBFieldTypeSingle) { + [output writeDouble:fieldNumber + value:GPBGetMessageDoubleField(self, field)]; + } else { // fieldType == GPBFieldTypeMap + // Exact type here doesn't matter. + GPBInt32DoubleDictionary *dict = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [dict writeToCodedOutputStream:output asField:field]; + } + break; + +//%PDDM-EXPAND FIELD_CASE(Int32, Int32) +// This block of code is generated, do not edit it directly. + + case GPBDataTypeInt32: + if (fieldType == GPBFieldTypeRepeated) { + uint32_t tag = field.isPackable ? GPBFieldTag(field) : 0; + GPBInt32Array *array = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [output writeInt32Array:fieldNumber values:array tag:tag]; + } else if (fieldType == GPBFieldTypeSingle) { + [output writeInt32:fieldNumber + value:GPBGetMessageInt32Field(self, field)]; + } else { // fieldType == GPBFieldTypeMap + // Exact type here doesn't matter. + GPBInt32Int32Dictionary *dict = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [dict writeToCodedOutputStream:output asField:field]; + } + break; + +//%PDDM-EXPAND FIELD_CASE(Int64, Int64) +// This block of code is generated, do not edit it directly. + + case GPBDataTypeInt64: + if (fieldType == GPBFieldTypeRepeated) { + uint32_t tag = field.isPackable ? GPBFieldTag(field) : 0; + GPBInt64Array *array = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [output writeInt64Array:fieldNumber values:array tag:tag]; + } else if (fieldType == GPBFieldTypeSingle) { + [output writeInt64:fieldNumber + value:GPBGetMessageInt64Field(self, field)]; + } else { // fieldType == GPBFieldTypeMap + // Exact type here doesn't matter. + GPBInt32Int64Dictionary *dict = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [dict writeToCodedOutputStream:output asField:field]; + } + break; + +//%PDDM-EXPAND FIELD_CASE(SInt32, Int32) +// This block of code is generated, do not edit it directly. + + case GPBDataTypeSInt32: + if (fieldType == GPBFieldTypeRepeated) { + uint32_t tag = field.isPackable ? GPBFieldTag(field) : 0; + GPBInt32Array *array = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [output writeSInt32Array:fieldNumber values:array tag:tag]; + } else if (fieldType == GPBFieldTypeSingle) { + [output writeSInt32:fieldNumber + value:GPBGetMessageInt32Field(self, field)]; + } else { // fieldType == GPBFieldTypeMap + // Exact type here doesn't matter. + GPBInt32Int32Dictionary *dict = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [dict writeToCodedOutputStream:output asField:field]; + } + break; + +//%PDDM-EXPAND FIELD_CASE(SInt64, Int64) +// This block of code is generated, do not edit it directly. + + case GPBDataTypeSInt64: + if (fieldType == GPBFieldTypeRepeated) { + uint32_t tag = field.isPackable ? GPBFieldTag(field) : 0; + GPBInt64Array *array = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [output writeSInt64Array:fieldNumber values:array tag:tag]; + } else if (fieldType == GPBFieldTypeSingle) { + [output writeSInt64:fieldNumber + value:GPBGetMessageInt64Field(self, field)]; + } else { // fieldType == GPBFieldTypeMap + // Exact type here doesn't matter. + GPBInt32Int64Dictionary *dict = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [dict writeToCodedOutputStream:output asField:field]; + } + break; + +//%PDDM-EXPAND FIELD_CASE(UInt32, UInt32) +// This block of code is generated, do not edit it directly. + + case GPBDataTypeUInt32: + if (fieldType == GPBFieldTypeRepeated) { + uint32_t tag = field.isPackable ? GPBFieldTag(field) : 0; + GPBUInt32Array *array = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [output writeUInt32Array:fieldNumber values:array tag:tag]; + } else if (fieldType == GPBFieldTypeSingle) { + [output writeUInt32:fieldNumber + value:GPBGetMessageUInt32Field(self, field)]; + } else { // fieldType == GPBFieldTypeMap + // Exact type here doesn't matter. + GPBInt32UInt32Dictionary *dict = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [dict writeToCodedOutputStream:output asField:field]; + } + break; + +//%PDDM-EXPAND FIELD_CASE(UInt64, UInt64) +// This block of code is generated, do not edit it directly. + + case GPBDataTypeUInt64: + if (fieldType == GPBFieldTypeRepeated) { + uint32_t tag = field.isPackable ? GPBFieldTag(field) : 0; + GPBUInt64Array *array = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [output writeUInt64Array:fieldNumber values:array tag:tag]; + } else if (fieldType == GPBFieldTypeSingle) { + [output writeUInt64:fieldNumber + value:GPBGetMessageUInt64Field(self, field)]; + } else { // fieldType == GPBFieldTypeMap + // Exact type here doesn't matter. + GPBInt32UInt64Dictionary *dict = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [dict writeToCodedOutputStream:output asField:field]; + } + break; + +//%PDDM-EXPAND FIELD_CASE_FULL(Enum, Int32, Enum) +// This block of code is generated, do not edit it directly. + + case GPBDataTypeEnum: + if (fieldType == GPBFieldTypeRepeated) { + uint32_t tag = field.isPackable ? GPBFieldTag(field) : 0; + GPBEnumArray *array = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [output writeEnumArray:fieldNumber values:array tag:tag]; + } else if (fieldType == GPBFieldTypeSingle) { + [output writeEnum:fieldNumber + value:GPBGetMessageInt32Field(self, field)]; + } else { // fieldType == GPBFieldTypeMap + // Exact type here doesn't matter. + GPBInt32EnumDictionary *dict = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [dict writeToCodedOutputStream:output asField:field]; + } + break; + +//%PDDM-EXPAND FIELD_CASE2(Bytes) +// This block of code is generated, do not edit it directly. + + case GPBDataTypeBytes: + if (fieldType == GPBFieldTypeRepeated) { + NSArray *array = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [output writeBytesArray:fieldNumber values:array]; + } else if (fieldType == GPBFieldTypeSingle) { + // GPBGetObjectIvarWithFieldNoAutocreate() avoids doing the has check + // again. + [output writeBytes:fieldNumber + value:GPBGetObjectIvarWithFieldNoAutocreate(self, field)]; + } else { // fieldType == GPBFieldTypeMap + // Exact type here doesn't matter. + id dict = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + GPBDataType mapKeyDataType = field.mapKeyDataType; + if (mapKeyDataType == GPBDataTypeString) { + GPBDictionaryWriteToStreamInternalHelper(output, dict, field); + } else { + [dict writeToCodedOutputStream:output asField:field]; + } + } + break; + +//%PDDM-EXPAND FIELD_CASE2(String) +// This block of code is generated, do not edit it directly. + + case GPBDataTypeString: + if (fieldType == GPBFieldTypeRepeated) { + NSArray *array = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [output writeStringArray:fieldNumber values:array]; + } else if (fieldType == GPBFieldTypeSingle) { + // GPBGetObjectIvarWithFieldNoAutocreate() avoids doing the has check + // again. + [output writeString:fieldNumber + value:GPBGetObjectIvarWithFieldNoAutocreate(self, field)]; + } else { // fieldType == GPBFieldTypeMap + // Exact type here doesn't matter. + id dict = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + GPBDataType mapKeyDataType = field.mapKeyDataType; + if (mapKeyDataType == GPBDataTypeString) { + GPBDictionaryWriteToStreamInternalHelper(output, dict, field); + } else { + [dict writeToCodedOutputStream:output asField:field]; + } + } + break; + +//%PDDM-EXPAND FIELD_CASE2(Message) +// This block of code is generated, do not edit it directly. + + case GPBDataTypeMessage: + if (fieldType == GPBFieldTypeRepeated) { + NSArray *array = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [output writeMessageArray:fieldNumber values:array]; + } else if (fieldType == GPBFieldTypeSingle) { + // GPBGetObjectIvarWithFieldNoAutocreate() avoids doing the has check + // again. + [output writeMessage:fieldNumber + value:GPBGetObjectIvarWithFieldNoAutocreate(self, field)]; + } else { // fieldType == GPBFieldTypeMap + // Exact type here doesn't matter. + id dict = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + GPBDataType mapKeyDataType = field.mapKeyDataType; + if (mapKeyDataType == GPBDataTypeString) { + GPBDictionaryWriteToStreamInternalHelper(output, dict, field); + } else { + [dict writeToCodedOutputStream:output asField:field]; + } + } + break; + +//%PDDM-EXPAND FIELD_CASE2(Group) +// This block of code is generated, do not edit it directly. + + case GPBDataTypeGroup: + if (fieldType == GPBFieldTypeRepeated) { + NSArray *array = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [output writeGroupArray:fieldNumber values:array]; + } else if (fieldType == GPBFieldTypeSingle) { + // GPBGetObjectIvarWithFieldNoAutocreate() avoids doing the has check + // again. + [output writeGroup:fieldNumber + value:GPBGetObjectIvarWithFieldNoAutocreate(self, field)]; + } else { // fieldType == GPBFieldTypeMap + // Exact type here doesn't matter. + id dict = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + GPBDataType mapKeyDataType = field.mapKeyDataType; + if (mapKeyDataType == GPBDataTypeString) { + GPBDictionaryWriteToStreamInternalHelper(output, dict, field); + } else { + [dict writeToCodedOutputStream:output asField:field]; + } + } + break; + +//%PDDM-EXPAND-END (18 expansions) + } +} + +#pragma mark - Extensions + +- (id)getExtension:(GPBExtensionDescriptor *)extension { + CheckExtension(self, extension); + id value = [extensionMap_ objectForKey:extension]; + if (value != nil) { + return value; + } + + // No default for repeated. + if (extension.isRepeated) { + return nil; + } + // Non messages get their default. + if (!GPBExtensionIsMessage(extension)) { + return extension.defaultValue; + } + + // Check for an autocreated value. + GPBPrepareReadOnlySemaphore(self); + dispatch_semaphore_wait(readOnlySemaphore_, DISPATCH_TIME_FOREVER); + value = [autocreatedExtensionMap_ objectForKey:extension]; + if (!value) { + // Auto create the message extensions to match normal fields. + value = CreateMessageWithAutocreatorForExtension(extension.msgClass, self, + extension); + + if (autocreatedExtensionMap_ == nil) { + autocreatedExtensionMap_ = [[NSMutableDictionary alloc] init]; + } + + // We can't simply call setExtension here because that would clear the new + // value's autocreator. + [autocreatedExtensionMap_ setObject:value forKey:extension]; + [value release]; + } + + dispatch_semaphore_signal(readOnlySemaphore_); + return value; +} + +- (id)getExistingExtension:(GPBExtensionDescriptor *)extension { + // This is an internal method so we don't need to call CheckExtension(). + return [extensionMap_ objectForKey:extension]; +} + +- (BOOL)hasExtension:(GPBExtensionDescriptor *)extension { +#if defined(DEBUG) && DEBUG + CheckExtension(self, extension); +#endif // DEBUG + return nil != [extensionMap_ objectForKey:extension]; +} + +- (NSArray *)extensionsCurrentlySet { + return [extensionMap_ allKeys]; +} + +- (void)writeExtensionsToCodedOutputStream:(GPBCodedOutputStream *)output + range:(GPBExtensionRange)range { + NSArray *sortedExtensions = [[extensionMap_ allKeys] + sortedArrayUsingSelector:@selector(compareByFieldNumber:)]; + uint32_t start = range.start; + uint32_t end = range.end; + for (GPBExtensionDescriptor *extension in sortedExtensions) { + uint32_t fieldNumber = extension.fieldNumber; + if (fieldNumber >= start && fieldNumber < end) { + id value = [extensionMap_ objectForKey:extension]; + GPBWriteExtensionValueToOutputStream(extension, value, output); + } + } +} + +- (void)setExtension:(GPBExtensionDescriptor *)extension value:(id)value { + if (!value) { + [self clearExtension:extension]; + return; + } + + CheckExtension(self, extension); + + if (extension.repeated) { + [NSException raise:NSInvalidArgumentException + format:@"Must call addExtension() for repeated types."]; + } + + if (extensionMap_ == nil) { + extensionMap_ = [[NSMutableDictionary alloc] init]; + } + + // This pointless cast is for CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION. + // Without it, the compiler complains we're passing an id nullable when + // setObject:forKey: requires a id nonnull for the value. The check for + // !value at the start of the method ensures it isn't nil, but the check + // isn't smart enough to realize that. + [extensionMap_ setObject:(id)value forKey:extension]; + + GPBExtensionDescriptor *descriptor = extension; + + if (GPBExtensionIsMessage(descriptor) && !descriptor.isRepeated) { + GPBMessage *autocreatedValue = + [[autocreatedExtensionMap_ objectForKey:extension] retain]; + // Must remove from the map before calling GPBClearMessageAutocreator() so + // that GPBClearMessageAutocreator() knows its safe to clear. + [autocreatedExtensionMap_ removeObjectForKey:extension]; + GPBClearMessageAutocreator(autocreatedValue); + [autocreatedValue release]; + } + + GPBBecomeVisibleToAutocreator(self); +} + +- (void)addExtension:(GPBExtensionDescriptor *)extension value:(id)value { + CheckExtension(self, extension); + + if (!extension.repeated) { + [NSException raise:NSInvalidArgumentException + format:@"Must call setExtension() for singular types."]; + } + + if (extensionMap_ == nil) { + extensionMap_ = [[NSMutableDictionary alloc] init]; + } + NSMutableArray *list = [extensionMap_ objectForKey:extension]; + if (list == nil) { + list = [NSMutableArray array]; + [extensionMap_ setObject:list forKey:extension]; + } + + [list addObject:value]; + GPBBecomeVisibleToAutocreator(self); +} + +- (void)setExtension:(GPBExtensionDescriptor *)extension + index:(NSUInteger)idx + value:(id)value { + CheckExtension(self, extension); + + if (!extension.repeated) { + [NSException raise:NSInvalidArgumentException + format:@"Must call setExtension() for singular types."]; + } + + if (extensionMap_ == nil) { + extensionMap_ = [[NSMutableDictionary alloc] init]; + } + + NSMutableArray *list = [extensionMap_ objectForKey:extension]; + + [list replaceObjectAtIndex:idx withObject:value]; + GPBBecomeVisibleToAutocreator(self); +} + +- (void)clearExtension:(GPBExtensionDescriptor *)extension { + CheckExtension(self, extension); + + // Only become visible if there was actually a value to clear. + if ([extensionMap_ objectForKey:extension]) { + [extensionMap_ removeObjectForKey:extension]; + GPBBecomeVisibleToAutocreator(self); + } +} + +#pragma mark - mergeFrom + +- (void)mergeFromData:(NSData *)data + extensionRegistry:(GPBExtensionRegistry *)extensionRegistry { + GPBCodedInputStream *input = [[GPBCodedInputStream alloc] initWithData:data]; + [self mergeFromCodedInputStream:input extensionRegistry:extensionRegistry]; + [input checkLastTagWas:0]; + [input release]; +} + +#pragma mark - mergeDelimitedFrom + +- (void)mergeDelimitedFromCodedInputStream:(GPBCodedInputStream *)input + extensionRegistry:(GPBExtensionRegistry *)extensionRegistry { + GPBCodedInputStreamState *state = &input->state_; + if (GPBCodedInputStreamIsAtEnd(state)) { + return; + } + NSData *data = GPBCodedInputStreamReadRetainedBytesNoCopy(state); + if (data == nil) { + return; + } + [self mergeFromData:data extensionRegistry:extensionRegistry]; + [data release]; +} + +#pragma mark - Parse From Data Support + ++ (instancetype)parseFromData:(NSData *)data error:(NSError **)errorPtr { + return [self parseFromData:data extensionRegistry:nil error:errorPtr]; +} + ++ (instancetype)parseFromData:(NSData *)data + extensionRegistry:(GPBExtensionRegistry *)extensionRegistry + error:(NSError **)errorPtr { + return [[[self alloc] initWithData:data + extensionRegistry:extensionRegistry + error:errorPtr] autorelease]; +} + ++ (instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input + extensionRegistry:(GPBExtensionRegistry *)extensionRegistry + error:(NSError **)errorPtr { + return + [[[self alloc] initWithCodedInputStream:input + extensionRegistry:extensionRegistry + error:errorPtr] autorelease]; +} + +#pragma mark - Parse Delimited From Data Support + ++ (instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input + extensionRegistry: + (GPBExtensionRegistry *)extensionRegistry + error:(NSError **)errorPtr { + GPBMessage *message = [[[self alloc] init] autorelease]; + @try { + [message mergeDelimitedFromCodedInputStream:input + extensionRegistry:extensionRegistry]; + if (errorPtr) { + *errorPtr = nil; + } + } + @catch (NSException *exception) { + message = nil; + if (errorPtr) { + *errorPtr = ErrorFromException(exception); + } + } +#ifdef DEBUG + if (message && !message.initialized) { + message = nil; + if (errorPtr) { + *errorPtr = MessageError(GPBMessageErrorCodeMissingRequiredField, nil); + } + } +#endif + return message; +} + +#pragma mark - Unknown Field Support + +- (GPBUnknownFieldSet *)unknownFields { + return unknownFields_; +} + +- (void)setUnknownFields:(GPBUnknownFieldSet *)unknownFields { + if (unknownFields != unknownFields_) { + [unknownFields_ release]; + unknownFields_ = [unknownFields copy]; + GPBBecomeVisibleToAutocreator(self); + } +} + +- (void)parseMessageSet:(GPBCodedInputStream *)input + extensionRegistry:(GPBExtensionRegistry *)extensionRegistry { + uint32_t typeId = 0; + NSData *rawBytes = nil; + GPBExtensionDescriptor *extension = nil; + GPBCodedInputStreamState *state = &input->state_; + while (true) { + uint32_t tag = GPBCodedInputStreamReadTag(state); + if (tag == 0) { + break; + } + + if (tag == GPBWireFormatMessageSetTypeIdTag) { + typeId = GPBCodedInputStreamReadUInt32(state); + if (typeId != 0) { + extension = [extensionRegistry extensionForDescriptor:[self descriptor] + fieldNumber:typeId]; + } + } else if (tag == GPBWireFormatMessageSetMessageTag) { + rawBytes = + [GPBCodedInputStreamReadRetainedBytesNoCopy(state) autorelease]; + } else { + if (![input skipField:tag]) { + break; + } + } + } + + [input checkLastTagWas:GPBWireFormatMessageSetItemEndTag]; + + if (rawBytes != nil && typeId != 0) { + if (extension != nil) { + GPBCodedInputStream *newInput = + [[GPBCodedInputStream alloc] initWithData:rawBytes]; + GPBExtensionMergeFromInputStream(extension, + extension.packable, + newInput, + extensionRegistry, + self); + [newInput release]; + } else { + GPBUnknownFieldSet *unknownFields = GetOrMakeUnknownFields(self); + [unknownFields mergeMessageSetMessage:typeId data:rawBytes]; + } + } +} + +- (BOOL)parseUnknownField:(GPBCodedInputStream *)input + extensionRegistry:(GPBExtensionRegistry *)extensionRegistry + tag:(uint32_t)tag { + GPBWireFormat wireType = GPBWireFormatGetTagWireType(tag); + int32_t fieldNumber = GPBWireFormatGetTagFieldNumber(tag); + + GPBDescriptor *descriptor = [self descriptor]; + GPBExtensionDescriptor *extension = + [extensionRegistry extensionForDescriptor:descriptor + fieldNumber:fieldNumber]; + if (extension == nil) { + if (descriptor.wireFormat && GPBWireFormatMessageSetItemTag == tag) { + [self parseMessageSet:input extensionRegistry:extensionRegistry]; + return YES; + } + } else { + if (extension.wireType == wireType) { + GPBExtensionMergeFromInputStream(extension, + extension.packable, + input, + extensionRegistry, + self); + return YES; + } + // Primitive, repeated types can be packed on unpacked on the wire, and are + // parsed either way. + if ([extension isRepeated] && + !GPBDataTypeIsObject(extension->description_->dataType) && + (extension.alternateWireType == wireType)) { + GPBExtensionMergeFromInputStream(extension, + !extension.packable, + input, + extensionRegistry, + self); + return YES; + } + } + if ([GPBUnknownFieldSet isFieldTag:tag]) { + GPBUnknownFieldSet *unknownFields = GetOrMakeUnknownFields(self); + return [unknownFields mergeFieldFrom:tag input:input]; + } else { + return NO; + } +} + +- (void)addUnknownMapEntry:(int32_t)fieldNum value:(NSData *)data { + GPBUnknownFieldSet *unknownFields = GetOrMakeUnknownFields(self); + [unknownFields addUnknownMapEntry:fieldNum value:data]; +} + +#pragma mark - MergeFromCodedInputStream Support + +static void MergeSingleFieldFromCodedInputStream( + GPBMessage *self, GPBFieldDescriptor *field, GPBFileSyntax syntax, + GPBCodedInputStream *input, GPBExtensionRegistry *extensionRegistry) { + GPBDataType fieldDataType = GPBGetFieldDataType(field); + switch (fieldDataType) { +#define CASE_SINGLE_POD(NAME, TYPE, FUNC_TYPE) \ + case GPBDataType##NAME: { \ + TYPE val = GPBCodedInputStreamRead##NAME(&input->state_); \ + GPBSet##FUNC_TYPE##IvarWithFieldInternal(self, field, val, syntax); \ + break; \ + } +#define CASE_SINGLE_OBJECT(NAME) \ + case GPBDataType##NAME: { \ + id val = GPBCodedInputStreamReadRetained##NAME(&input->state_); \ + GPBSetRetainedObjectIvarWithFieldInternal(self, field, val, syntax); \ + break; \ + } + CASE_SINGLE_POD(Bool, BOOL, Bool) + CASE_SINGLE_POD(Fixed32, uint32_t, UInt32) + CASE_SINGLE_POD(SFixed32, int32_t, Int32) + CASE_SINGLE_POD(Float, float, Float) + CASE_SINGLE_POD(Fixed64, uint64_t, UInt64) + CASE_SINGLE_POD(SFixed64, int64_t, Int64) + CASE_SINGLE_POD(Double, double, Double) + CASE_SINGLE_POD(Int32, int32_t, Int32) + CASE_SINGLE_POD(Int64, int64_t, Int64) + CASE_SINGLE_POD(SInt32, int32_t, Int32) + CASE_SINGLE_POD(SInt64, int64_t, Int64) + CASE_SINGLE_POD(UInt32, uint32_t, UInt32) + CASE_SINGLE_POD(UInt64, uint64_t, UInt64) + CASE_SINGLE_OBJECT(Bytes) + CASE_SINGLE_OBJECT(String) +#undef CASE_SINGLE_POD +#undef CASE_SINGLE_OBJECT + + case GPBDataTypeMessage: { + if (GPBGetHasIvarField(self, field)) { + // GPBGetObjectIvarWithFieldNoAutocreate() avoids doing the has + // check again. + GPBMessage *message = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [input readMessage:message extensionRegistry:extensionRegistry]; + } else { + GPBMessage *message = [[field.msgClass alloc] init]; + [input readMessage:message extensionRegistry:extensionRegistry]; + GPBSetRetainedObjectIvarWithFieldInternal(self, field, message, syntax); + } + break; + } + + case GPBDataTypeGroup: { + if (GPBGetHasIvarField(self, field)) { + // GPBGetObjectIvarWithFieldNoAutocreate() avoids doing the has + // check again. + GPBMessage *message = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [input readGroup:GPBFieldNumber(field) + message:message + extensionRegistry:extensionRegistry]; + } else { + GPBMessage *message = [[field.msgClass alloc] init]; + [input readGroup:GPBFieldNumber(field) + message:message + extensionRegistry:extensionRegistry]; + GPBSetRetainedObjectIvarWithFieldInternal(self, field, message, syntax); + } + break; + } + + case GPBDataTypeEnum: { + int32_t val = GPBCodedInputStreamReadEnum(&input->state_); + if (GPBHasPreservingUnknownEnumSemantics(syntax) || + [field isValidEnumValue:val]) { + GPBSetInt32IvarWithFieldInternal(self, field, val, syntax); + } else { + GPBUnknownFieldSet *unknownFields = GetOrMakeUnknownFields(self); + [unknownFields mergeVarintField:GPBFieldNumber(field) value:val]; + } + } + } // switch +} + +static void MergeRepeatedPackedFieldFromCodedInputStream( + GPBMessage *self, GPBFieldDescriptor *field, GPBFileSyntax syntax, + GPBCodedInputStream *input) { + GPBDataType fieldDataType = GPBGetFieldDataType(field); + GPBCodedInputStreamState *state = &input->state_; + id genericArray = GetOrCreateArrayIvarWithField(self, field, syntax); + int32_t length = GPBCodedInputStreamReadInt32(state); + size_t limit = GPBCodedInputStreamPushLimit(state, length); + while (GPBCodedInputStreamBytesUntilLimit(state) > 0) { + switch (fieldDataType) { +#define CASE_REPEATED_PACKED_POD(NAME, TYPE, ARRAY_TYPE) \ + case GPBDataType##NAME: { \ + TYPE val = GPBCodedInputStreamRead##NAME(state); \ + [(GPB##ARRAY_TYPE##Array *)genericArray addValue:val]; \ + break; \ + } + CASE_REPEATED_PACKED_POD(Bool, BOOL, Bool) + CASE_REPEATED_PACKED_POD(Fixed32, uint32_t, UInt32) + CASE_REPEATED_PACKED_POD(SFixed32, int32_t, Int32) + CASE_REPEATED_PACKED_POD(Float, float, Float) + CASE_REPEATED_PACKED_POD(Fixed64, uint64_t, UInt64) + CASE_REPEATED_PACKED_POD(SFixed64, int64_t, Int64) + CASE_REPEATED_PACKED_POD(Double, double, Double) + CASE_REPEATED_PACKED_POD(Int32, int32_t, Int32) + CASE_REPEATED_PACKED_POD(Int64, int64_t, Int64) + CASE_REPEATED_PACKED_POD(SInt32, int32_t, Int32) + CASE_REPEATED_PACKED_POD(SInt64, int64_t, Int64) + CASE_REPEATED_PACKED_POD(UInt32, uint32_t, UInt32) + CASE_REPEATED_PACKED_POD(UInt64, uint64_t, UInt64) +#undef CASE_REPEATED_PACKED_POD + + case GPBDataTypeBytes: + case GPBDataTypeString: + case GPBDataTypeMessage: + case GPBDataTypeGroup: + NSCAssert(NO, @"Non primitive types can't be packed"); + break; + + case GPBDataTypeEnum: { + int32_t val = GPBCodedInputStreamReadEnum(state); + if (GPBHasPreservingUnknownEnumSemantics(syntax) || + [field isValidEnumValue:val]) { + [(GPBEnumArray*)genericArray addRawValue:val]; + } else { + GPBUnknownFieldSet *unknownFields = GetOrMakeUnknownFields(self); + [unknownFields mergeVarintField:GPBFieldNumber(field) value:val]; + } + break; + } + } // switch + } // while(BytesUntilLimit() > 0) + GPBCodedInputStreamPopLimit(state, limit); +} + +static void MergeRepeatedNotPackedFieldFromCodedInputStream( + GPBMessage *self, GPBFieldDescriptor *field, GPBFileSyntax syntax, + GPBCodedInputStream *input, GPBExtensionRegistry *extensionRegistry) { + GPBCodedInputStreamState *state = &input->state_; + id genericArray = GetOrCreateArrayIvarWithField(self, field, syntax); + switch (GPBGetFieldDataType(field)) { +#define CASE_REPEATED_NOT_PACKED_POD(NAME, TYPE, ARRAY_TYPE) \ + case GPBDataType##NAME: { \ + TYPE val = GPBCodedInputStreamRead##NAME(state); \ + [(GPB##ARRAY_TYPE##Array *)genericArray addValue:val]; \ + break; \ + } +#define CASE_REPEATED_NOT_PACKED_OBJECT(NAME) \ + case GPBDataType##NAME: { \ + id val = GPBCodedInputStreamReadRetained##NAME(state); \ + [(NSMutableArray*)genericArray addObject:val]; \ + [val release]; \ + break; \ + } + CASE_REPEATED_NOT_PACKED_POD(Bool, BOOL, Bool) + CASE_REPEATED_NOT_PACKED_POD(Fixed32, uint32_t, UInt32) + CASE_REPEATED_NOT_PACKED_POD(SFixed32, int32_t, Int32) + CASE_REPEATED_NOT_PACKED_POD(Float, float, Float) + CASE_REPEATED_NOT_PACKED_POD(Fixed64, uint64_t, UInt64) + CASE_REPEATED_NOT_PACKED_POD(SFixed64, int64_t, Int64) + CASE_REPEATED_NOT_PACKED_POD(Double, double, Double) + CASE_REPEATED_NOT_PACKED_POD(Int32, int32_t, Int32) + CASE_REPEATED_NOT_PACKED_POD(Int64, int64_t, Int64) + CASE_REPEATED_NOT_PACKED_POD(SInt32, int32_t, Int32) + CASE_REPEATED_NOT_PACKED_POD(SInt64, int64_t, Int64) + CASE_REPEATED_NOT_PACKED_POD(UInt32, uint32_t, UInt32) + CASE_REPEATED_NOT_PACKED_POD(UInt64, uint64_t, UInt64) + CASE_REPEATED_NOT_PACKED_OBJECT(Bytes) + CASE_REPEATED_NOT_PACKED_OBJECT(String) +#undef CASE_REPEATED_NOT_PACKED_POD +#undef CASE_NOT_PACKED_OBJECT + case GPBDataTypeMessage: { + GPBMessage *message = [[field.msgClass alloc] init]; + [input readMessage:message extensionRegistry:extensionRegistry]; + [(NSMutableArray*)genericArray addObject:message]; + [message release]; + break; + } + case GPBDataTypeGroup: { + GPBMessage *message = [[field.msgClass alloc] init]; + [input readGroup:GPBFieldNumber(field) + message:message + extensionRegistry:extensionRegistry]; + [(NSMutableArray*)genericArray addObject:message]; + [message release]; + break; + } + case GPBDataTypeEnum: { + int32_t val = GPBCodedInputStreamReadEnum(state); + if (GPBHasPreservingUnknownEnumSemantics(syntax) || + [field isValidEnumValue:val]) { + [(GPBEnumArray*)genericArray addRawValue:val]; + } else { + GPBUnknownFieldSet *unknownFields = GetOrMakeUnknownFields(self); + [unknownFields mergeVarintField:GPBFieldNumber(field) value:val]; + } + break; + } + } // switch +} + +- (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input + extensionRegistry:(GPBExtensionRegistry *)extensionRegistry { + GPBDescriptor *descriptor = [self descriptor]; + GPBFileSyntax syntax = descriptor.file.syntax; + GPBCodedInputStreamState *state = &input->state_; + uint32_t tag = 0; + NSUInteger startingIndex = 0; + NSArray *fields = descriptor->fields_; + NSUInteger numFields = fields.count; + while (YES) { + BOOL merged = NO; + tag = GPBCodedInputStreamReadTag(state); + if (tag == 0) { + break; // Reached end. + } + for (NSUInteger i = 0; i < numFields; ++i) { + if (startingIndex >= numFields) startingIndex = 0; + GPBFieldDescriptor *fieldDescriptor = fields[startingIndex]; + if (GPBFieldTag(fieldDescriptor) == tag) { + GPBFieldType fieldType = fieldDescriptor.fieldType; + if (fieldType == GPBFieldTypeSingle) { + MergeSingleFieldFromCodedInputStream(self, fieldDescriptor, syntax, + input, extensionRegistry); + // Well formed protos will only have a single field once, advance + // the starting index to the next field. + startingIndex += 1; + } else if (fieldType == GPBFieldTypeRepeated) { + if (fieldDescriptor.isPackable) { + MergeRepeatedPackedFieldFromCodedInputStream( + self, fieldDescriptor, syntax, input); + // Well formed protos will only have a repeated field that is + // packed once, advance the starting index to the next field. + startingIndex += 1; + } else { + MergeRepeatedNotPackedFieldFromCodedInputStream( + self, fieldDescriptor, syntax, input, extensionRegistry); + } + } else { // fieldType == GPBFieldTypeMap + // GPB*Dictionary or NSDictionary, exact type doesn't matter at this + // point. + id map = GetOrCreateMapIvarWithField(self, fieldDescriptor, syntax); + [input readMapEntry:map + extensionRegistry:extensionRegistry + field:fieldDescriptor + parentMessage:self]; + } + merged = YES; + break; + } else { + startingIndex += 1; + } + } // for(i < numFields) + + if (!merged && (tag != 0)) { + // Primitive, repeated types can be packed on unpacked on the wire, and + // are parsed either way. The above loop covered tag in the preferred + // for, so this need to check the alternate form. + for (NSUInteger i = 0; i < numFields; ++i) { + if (startingIndex >= numFields) startingIndex = 0; + GPBFieldDescriptor *fieldDescriptor = fields[startingIndex]; + if ((fieldDescriptor.fieldType == GPBFieldTypeRepeated) && + !GPBFieldDataTypeIsObject(fieldDescriptor) && + (GPBFieldAlternateTag(fieldDescriptor) == tag)) { + BOOL alternateIsPacked = !fieldDescriptor.isPackable; + if (alternateIsPacked) { + MergeRepeatedPackedFieldFromCodedInputStream( + self, fieldDescriptor, syntax, input); + // Well formed protos will only have a repeated field that is + // packed once, advance the starting index to the next field. + startingIndex += 1; + } else { + MergeRepeatedNotPackedFieldFromCodedInputStream( + self, fieldDescriptor, syntax, input, extensionRegistry); + } + merged = YES; + break; + } else { + startingIndex += 1; + } + } + } + + if (!merged) { + if (tag == 0) { + // zero signals EOF / limit reached + return; + } else { + if (![self parseUnknownField:input + extensionRegistry:extensionRegistry + tag:tag]) { + // it's an endgroup tag + return; + } + } + } // if(!merged) + + } // while(YES) +} + +#pragma mark - MergeFrom Support + +- (void)mergeFrom:(GPBMessage *)other { + Class selfClass = [self class]; + Class otherClass = [other class]; + if (!([selfClass isSubclassOfClass:otherClass] || + [otherClass isSubclassOfClass:selfClass])) { + [NSException raise:NSInvalidArgumentException + format:@"Classes must match %@ != %@", selfClass, otherClass]; + } + + // We assume something will be done and become visible. + GPBBecomeVisibleToAutocreator(self); + + GPBDescriptor *descriptor = [[self class] descriptor]; + GPBFileSyntax syntax = descriptor.file.syntax; + + for (GPBFieldDescriptor *field in descriptor->fields_) { + GPBFieldType fieldType = field.fieldType; + if (fieldType == GPBFieldTypeSingle) { + int32_t hasIndex = GPBFieldHasIndex(field); + uint32_t fieldNumber = GPBFieldNumber(field); + if (!GPBGetHasIvar(other, hasIndex, fieldNumber)) { + // Other doesn't have the field set, on to the next. + continue; + } + GPBDataType fieldDataType = GPBGetFieldDataType(field); + switch (fieldDataType) { + case GPBDataTypeBool: + GPBSetBoolIvarWithFieldInternal( + self, field, GPBGetMessageBoolField(other, field), syntax); + break; + case GPBDataTypeSFixed32: + case GPBDataTypeEnum: + case GPBDataTypeInt32: + case GPBDataTypeSInt32: + GPBSetInt32IvarWithFieldInternal( + self, field, GPBGetMessageInt32Field(other, field), syntax); + break; + case GPBDataTypeFixed32: + case GPBDataTypeUInt32: + GPBSetUInt32IvarWithFieldInternal( + self, field, GPBGetMessageUInt32Field(other, field), syntax); + break; + case GPBDataTypeSFixed64: + case GPBDataTypeInt64: + case GPBDataTypeSInt64: + GPBSetInt64IvarWithFieldInternal( + self, field, GPBGetMessageInt64Field(other, field), syntax); + break; + case GPBDataTypeFixed64: + case GPBDataTypeUInt64: + GPBSetUInt64IvarWithFieldInternal( + self, field, GPBGetMessageUInt64Field(other, field), syntax); + break; + case GPBDataTypeFloat: + GPBSetFloatIvarWithFieldInternal( + self, field, GPBGetMessageFloatField(other, field), syntax); + break; + case GPBDataTypeDouble: + GPBSetDoubleIvarWithFieldInternal( + self, field, GPBGetMessageDoubleField(other, field), syntax); + break; + case GPBDataTypeBytes: + case GPBDataTypeString: { + id otherVal = GPBGetObjectIvarWithFieldNoAutocreate(other, field); + GPBSetObjectIvarWithFieldInternal(self, field, otherVal, syntax); + break; + } + case GPBDataTypeMessage: + case GPBDataTypeGroup: { + id otherVal = GPBGetObjectIvarWithFieldNoAutocreate(other, field); + if (GPBGetHasIvar(self, hasIndex, fieldNumber)) { + GPBMessage *message = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + [message mergeFrom:otherVal]; + } else { + GPBMessage *message = [otherVal copy]; + GPBSetRetainedObjectIvarWithFieldInternal(self, field, message, + syntax); + } + break; + } + } // switch() + } else if (fieldType == GPBFieldTypeRepeated) { + // In the case of a list, they need to be appended, and there is no + // _hasIvar to worry about setting. + id otherArray = + GPBGetObjectIvarWithFieldNoAutocreate(other, field); + if (otherArray) { + GPBDataType fieldDataType = field->description_->dataType; + if (GPBDataTypeIsObject(fieldDataType)) { + NSMutableArray *resultArray = + GetOrCreateArrayIvarWithField(self, field, syntax); + [resultArray addObjectsFromArray:otherArray]; + } else if (fieldDataType == GPBDataTypeEnum) { + GPBEnumArray *resultArray = + GetOrCreateArrayIvarWithField(self, field, syntax); + [resultArray addRawValuesFromArray:otherArray]; + } else { + // The array type doesn't matter, that all implment + // -addValuesFromArray:. + GPBInt32Array *resultArray = + GetOrCreateArrayIvarWithField(self, field, syntax); + [resultArray addValuesFromArray:otherArray]; + } + } + } else { // fieldType = GPBFieldTypeMap + // In the case of a map, they need to be merged, and there is no + // _hasIvar to worry about setting. + id otherDict = GPBGetObjectIvarWithFieldNoAutocreate(other, field); + if (otherDict) { + GPBDataType keyDataType = field.mapKeyDataType; + GPBDataType valueDataType = field->description_->dataType; + if (GPBDataTypeIsObject(keyDataType) && + GPBDataTypeIsObject(valueDataType)) { + NSMutableDictionary *resultDict = + GetOrCreateMapIvarWithField(self, field, syntax); + [resultDict addEntriesFromDictionary:otherDict]; + } else if (valueDataType == GPBDataTypeEnum) { + // The exact type doesn't matter, just need to know it is a + // GPB*EnumDictionary. + GPBInt32EnumDictionary *resultDict = + GetOrCreateMapIvarWithField(self, field, syntax); + [resultDict addRawEntriesFromDictionary:otherDict]; + } else { + // The exact type doesn't matter, they all implement + // -addEntriesFromDictionary:. + GPBInt32Int32Dictionary *resultDict = + GetOrCreateMapIvarWithField(self, field, syntax); + [resultDict addEntriesFromDictionary:otherDict]; + } + } + } // if (fieldType)..else if...else + } // for(fields) + + // Unknown fields. + if (!unknownFields_) { + [self setUnknownFields:other.unknownFields]; + } else { + [unknownFields_ mergeUnknownFields:other.unknownFields]; + } + + // Extensions + + if (other->extensionMap_.count == 0) { + return; + } + + if (extensionMap_ == nil) { + extensionMap_ = + CloneExtensionMap(other->extensionMap_, NSZoneFromPointer(self)); + } else { + for (GPBExtensionDescriptor *extension in other->extensionMap_) { + id otherValue = [other->extensionMap_ objectForKey:extension]; + id value = [extensionMap_ objectForKey:extension]; + BOOL isMessageExtension = GPBExtensionIsMessage(extension); + + if (extension.repeated) { + NSMutableArray *list = value; + if (list == nil) { + list = [[NSMutableArray alloc] init]; + [extensionMap_ setObject:list forKey:extension]; + [list release]; + } + if (isMessageExtension) { + for (GPBMessage *otherListValue in otherValue) { + GPBMessage *copiedValue = [otherListValue copy]; + [list addObject:copiedValue]; + [copiedValue release]; + } + } else { + [list addObjectsFromArray:otherValue]; + } + } else { + if (isMessageExtension) { + if (value) { + [(GPBMessage *)value mergeFrom:(GPBMessage *)otherValue]; + } else { + GPBMessage *copiedValue = [otherValue copy]; + [extensionMap_ setObject:copiedValue forKey:extension]; + [copiedValue release]; + } + } else { + [extensionMap_ setObject:otherValue forKey:extension]; + } + } + + if (isMessageExtension && !extension.isRepeated) { + GPBMessage *autocreatedValue = + [[autocreatedExtensionMap_ objectForKey:extension] retain]; + // Must remove from the map before calling GPBClearMessageAutocreator() + // so that GPBClearMessageAutocreator() knows its safe to clear. + [autocreatedExtensionMap_ removeObjectForKey:extension]; + GPBClearMessageAutocreator(autocreatedValue); + [autocreatedValue release]; + } + } + } +} + +#pragma mark - isEqual: & hash Support + +- (BOOL)isEqual:(id)other { + if (other == self) { + return YES; + } + if (![other isKindOfClass:[self class]] && + ![self isKindOfClass:[other class]]) { + return NO; + } + + GPBMessage *otherMsg = other; + GPBDescriptor *descriptor = [[self class] descriptor]; + uint8_t *selfStorage = (uint8_t *)messageStorage_; + uint8_t *otherStorage = (uint8_t *)otherMsg->messageStorage_; + + for (GPBFieldDescriptor *field in descriptor->fields_) { + if (GPBFieldIsMapOrArray(field)) { + // In the case of a list or map, there is no _hasIvar to worry about. + // NOTE: These are NSArray/GPB*Array or NSDictionary/GPB*Dictionary, but + // the type doesn't really matter as the objects all support -count and + // -isEqual:. + NSArray *resultMapOrArray = + GPBGetObjectIvarWithFieldNoAutocreate(self, field); + NSArray *otherMapOrArray = + GPBGetObjectIvarWithFieldNoAutocreate(other, field); + // nil and empty are equal + if (resultMapOrArray.count != 0 || otherMapOrArray.count != 0) { + if (![resultMapOrArray isEqual:otherMapOrArray]) { + return NO; + } + } + } else { // Single field + int32_t hasIndex = GPBFieldHasIndex(field); + uint32_t fieldNum = GPBFieldNumber(field); + BOOL selfHas = GPBGetHasIvar(self, hasIndex, fieldNum); + BOOL otherHas = GPBGetHasIvar(other, hasIndex, fieldNum); + if (selfHas != otherHas) { + return NO; // Differing has values, not equal. + } + if (!selfHas) { + // Same has values, was no, nothing else to check for this field. + continue; + } + // Now compare the values. + GPBDataType fieldDataType = GPBGetFieldDataType(field); + size_t fieldOffset = field->description_->offset; + switch (fieldDataType) { + case GPBDataTypeBool: { + // Bools are stored in has_bits to avoid needing explicit space in + // the storage structure. + // (the field number passed to the HasIvar helper doesn't really + // matter since the offset is never negative) + BOOL selfValue = GPBGetHasIvar(self, (int32_t)(fieldOffset), 0); + BOOL otherValue = GPBGetHasIvar(other, (int32_t)(fieldOffset), 0); + if (selfValue != otherValue) { + return NO; + } + break; + } + case GPBDataTypeSFixed32: + case GPBDataTypeInt32: + case GPBDataTypeSInt32: + case GPBDataTypeEnum: + case GPBDataTypeFixed32: + case GPBDataTypeUInt32: + case GPBDataTypeFloat: { + GPBInternalCompileAssert(sizeof(float) == sizeof(uint32_t), float_not_32_bits); + // These are all 32bit, signed/unsigned doesn't matter for equality. + uint32_t *selfValPtr = (uint32_t *)&selfStorage[fieldOffset]; + uint32_t *otherValPtr = (uint32_t *)&otherStorage[fieldOffset]; + if (*selfValPtr != *otherValPtr) { + return NO; + } + break; + } + case GPBDataTypeSFixed64: + case GPBDataTypeInt64: + case GPBDataTypeSInt64: + case GPBDataTypeFixed64: + case GPBDataTypeUInt64: + case GPBDataTypeDouble: { + GPBInternalCompileAssert(sizeof(double) == sizeof(uint64_t), double_not_64_bits); + // These are all 64bit, signed/unsigned doesn't matter for equality. + uint64_t *selfValPtr = (uint64_t *)&selfStorage[fieldOffset]; + uint64_t *otherValPtr = (uint64_t *)&otherStorage[fieldOffset]; + if (*selfValPtr != *otherValPtr) { + return NO; + } + break; + } + case GPBDataTypeBytes: + case GPBDataTypeString: + case GPBDataTypeMessage: + case GPBDataTypeGroup: { + // Type doesn't matter here, they all implement -isEqual:. + id *selfValPtr = (id *)&selfStorage[fieldOffset]; + id *otherValPtr = (id *)&otherStorage[fieldOffset]; + if (![*selfValPtr isEqual:*otherValPtr]) { + return NO; + } + break; + } + } // switch() + } // if(mapOrArray)...else + } // for(fields) + + // nil and empty are equal + if (extensionMap_.count != 0 || otherMsg->extensionMap_.count != 0) { + if (![extensionMap_ isEqual:otherMsg->extensionMap_]) { + return NO; + } + } + + // nil and empty are equal + GPBUnknownFieldSet *otherUnknowns = otherMsg->unknownFields_; + if ([unknownFields_ countOfFields] != 0 || + [otherUnknowns countOfFields] != 0) { + if (![unknownFields_ isEqual:otherUnknowns]) { + return NO; + } + } + + return YES; +} + +// It is very difficult to implement a generic hash for ProtoBuf messages that +// will perform well. If you need hashing on your ProtoBufs (eg you are using +// them as dictionary keys) you will probably want to implement a ProtoBuf +// message specific hash as a category on your protobuf class. Do not make it a +// category on GPBMessage as you will conflict with this hash, and will possibly +// override hash for all generated protobufs. A good implementation of hash will +// be really fast, so we would recommend only hashing protobufs that have an +// identifier field of some kind that you can easily hash. If you implement +// hash, we would strongly recommend overriding isEqual: in your category as +// well, as the default implementation of isEqual: is extremely slow, and may +// drastically affect performance in large sets. +- (NSUInteger)hash { + GPBDescriptor *descriptor = [[self class] descriptor]; + const NSUInteger prime = 19; + uint8_t *storage = (uint8_t *)messageStorage_; + + // Start with the descriptor and then mix it with some instance info. + // Hopefully that will give a spread based on classes and what fields are set. + NSUInteger result = (NSUInteger)descriptor; + + for (GPBFieldDescriptor *field in descriptor->fields_) { + if (GPBFieldIsMapOrArray(field)) { + // Exact type doesn't matter, just check if there are any elements. + NSArray *mapOrArray = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + NSUInteger count = mapOrArray.count; + if (count) { + // NSArray/NSDictionary use count, use the field number and the count. + result = prime * result + GPBFieldNumber(field); + result = prime * result + count; + } + } else if (GPBGetHasIvarField(self, field)) { + // Just using the field number seemed simple/fast, but then a small + // message class where all the same fields are always set (to different + // things would end up all with the same hash, so pull in some data). + GPBDataType fieldDataType = GPBGetFieldDataType(field); + size_t fieldOffset = field->description_->offset; + switch (fieldDataType) { + case GPBDataTypeBool: { + // Bools are stored in has_bits to avoid needing explicit space in + // the storage structure. + // (the field number passed to the HasIvar helper doesn't really + // matter since the offset is never negative) + BOOL value = GPBGetHasIvar(self, (int32_t)(fieldOffset), 0); + result = prime * result + value; + break; + } + case GPBDataTypeSFixed32: + case GPBDataTypeInt32: + case GPBDataTypeSInt32: + case GPBDataTypeEnum: + case GPBDataTypeFixed32: + case GPBDataTypeUInt32: + case GPBDataTypeFloat: { + GPBInternalCompileAssert(sizeof(float) == sizeof(uint32_t), float_not_32_bits); + // These are all 32bit, just mix it in. + uint32_t *valPtr = (uint32_t *)&storage[fieldOffset]; + result = prime * result + *valPtr; + break; + } + case GPBDataTypeSFixed64: + case GPBDataTypeInt64: + case GPBDataTypeSInt64: + case GPBDataTypeFixed64: + case GPBDataTypeUInt64: + case GPBDataTypeDouble: { + GPBInternalCompileAssert(sizeof(double) == sizeof(uint64_t), double_not_64_bits); + // These are all 64bit, just mix what fits into an NSUInteger in. + uint64_t *valPtr = (uint64_t *)&storage[fieldOffset]; + result = prime * result + (NSUInteger)(*valPtr); + break; + } + case GPBDataTypeBytes: + case GPBDataTypeString: { + // Type doesn't matter here, they both implement -hash:. + id *valPtr = (id *)&storage[fieldOffset]; + result = prime * result + [*valPtr hash]; + break; + } + + case GPBDataTypeMessage: + case GPBDataTypeGroup: { + GPBMessage **valPtr = (GPBMessage **)&storage[fieldOffset]; + // Could call -hash on the sub message, but that could recurse pretty + // deep; follow the lead of NSArray/NSDictionary and don't really + // recurse for hash, instead use the field number and the descriptor + // of the sub message. Yes, this could suck for a bunch of messages + // where they all only differ in the sub messages, but if you are + // using a message with sub messages for something that needs -hash, + // odds are you are also copying them as keys, and that deep copy + // will also suck. + result = prime * result + GPBFieldNumber(field); + result = prime * result + (NSUInteger)[[*valPtr class] descriptor]; + break; + } + } // switch() + } + } + + // Unknowns and extensions are not included. + + return result; +} + +#pragma mark - Description Support + +- (NSString *)description { + NSString *textFormat = GPBTextFormatForMessage(self, @" "); + NSString *description = [NSString + stringWithFormat:@"<%@ %p>: {\n%@}", [self class], self, textFormat]; + return description; +} + +#if defined(DEBUG) && DEBUG + +// Xcode 5.1 added support for custom quick look info. +// https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/CustomClassDisplay_in_QuickLook/CH01-quick_look_for_custom_objects/CH01-quick_look_for_custom_objects.html#//apple_ref/doc/uid/TP40014001-CH2-SW1 +- (id)debugQuickLookObject { + return GPBTextFormatForMessage(self, nil); +} + +#endif // DEBUG + +#pragma mark - SerializedSize + +- (size_t)serializedSize { + GPBDescriptor *descriptor = [[self class] descriptor]; + size_t result = 0; + + // Has check is done explicitly, so GPBGetObjectIvarWithFieldNoAutocreate() + // avoids doing the has check again. + + // Fields. + for (GPBFieldDescriptor *fieldDescriptor in descriptor->fields_) { + GPBFieldType fieldType = fieldDescriptor.fieldType; + GPBDataType fieldDataType = GPBGetFieldDataType(fieldDescriptor); + + // Single Fields + if (fieldType == GPBFieldTypeSingle) { + BOOL selfHas = GPBGetHasIvarField(self, fieldDescriptor); + if (!selfHas) { + continue; // Nothing to do. + } + + uint32_t fieldNumber = GPBFieldNumber(fieldDescriptor); + + switch (fieldDataType) { +#define CASE_SINGLE_POD(NAME, TYPE, FUNC_TYPE) \ + case GPBDataType##NAME: { \ + TYPE fieldVal = GPBGetMessage##FUNC_TYPE##Field(self, fieldDescriptor); \ + result += GPBCompute##NAME##Size(fieldNumber, fieldVal); \ + break; \ + } +#define CASE_SINGLE_OBJECT(NAME) \ + case GPBDataType##NAME: { \ + id fieldVal = GPBGetObjectIvarWithFieldNoAutocreate(self, fieldDescriptor); \ + result += GPBCompute##NAME##Size(fieldNumber, fieldVal); \ + break; \ + } + CASE_SINGLE_POD(Bool, BOOL, Bool) + CASE_SINGLE_POD(Fixed32, uint32_t, UInt32) + CASE_SINGLE_POD(SFixed32, int32_t, Int32) + CASE_SINGLE_POD(Float, float, Float) + CASE_SINGLE_POD(Fixed64, uint64_t, UInt64) + CASE_SINGLE_POD(SFixed64, int64_t, Int64) + CASE_SINGLE_POD(Double, double, Double) + CASE_SINGLE_POD(Int32, int32_t, Int32) + CASE_SINGLE_POD(Int64, int64_t, Int64) + CASE_SINGLE_POD(SInt32, int32_t, Int32) + CASE_SINGLE_POD(SInt64, int64_t, Int64) + CASE_SINGLE_POD(UInt32, uint32_t, UInt32) + CASE_SINGLE_POD(UInt64, uint64_t, UInt64) + CASE_SINGLE_OBJECT(Bytes) + CASE_SINGLE_OBJECT(String) + CASE_SINGLE_OBJECT(Message) + CASE_SINGLE_OBJECT(Group) + CASE_SINGLE_POD(Enum, int32_t, Int32) +#undef CASE_SINGLE_POD +#undef CASE_SINGLE_OBJECT + } + + // Repeated Fields + } else if (fieldType == GPBFieldTypeRepeated) { + id genericArray = + GPBGetObjectIvarWithFieldNoAutocreate(self, fieldDescriptor); + NSUInteger count = [genericArray count]; + if (count == 0) { + continue; // Nothing to add. + } + __block size_t dataSize = 0; + + switch (fieldDataType) { +#define CASE_REPEATED_POD(NAME, TYPE, ARRAY_TYPE) \ + CASE_REPEATED_POD_EXTRA(NAME, TYPE, ARRAY_TYPE, ) +#define CASE_REPEATED_POD_EXTRA(NAME, TYPE, ARRAY_TYPE, ARRAY_ACCESSOR_NAME) \ + case GPBDataType##NAME: { \ + GPB##ARRAY_TYPE##Array *array = genericArray; \ + [array enumerate##ARRAY_ACCESSOR_NAME##ValuesWithBlock:^(TYPE value, NSUInteger idx, BOOL *stop) { \ + _Pragma("unused(idx, stop)"); \ + dataSize += GPBCompute##NAME##SizeNoTag(value); \ + }]; \ + break; \ + } +#define CASE_REPEATED_OBJECT(NAME) \ + case GPBDataType##NAME: { \ + for (id value in genericArray) { \ + dataSize += GPBCompute##NAME##SizeNoTag(value); \ + } \ + break; \ + } + CASE_REPEATED_POD(Bool, BOOL, Bool) + CASE_REPEATED_POD(Fixed32, uint32_t, UInt32) + CASE_REPEATED_POD(SFixed32, int32_t, Int32) + CASE_REPEATED_POD(Float, float, Float) + CASE_REPEATED_POD(Fixed64, uint64_t, UInt64) + CASE_REPEATED_POD(SFixed64, int64_t, Int64) + CASE_REPEATED_POD(Double, double, Double) + CASE_REPEATED_POD(Int32, int32_t, Int32) + CASE_REPEATED_POD(Int64, int64_t, Int64) + CASE_REPEATED_POD(SInt32, int32_t, Int32) + CASE_REPEATED_POD(SInt64, int64_t, Int64) + CASE_REPEATED_POD(UInt32, uint32_t, UInt32) + CASE_REPEATED_POD(UInt64, uint64_t, UInt64) + CASE_REPEATED_OBJECT(Bytes) + CASE_REPEATED_OBJECT(String) + CASE_REPEATED_OBJECT(Message) + CASE_REPEATED_OBJECT(Group) + CASE_REPEATED_POD_EXTRA(Enum, int32_t, Enum, Raw) +#undef CASE_REPEATED_POD +#undef CASE_REPEATED_POD_EXTRA +#undef CASE_REPEATED_OBJECT + } // switch + result += dataSize; + size_t tagSize = GPBComputeTagSize(GPBFieldNumber(fieldDescriptor)); + if (fieldDataType == GPBDataTypeGroup) { + // Groups have both a start and an end tag. + tagSize *= 2; + } + if (fieldDescriptor.isPackable) { + result += tagSize; + result += GPBComputeSizeTSizeAsInt32NoTag(dataSize); + } else { + result += count * tagSize; + } + + // Map<> Fields + } else { // fieldType == GPBFieldTypeMap + if (GPBDataTypeIsObject(fieldDataType) && + (fieldDescriptor.mapKeyDataType == GPBDataTypeString)) { + // If key type was string, then the map is an NSDictionary. + NSDictionary *map = + GPBGetObjectIvarWithFieldNoAutocreate(self, fieldDescriptor); + if (map) { + result += GPBDictionaryComputeSizeInternalHelper(map, fieldDescriptor); + } + } else { + // Type will be GPB*GroupDictionary, exact type doesn't matter. + GPBInt32Int32Dictionary *map = + GPBGetObjectIvarWithFieldNoAutocreate(self, fieldDescriptor); + result += [map computeSerializedSizeAsField:fieldDescriptor]; + } + } + } // for(fields) + + // Add any unknown fields. + if (descriptor.wireFormat) { + result += [unknownFields_ serializedSizeAsMessageSet]; + } else { + result += [unknownFields_ serializedSize]; + } + + // Add any extensions. + for (GPBExtensionDescriptor *extension in extensionMap_) { + id value = [extensionMap_ objectForKey:extension]; + result += GPBComputeExtensionSerializedSizeIncludingTag(extension, value); + } + + return result; +} + +#pragma mark - Resolve Methods Support + +typedef struct ResolveIvarAccessorMethodResult { + IMP impToAdd; + SEL encodingSelector; +} ResolveIvarAccessorMethodResult; + +static void ResolveIvarGet(GPBFieldDescriptor *field, + ResolveIvarAccessorMethodResult *result) { + GPBDataType fieldDataType = GPBGetFieldDataType(field); + switch (fieldDataType) { +#define CASE_GET(NAME, TYPE, TRUE_NAME) \ + case GPBDataType##NAME: { \ + result->impToAdd = imp_implementationWithBlock(^(id obj) { \ + return GPBGetMessage##TRUE_NAME##Field(obj, field); \ + }); \ + result->encodingSelector = @selector(get##NAME); \ + break; \ + } +#define CASE_GET_OBJECT(NAME, TYPE, TRUE_NAME) \ + case GPBDataType##NAME: { \ + result->impToAdd = imp_implementationWithBlock(^(id obj) { \ + return GPBGetObjectIvarWithField(obj, field); \ + }); \ + result->encodingSelector = @selector(get##NAME); \ + break; \ + } + CASE_GET(Bool, BOOL, Bool) + CASE_GET(Fixed32, uint32_t, UInt32) + CASE_GET(SFixed32, int32_t, Int32) + CASE_GET(Float, float, Float) + CASE_GET(Fixed64, uint64_t, UInt64) + CASE_GET(SFixed64, int64_t, Int64) + CASE_GET(Double, double, Double) + CASE_GET(Int32, int32_t, Int32) + CASE_GET(Int64, int64_t, Int64) + CASE_GET(SInt32, int32_t, Int32) + CASE_GET(SInt64, int64_t, Int64) + CASE_GET(UInt32, uint32_t, UInt32) + CASE_GET(UInt64, uint64_t, UInt64) + CASE_GET_OBJECT(Bytes, id, Object) + CASE_GET_OBJECT(String, id, Object) + CASE_GET_OBJECT(Message, id, Object) + CASE_GET_OBJECT(Group, id, Object) + CASE_GET(Enum, int32_t, Enum) +#undef CASE_GET + } +} + +static void ResolveIvarSet(GPBFieldDescriptor *field, + GPBFileSyntax syntax, + ResolveIvarAccessorMethodResult *result) { + GPBDataType fieldDataType = GPBGetFieldDataType(field); + switch (fieldDataType) { +#define CASE_SET(NAME, TYPE, TRUE_NAME) \ + case GPBDataType##NAME: { \ + result->impToAdd = imp_implementationWithBlock(^(id obj, TYPE value) { \ + return GPBSet##TRUE_NAME##IvarWithFieldInternal(obj, field, value, syntax); \ + }); \ + result->encodingSelector = @selector(set##NAME:); \ + break; \ + } + CASE_SET(Bool, BOOL, Bool) + CASE_SET(Fixed32, uint32_t, UInt32) + CASE_SET(SFixed32, int32_t, Int32) + CASE_SET(Float, float, Float) + CASE_SET(Fixed64, uint64_t, UInt64) + CASE_SET(SFixed64, int64_t, Int64) + CASE_SET(Double, double, Double) + CASE_SET(Int32, int32_t, Int32) + CASE_SET(Int64, int64_t, Int64) + CASE_SET(SInt32, int32_t, Int32) + CASE_SET(SInt64, int64_t, Int64) + CASE_SET(UInt32, uint32_t, UInt32) + CASE_SET(UInt64, uint64_t, UInt64) + CASE_SET(Bytes, id, Object) + CASE_SET(String, id, Object) + CASE_SET(Message, id, Object) + CASE_SET(Group, id, Object) + CASE_SET(Enum, int32_t, Enum) +#undef CASE_SET + } +} + ++ (BOOL)resolveInstanceMethod:(SEL)sel { + const GPBDescriptor *descriptor = [self descriptor]; + if (!descriptor) { + return [super resolveInstanceMethod:sel]; + } + + // NOTE: hasOrCountSel_/setHasSel_ will be NULL if the field for the given + // message should not have has support (done in GPBDescriptor.m), so there is + // no need for checks here to see if has*/setHas* are allowed. + + ResolveIvarAccessorMethodResult result = {NULL, NULL}; + for (GPBFieldDescriptor *field in descriptor->fields_) { + BOOL isMapOrArray = GPBFieldIsMapOrArray(field); + if (!isMapOrArray) { + // Single fields. + if (sel == field->getSel_) { + ResolveIvarGet(field, &result); + break; + } else if (sel == field->setSel_) { + ResolveIvarSet(field, descriptor.file.syntax, &result); + break; + } else if (sel == field->hasOrCountSel_) { + int32_t index = GPBFieldHasIndex(field); + uint32_t fieldNum = GPBFieldNumber(field); + result.impToAdd = imp_implementationWithBlock(^(id obj) { + return GPBGetHasIvar(obj, index, fieldNum); + }); + result.encodingSelector = @selector(getBool); + break; + } else if (sel == field->setHasSel_) { + result.impToAdd = imp_implementationWithBlock(^(id obj, BOOL value) { + if (value) { + [NSException raise:NSInvalidArgumentException + format:@"%@: %@ can only be set to NO (to clear field).", + [obj class], + NSStringFromSelector(field->setHasSel_)]; + } + GPBClearMessageField(obj, field); + }); + result.encodingSelector = @selector(setBool:); + break; + } else { + GPBOneofDescriptor *oneof = field->containingOneof_; + if (oneof && (sel == oneof->caseSel_)) { + int32_t index = GPBFieldHasIndex(field); + result.impToAdd = imp_implementationWithBlock(^(id obj) { + return GPBGetHasOneof(obj, index); + }); + result.encodingSelector = @selector(getEnum); + break; + } + } + } else { + // map<>/repeated fields. + if (sel == field->getSel_) { + if (field.fieldType == GPBFieldTypeRepeated) { + result.impToAdd = imp_implementationWithBlock(^(id obj) { + return GetArrayIvarWithField(obj, field); + }); + } else { + result.impToAdd = imp_implementationWithBlock(^(id obj) { + return GetMapIvarWithField(obj, field); + }); + } + result.encodingSelector = @selector(getArray); + break; + } else if (sel == field->setSel_) { + // Local for syntax so the block can directly capture it and not the + // full lookup. + const GPBFileSyntax syntax = descriptor.file.syntax; + result.impToAdd = imp_implementationWithBlock(^(id obj, id value) { + return GPBSetObjectIvarWithFieldInternal(obj, field, value, syntax); + }); + result.encodingSelector = @selector(setArray:); + break; + } else if (sel == field->hasOrCountSel_) { + result.impToAdd = imp_implementationWithBlock(^(id obj) { + // Type doesn't matter, all *Array and *Dictionary types support + // -count. + NSArray *arrayOrMap = + GPBGetObjectIvarWithFieldNoAutocreate(obj, field); + return [arrayOrMap count]; + }); + result.encodingSelector = @selector(getArrayCount); + break; + } + } + } + if (result.impToAdd) { + const char *encoding = + GPBMessageEncodingForSelector(result.encodingSelector, YES); + Class msgClass = descriptor.messageClass; + BOOL methodAdded = class_addMethod(msgClass, sel, result.impToAdd, encoding); + // class_addMethod() is documented as also failing if the method was already + // added; so we check if the method is already there and return success so + // the method dispatch will still happen. Why would it already be added? + // Two threads could cause the same method to be bound at the same time, + // but only one will actually bind it; the other still needs to return true + // so things will dispatch. + if (!methodAdded) { + methodAdded = GPBClassHasSel(msgClass, sel); + } + return methodAdded; + } + return [super resolveInstanceMethod:sel]; +} + ++ (BOOL)resolveClassMethod:(SEL)sel { + // Extensions scoped to a Message and looked up via class methods. + if (GPBResolveExtensionClassMethod([self descriptor].messageClass, sel)) { + return YES; + } + return [super resolveClassMethod:sel]; +} + +#pragma mark - NSCoding Support + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (instancetype)initWithCoder:(NSCoder *)aDecoder { + self = [self init]; + if (self) { + NSData *data = + [aDecoder decodeObjectOfClass:[NSData class] forKey:kGPBDataCoderKey]; + if (data.length) { + [self mergeFromData:data extensionRegistry:nil]; + } + } + return self; +} + +- (void)encodeWithCoder:(NSCoder *)aCoder { + NSData *data = [self data]; + if (data.length) { + [aCoder encodeObject:data forKey:kGPBDataCoderKey]; + } +} + +#pragma mark - KVC Support + ++ (BOOL)accessInstanceVariablesDirectly { + // Make sure KVC doesn't use instance variables. + return NO; +} + +@end + +#pragma mark - Messages from GPBUtilities.h but defined here for access to helpers. + +// Only exists for public api, no core code should use this. +id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field) { +#if defined(DEBUG) && DEBUG + if (field.fieldType != GPBFieldTypeRepeated) { + [NSException raise:NSInvalidArgumentException + format:@"%@.%@ is not a repeated field.", + [self class], field.name]; + } +#endif + GPBDescriptor *descriptor = [[self class] descriptor]; + GPBFileSyntax syntax = descriptor.file.syntax; + return GetOrCreateArrayIvarWithField(self, field, syntax); +} + +// Only exists for public api, no core code should use this. +id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field) { +#if defined(DEBUG) && DEBUG + if (field.fieldType != GPBFieldTypeMap) { + [NSException raise:NSInvalidArgumentException + format:@"%@.%@ is not a map<> field.", + [self class], field.name]; + } +#endif + GPBDescriptor *descriptor = [[self class] descriptor]; + GPBFileSyntax syntax = descriptor.file.syntax; + return GetOrCreateMapIvarWithField(self, field, syntax); +} + +#pragma clang diagnostic pop diff --git a/Pods/Protobuf/objectivec/GPBMessage_PackagePrivate.h b/Pods/Protobuf/objectivec/GPBMessage_PackagePrivate.h new file mode 100644 index 0000000..90834d4 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBMessage_PackagePrivate.h @@ -0,0 +1,134 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// This header is private to the ProtobolBuffers library and must NOT be +// included by any sources outside this library. The contents of this file are +// subject to change at any time without notice. + +#import "GPBMessage.h" + +#import + +#import "GPBBootstrap.h" + +typedef struct GPBMessage_Storage { + uint32_t _has_storage_[0]; +} GPBMessage_Storage; + +typedef struct GPBMessage_Storage *GPBMessage_StoragePtr; + +@interface GPBMessage () { + @package + // NOTE: Because of the +allocWithZone code using NSAllocateObject(), + // this structure should ideally always be kept pointer aligned where the + // real storage starts is also pointer aligned. The compiler/runtime already + // do this, but it may not be documented. + + // A pointer to the actual fields of the subclasses. The actual structure + // pointed to by this pointer will depend on the subclass. + // All of the actual structures will start the same as + // GPBMessage_Storage with _has_storage__ as the first field. + // Kept public because static functions need to access it. + GPBMessage_StoragePtr messageStorage_; + + // A lock to provide mutual exclusion from internal data that can be modified + // by *read* operations such as getters (autocreation of message fields and + // message extensions, not setting of values). Used to guarantee thread safety + // for concurrent reads on the message. + // NOTE: OSSpinLock may seem like a good fit here but Apple engineers have + // pointed out that they are vulnerable to live locking on iOS in cases of + // priority inversion: + // http://mjtsai.com/blog/2015/12/16/osspinlock-is-unsafe/ + // https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000372.html + // Use of readOnlySemaphore_ must be prefaced by a call to + // GPBPrepareReadOnlySemaphore to ensure it has been created. This allows + // readOnlySemaphore_ to be only created when actually needed. + dispatch_semaphore_t readOnlySemaphore_; +} + +// Gets an extension value without autocreating the result if not found. (i.e. +// returns nil if the extension is not set) +- (id)getExistingExtension:(GPBExtensionDescriptor *)extension; + +// Parses a message of this type from the input and merges it with this +// message. +// +// Warning: This does not verify that all required fields are present in +// the input message. +// Note: The caller should call +// -[CodedInputStream checkLastTagWas:] after calling this to +// verify that the last tag seen was the appropriate end-group tag, +// or zero for EOF. +// NOTE: This will throw if there is an error while parsing. +- (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input + extensionRegistry:(GPBExtensionRegistry *)extensionRegistry; + +// Parses the next delimited message of this type from the input and merges it +// with this message. +- (void)mergeDelimitedFromCodedInputStream:(GPBCodedInputStream *)input + extensionRegistry: + (GPBExtensionRegistry *)extensionRegistry; + +- (void)addUnknownMapEntry:(int32_t)fieldNum value:(NSData *)data; + +@end + +CF_EXTERN_C_BEGIN + + +// Call this before using the readOnlySemaphore_. This ensures it is created only once. +void GPBPrepareReadOnlySemaphore(GPBMessage *self); + +// Returns a new instance that was automatically created by |autocreator| for +// its field |field|. +GPBMessage *GPBCreateMessageWithAutocreator(Class msgClass, + GPBMessage *autocreator, + GPBFieldDescriptor *field) + __attribute__((ns_returns_retained)); + +// Returns whether |message| autocreated this message. This is NO if the message +// was not autocreated by |message| or if it has been mutated since +// autocreation. +BOOL GPBWasMessageAutocreatedBy(GPBMessage *message, GPBMessage *parent); + +// Call this when you mutate a message. It will cause the message to become +// visible to its autocreator. +void GPBBecomeVisibleToAutocreator(GPBMessage *self); + +// Call this when an array/dictionary is mutated so the parent message that +// autocreated it can react. +void GPBAutocreatedArrayModified(GPBMessage *self, id array); +void GPBAutocreatedDictionaryModified(GPBMessage *self, id dictionary); + +// Clear the autocreator, if any. Asserts if the autocreator still has an +// autocreated reference to this message. +void GPBClearMessageAutocreator(GPBMessage *self); + +CF_EXTERN_C_END diff --git a/Pods/Protobuf/objectivec/GPBProtocolBuffers.h b/Pods/Protobuf/objectivec/GPBProtocolBuffers.h new file mode 100644 index 0000000..68d8854 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBProtocolBuffers.h @@ -0,0 +1,76 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import "GPBBootstrap.h" + +#import "GPBArray.h" +#import "GPBCodedInputStream.h" +#import "GPBCodedOutputStream.h" +#import "GPBDescriptor.h" +#import "GPBDictionary.h" +#import "GPBExtensionRegistry.h" +#import "GPBMessage.h" +#import "GPBRootObject.h" +#import "GPBUnknownField.h" +#import "GPBUnknownFieldSet.h" +#import "GPBUtilities.h" +#import "GPBWellKnownTypes.h" +#import "GPBWireFormat.h" + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +// Well-known proto types +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import + #import + #import + #import + #import + #import + #import + #import + #import + #import +#else + #import "google/protobuf/Any.pbobjc.h" + #import "google/protobuf/Api.pbobjc.h" + #import "google/protobuf/Duration.pbobjc.h" + #import "google/protobuf/Empty.pbobjc.h" + #import "google/protobuf/FieldMask.pbobjc.h" + #import "google/protobuf/SourceContext.pbobjc.h" + #import "google/protobuf/Struct.pbobjc.h" + #import "google/protobuf/Timestamp.pbobjc.h" + #import "google/protobuf/Type.pbobjc.h" + #import "google/protobuf/Wrappers.pbobjc.h" +#endif diff --git a/Pods/Protobuf/objectivec/GPBProtocolBuffers_RuntimeSupport.h b/Pods/Protobuf/objectivec/GPBProtocolBuffers_RuntimeSupport.h new file mode 100644 index 0000000..fea75b9 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBProtocolBuffers_RuntimeSupport.h @@ -0,0 +1,40 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// This header is meant to only be used by the generated source, it should not +// be included in code using protocol buffers. + +#import "GPBProtocolBuffers.h" + +#import "GPBDescriptor_PackagePrivate.h" +#import "GPBExtensionInternals.h" +#import "GPBMessage_PackagePrivate.h" +#import "GPBRootObject_PackagePrivate.h" +#import "GPBUtilities_PackagePrivate.h" diff --git a/Pods/Protobuf/objectivec/GPBRootObject.h b/Pods/Protobuf/objectivec/GPBRootObject.h new file mode 100644 index 0000000..d2e2aeb --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBRootObject.h @@ -0,0 +1,52 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import + +@class GPBExtensionRegistry; + +NS_ASSUME_NONNULL_BEGIN + +/** + * Every generated proto file defines a local "Root" class that exposes a + * GPBExtensionRegistry for all the extensions defined by that file and + * the files it depends on. + **/ +@interface GPBRootObject : NSObject + +/** + * @return An extension registry for the given file and all the files it depends + * on. + **/ ++ (GPBExtensionRegistry *)extensionRegistry; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Pods/Protobuf/objectivec/GPBRootObject.m b/Pods/Protobuf/objectivec/GPBRootObject.m new file mode 100644 index 0000000..585d205 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBRootObject.m @@ -0,0 +1,237 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import "GPBRootObject_PackagePrivate.h" + +#import + +#import + +#import "GPBDescriptor.h" +#import "GPBExtensionRegistry.h" +#import "GPBUtilities_PackagePrivate.h" + +@interface GPBExtensionDescriptor (GPBRootObject) +// Get singletonName as a c string. +- (const char *)singletonNameC; +@end + +@implementation GPBRootObject + +// Taken from http://www.burtleburtle.net/bob/hash/doobs.html +// Public Domain +static uint32_t jenkins_one_at_a_time_hash(const char *key) { + uint32_t hash = 0; + for (uint32_t i = 0; key[i] != '\0'; ++i) { + hash += key[i]; + hash += (hash << 10); + hash ^= (hash >> 6); + } + hash += (hash << 3); + hash ^= (hash >> 11); + hash += (hash << 15); + return hash; +} + +// Key methods for our custom CFDictionary. +// Note that the dictionary lasts for the lifetime of our app, so no need +// to worry about deallocation. All of the items are added to it at +// startup, and so the keys don't need to be retained/released. +// Keys are NULL terminated char *. +static const void *GPBRootExtensionKeyRetain(CFAllocatorRef allocator, + const void *value) { +#pragma unused(allocator) + return value; +} + +static void GPBRootExtensionKeyRelease(CFAllocatorRef allocator, + const void *value) { +#pragma unused(allocator) +#pragma unused(value) +} + +static CFStringRef GPBRootExtensionCopyKeyDescription(const void *value) { + const char *key = (const char *)value; + return CFStringCreateWithCString(kCFAllocatorDefault, key, + kCFStringEncodingUTF8); +} + +static Boolean GPBRootExtensionKeyEqual(const void *value1, + const void *value2) { + const char *key1 = (const char *)value1; + const char *key2 = (const char *)value2; + return strcmp(key1, key2) == 0; +} + +static CFHashCode GPBRootExtensionKeyHash(const void *value) { + const char *key = (const char *)value; + return jenkins_one_at_a_time_hash(key); +} + +// NOTE: OSSpinLock may seem like a good fit here but Apple engineers have +// pointed out that they are vulnerable to live locking on iOS in cases of +// priority inversion: +// http://mjtsai.com/blog/2015/12/16/osspinlock-is-unsafe/ +// https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000372.html +static dispatch_semaphore_t gExtensionSingletonDictionarySemaphore; +static CFMutableDictionaryRef gExtensionSingletonDictionary = NULL; +static GPBExtensionRegistry *gDefaultExtensionRegistry = NULL; + ++ (void)initialize { + // Ensure the global is started up. + if (!gExtensionSingletonDictionary) { + gExtensionSingletonDictionarySemaphore = dispatch_semaphore_create(1); + CFDictionaryKeyCallBacks keyCallBacks = { + // See description above for reason for using custom dictionary. + 0, + GPBRootExtensionKeyRetain, + GPBRootExtensionKeyRelease, + GPBRootExtensionCopyKeyDescription, + GPBRootExtensionKeyEqual, + GPBRootExtensionKeyHash, + }; + gExtensionSingletonDictionary = + CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &keyCallBacks, + &kCFTypeDictionaryValueCallBacks); + gDefaultExtensionRegistry = [[GPBExtensionRegistry alloc] init]; + } + + if ([self superclass] == [GPBRootObject class]) { + // This is here to start up all the per file "Root" subclasses. + // This must be done in initialize to enforce thread safety of start up of + // the protocol buffer library. + [self extensionRegistry]; + } +} + ++ (GPBExtensionRegistry *)extensionRegistry { + // Is overridden in all the subclasses that provide extensions to provide the + // per class one. + return gDefaultExtensionRegistry; +} + ++ (void)globallyRegisterExtension:(GPBExtensionDescriptor *)field { + const char *key = [field singletonNameC]; + dispatch_semaphore_wait(gExtensionSingletonDictionarySemaphore, + DISPATCH_TIME_FOREVER); + CFDictionarySetValue(gExtensionSingletonDictionary, key, field); + dispatch_semaphore_signal(gExtensionSingletonDictionarySemaphore); +} + +static id ExtensionForName(id self, SEL _cmd) { + // Really fast way of doing "classname_selName". + // This came up as a hotspot (creation of NSString *) when accessing a + // lot of extensions. + const char *selName = sel_getName(_cmd); + if (selName[0] == '_') { + return nil; // Apple internal selector. + } + size_t selNameLen = 0; + while (1) { + char c = selName[selNameLen]; + if (c == '\0') { // String end. + break; + } + if (c == ':') { + return nil; // Selector took an arg, not one of the runtime methods. + } + ++selNameLen; + } + + const char *className = class_getName(self); + size_t classNameLen = strlen(className); + char key[classNameLen + selNameLen + 2]; + memcpy(key, className, classNameLen); + key[classNameLen] = '_'; + memcpy(&key[classNameLen + 1], selName, selNameLen); + key[classNameLen + 1 + selNameLen] = '\0'; + + // NOTE: Even though this method is called from another C function, + // gExtensionSingletonDictionarySemaphore and gExtensionSingletonDictionary + // will always be initialized. This is because this call flow is just to + // lookup the Extension, meaning the code is calling an Extension class + // message on a Message or Root class. This guarantees that the class was + // initialized and Message classes ensure their Root was also initialized. + NSAssert(gExtensionSingletonDictionary, @"Startup order broken!"); + + dispatch_semaphore_wait(gExtensionSingletonDictionarySemaphore, + DISPATCH_TIME_FOREVER); + id extension = (id)CFDictionaryGetValue(gExtensionSingletonDictionary, key); + // We can't remove the key from the dictionary here (as an optimization), + // two threads could have gone into +resolveClassMethod: for the same method, + // and ended up here; there's no way to ensure both return YES without letting + // both try to wire in the method. + dispatch_semaphore_signal(gExtensionSingletonDictionarySemaphore); + return extension; +} + +BOOL GPBResolveExtensionClassMethod(Class self, SEL sel) { + // Another option would be to register the extensions with the class at + // globallyRegisterExtension: + // Timing the two solutions, this solution turned out to be much faster + // and reduced startup time, and runtime memory. + // The advantage to globallyRegisterExtension is that it would reduce the + // size of the protos somewhat because the singletonNameC wouldn't need + // to include the class name. For a class with a lot of extensions it + // can add up. You could also significantly reduce the code complexity of this + // file. + id extension = ExtensionForName(self, sel); + if (extension != nil) { + const char *encoding = + GPBMessageEncodingForSelector(@selector(getClassValue), NO); + Class metaClass = objc_getMetaClass(class_getName(self)); + IMP imp = imp_implementationWithBlock(^(id obj) { +#pragma unused(obj) + return extension; + }); + BOOL methodAdded = class_addMethod(metaClass, sel, imp, encoding); + // class_addMethod() is documented as also failing if the method was already + // added; so we check if the method is already there and return success so + // the method dispatch will still happen. Why would it already be added? + // Two threads could cause the same method to be bound at the same time, + // but only one will actually bind it; the other still needs to return true + // so things will dispatch. + if (!methodAdded) { + methodAdded = GPBClassHasSel(metaClass, sel); + } + return methodAdded; + } + return NO; +} + + ++ (BOOL)resolveClassMethod:(SEL)sel { + if (GPBResolveExtensionClassMethod(self, sel)) { + return YES; + } + return [super resolveClassMethod:sel]; +} + +@end diff --git a/Pods/Protobuf/objectivec/GPBRootObject_PackagePrivate.h b/Pods/Protobuf/objectivec/GPBRootObject_PackagePrivate.h new file mode 100644 index 0000000..3c8f09c --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBRootObject_PackagePrivate.h @@ -0,0 +1,46 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import + +#import "GPBRootObject.h" + +@class GPBExtensionDescriptor; + +@interface GPBRootObject () + +// Globally register. ++ (void)globallyRegisterExtension:(GPBExtensionDescriptor *)field; + +@end + +// Returns YES if the selector was resolved and added to the class, +// NO otherwise. +BOOL GPBResolveExtensionClassMethod(Class self, SEL sel); diff --git a/Pods/Protobuf/objectivec/GPBRuntimeTypes.h b/Pods/Protobuf/objectivec/GPBRuntimeTypes.h new file mode 100644 index 0000000..4d55206 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBRuntimeTypes.h @@ -0,0 +1,144 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import + +#import "GPBBootstrap.h" + +@class GPBEnumDescriptor; +@class GPBMessage; +@class GPBInt32Array; + +/** + * Verifies that a given value can be represented by an enum type. + * */ +typedef BOOL (*GPBEnumValidationFunc)(int32_t); + +/** + * Fetches an EnumDescriptor. + * */ +typedef GPBEnumDescriptor *(*GPBEnumDescriptorFunc)(void); + +/** + * Magic value used at runtime to indicate an enum value that wasn't know at + * compile time. + * */ +enum { + kGPBUnrecognizedEnumeratorValue = (int32_t)0xFBADBEEF, +}; + +/** + * A union for storing all possible Protobuf values. Note that owner is + * responsible for memory management of object types. + * */ +typedef union { + BOOL valueBool; + int32_t valueInt32; + int64_t valueInt64; + uint32_t valueUInt32; + uint64_t valueUInt64; + float valueFloat; + double valueDouble; + GPB_UNSAFE_UNRETAINED NSData *valueData; + GPB_UNSAFE_UNRETAINED NSString *valueString; + GPB_UNSAFE_UNRETAINED GPBMessage *valueMessage; + int32_t valueEnum; +} GPBGenericValue; + +/** + * Enum listing the possible data types that a field can contain. + * + * @note Do not change the order of this enum (or add things to it) without + * thinking about it very carefully. There are several things that depend + * on the order. + * */ +typedef NS_ENUM(uint8_t, GPBDataType) { + /** Field contains boolean value(s). */ + GPBDataTypeBool = 0, + /** Field contains unsigned 4 byte value(s). */ + GPBDataTypeFixed32, + /** Field contains signed 4 byte value(s). */ + GPBDataTypeSFixed32, + /** Field contains float value(s). */ + GPBDataTypeFloat, + /** Field contains unsigned 8 byte value(s). */ + GPBDataTypeFixed64, + /** Field contains signed 8 byte value(s). */ + GPBDataTypeSFixed64, + /** Field contains double value(s). */ + GPBDataTypeDouble, + /** + * Field contains variable length value(s). Inefficient for encoding negative + * numbers – if your field is likely to have negative values, use + * GPBDataTypeSInt32 instead. + **/ + GPBDataTypeInt32, + /** + * Field contains variable length value(s). Inefficient for encoding negative + * numbers – if your field is likely to have negative values, use + * GPBDataTypeSInt64 instead. + **/ + GPBDataTypeInt64, + /** Field contains signed variable length integer value(s). */ + GPBDataTypeSInt32, + /** Field contains signed variable length integer value(s). */ + GPBDataTypeSInt64, + /** Field contains unsigned variable length integer value(s). */ + GPBDataTypeUInt32, + /** Field contains unsigned variable length integer value(s). */ + GPBDataTypeUInt64, + /** Field contains an arbitrary sequence of bytes. */ + GPBDataTypeBytes, + /** Field contains UTF-8 encoded or 7-bit ASCII text. */ + GPBDataTypeString, + /** Field contains message type(s). */ + GPBDataTypeMessage, + /** Field contains message type(s). */ + GPBDataTypeGroup, + /** Field contains enum value(s). */ + GPBDataTypeEnum, +}; + +enum { + /** + * A count of the number of types in GPBDataType. Separated out from the + * GPBDataType enum to avoid warnings regarding not handling GPBDataType_Count + * in switch statements. + **/ + GPBDataType_Count = GPBDataTypeEnum + 1 +}; + +/** An extension range. */ +typedef struct GPBExtensionRange { + /** Inclusive. */ + uint32_t start; + /** Exclusive. */ + uint32_t end; +} GPBExtensionRange; diff --git a/Pods/Protobuf/objectivec/GPBUnknownField.h b/Pods/Protobuf/objectivec/GPBUnknownField.h new file mode 100644 index 0000000..5b96023 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBUnknownField.h @@ -0,0 +1,99 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import + +@class GPBCodedOutputStream; +@class GPBUInt32Array; +@class GPBUInt64Array; +@class GPBUnknownFieldSet; + +NS_ASSUME_NONNULL_BEGIN +/** + * Store an unknown field. These are used in conjunction with + * GPBUnknownFieldSet. + **/ +@interface GPBUnknownField : NSObject + +/** Initialize a field with the given number. */ +- (instancetype)initWithNumber:(int32_t)number; + +/** The field number the data is stored under. */ +@property(nonatomic, readonly, assign) int32_t number; + +/** An array of varint values for this field. */ +@property(nonatomic, readonly, strong) GPBUInt64Array *varintList; + +/** An array of fixed32 values for this field. */ +@property(nonatomic, readonly, strong) GPBUInt32Array *fixed32List; + +/** An array of fixed64 values for this field. */ +@property(nonatomic, readonly, strong) GPBUInt64Array *fixed64List; + +/** An array of data values for this field. */ +@property(nonatomic, readonly, strong) NSArray *lengthDelimitedList; + +/** An array of groups of values for this field. */ +@property(nonatomic, readonly, strong) NSArray *groupList; + +/** + * Add a value to the varintList. + * + * @param value The value to add. + **/ +- (void)addVarint:(uint64_t)value; +/** + * Add a value to the fixed32List. + * + * @param value The value to add. + **/ +- (void)addFixed32:(uint32_t)value; +/** + * Add a value to the fixed64List. + * + * @param value The value to add. + **/ +- (void)addFixed64:(uint64_t)value; +/** + * Add a value to the lengthDelimitedList. + * + * @param value The value to add. + **/ +- (void)addLengthDelimited:(NSData *)value; +/** + * Add a value to the groupList. + * + * @param value The value to add. + **/ +- (void)addGroup:(GPBUnknownFieldSet *)value; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Pods/Protobuf/objectivec/GPBUnknownField.m b/Pods/Protobuf/objectivec/GPBUnknownField.m new file mode 100644 index 0000000..9d5c97f --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBUnknownField.m @@ -0,0 +1,336 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import "GPBUnknownField_PackagePrivate.h" + +#import "GPBArray.h" +#import "GPBCodedOutputStream_PackagePrivate.h" + +@implementation GPBUnknownField { + @protected + int32_t number_; + GPBUInt64Array *mutableVarintList_; + GPBUInt32Array *mutableFixed32List_; + GPBUInt64Array *mutableFixed64List_; + NSMutableArray *mutableLengthDelimitedList_; + NSMutableArray *mutableGroupList_; +} + +@synthesize number = number_; +@synthesize varintList = mutableVarintList_; +@synthesize fixed32List = mutableFixed32List_; +@synthesize fixed64List = mutableFixed64List_; +@synthesize lengthDelimitedList = mutableLengthDelimitedList_; +@synthesize groupList = mutableGroupList_; + +- (instancetype)initWithNumber:(int32_t)number { + if ((self = [super init])) { + number_ = number; + } + return self; +} + +- (void)dealloc { + [mutableVarintList_ release]; + [mutableFixed32List_ release]; + [mutableFixed64List_ release]; + [mutableLengthDelimitedList_ release]; + [mutableGroupList_ release]; + + [super dealloc]; +} + +// Direct access is use for speed, to avoid even internally declaring things +// read/write, etc. The warning is enabled in the project to ensure code calling +// protos can turn on -Wdirect-ivar-access without issues. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdirect-ivar-access" + +- (id)copyWithZone:(NSZone *)zone { + GPBUnknownField *result = + [[GPBUnknownField allocWithZone:zone] initWithNumber:number_]; + result->mutableFixed32List_ = [mutableFixed32List_ copyWithZone:zone]; + result->mutableFixed64List_ = [mutableFixed64List_ copyWithZone:zone]; + result->mutableLengthDelimitedList_ = + [mutableLengthDelimitedList_ mutableCopyWithZone:zone]; + result->mutableVarintList_ = [mutableVarintList_ copyWithZone:zone]; + if (mutableGroupList_.count) { + result->mutableGroupList_ = [[NSMutableArray allocWithZone:zone] + initWithCapacity:mutableGroupList_.count]; + for (GPBUnknownFieldSet *group in mutableGroupList_) { + GPBUnknownFieldSet *copied = [group copyWithZone:zone]; + [result->mutableGroupList_ addObject:copied]; + [copied release]; + } + } + return result; +} + +- (BOOL)isEqual:(id)object { + if (self == object) return YES; + if (![object isKindOfClass:[GPBUnknownField class]]) return NO; + GPBUnknownField *field = (GPBUnknownField *)object; + if (number_ != field->number_) return NO; + BOOL equalVarint = + (mutableVarintList_.count == 0 && field->mutableVarintList_.count == 0) || + [mutableVarintList_ isEqual:field->mutableVarintList_]; + if (!equalVarint) return NO; + BOOL equalFixed32 = (mutableFixed32List_.count == 0 && + field->mutableFixed32List_.count == 0) || + [mutableFixed32List_ isEqual:field->mutableFixed32List_]; + if (!equalFixed32) return NO; + BOOL equalFixed64 = (mutableFixed64List_.count == 0 && + field->mutableFixed64List_.count == 0) || + [mutableFixed64List_ isEqual:field->mutableFixed64List_]; + if (!equalFixed64) return NO; + BOOL equalLDList = + (mutableLengthDelimitedList_.count == 0 && + field->mutableLengthDelimitedList_.count == 0) || + [mutableLengthDelimitedList_ isEqual:field->mutableLengthDelimitedList_]; + if (!equalLDList) return NO; + BOOL equalGroupList = + (mutableGroupList_.count == 0 && field->mutableGroupList_.count == 0) || + [mutableGroupList_ isEqual:field->mutableGroupList_]; + if (!equalGroupList) return NO; + return YES; +} + +- (NSUInteger)hash { + // Just mix the hashes of the possible sub arrays. + const int prime = 31; + NSUInteger result = prime + [mutableVarintList_ hash]; + result = prime * result + [mutableFixed32List_ hash]; + result = prime * result + [mutableFixed64List_ hash]; + result = prime * result + [mutableLengthDelimitedList_ hash]; + result = prime * result + [mutableGroupList_ hash]; + return result; +} + +- (void)writeToOutput:(GPBCodedOutputStream *)output { + NSUInteger count = mutableVarintList_.count; + if (count > 0) { + [output writeUInt64Array:number_ values:mutableVarintList_ tag:0]; + } + count = mutableFixed32List_.count; + if (count > 0) { + [output writeFixed32Array:number_ values:mutableFixed32List_ tag:0]; + } + count = mutableFixed64List_.count; + if (count > 0) { + [output writeFixed64Array:number_ values:mutableFixed64List_ tag:0]; + } + count = mutableLengthDelimitedList_.count; + if (count > 0) { + [output writeBytesArray:number_ values:mutableLengthDelimitedList_]; + } + count = mutableGroupList_.count; + if (count > 0) { + [output writeUnknownGroupArray:number_ values:mutableGroupList_]; + } +} + +- (size_t)serializedSize { + __block size_t result = 0; + int32_t number = number_; + [mutableVarintList_ + enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + result += GPBComputeUInt64Size(number, value); + }]; + + [mutableFixed32List_ + enumerateValuesWithBlock:^(uint32_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + result += GPBComputeFixed32Size(number, value); + }]; + + [mutableFixed64List_ + enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + result += GPBComputeFixed64Size(number, value); + }]; + + for (NSData *data in mutableLengthDelimitedList_) { + result += GPBComputeBytesSize(number, data); + } + + for (GPBUnknownFieldSet *set in mutableGroupList_) { + result += GPBComputeUnknownGroupSize(number, set); + } + + return result; +} + +- (void)writeAsMessageSetExtensionToOutput:(GPBCodedOutputStream *)output { + for (NSData *data in mutableLengthDelimitedList_) { + [output writeRawMessageSetExtension:number_ value:data]; + } +} + +- (size_t)serializedSizeAsMessageSetExtension { + size_t result = 0; + for (NSData *data in mutableLengthDelimitedList_) { + result += GPBComputeRawMessageSetExtensionSize(number_, data); + } + return result; +} + +- (NSString *)description { + NSMutableString *description = + [NSMutableString stringWithFormat:@"<%@ %p>: Field: %d {\n", + [self class], self, number_]; + [mutableVarintList_ + enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [description appendFormat:@"\t%llu\n", value]; + }]; + + [mutableFixed32List_ + enumerateValuesWithBlock:^(uint32_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [description appendFormat:@"\t%u\n", value]; + }]; + + [mutableFixed64List_ + enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) { +#pragma unused(idx, stop) + [description appendFormat:@"\t%llu\n", value]; + }]; + + for (NSData *data in mutableLengthDelimitedList_) { + [description appendFormat:@"\t%@\n", data]; + } + + for (GPBUnknownFieldSet *set in mutableGroupList_) { + [description appendFormat:@"\t%@\n", set]; + } + [description appendString:@"}"]; + return description; +} + +- (void)mergeFromField:(GPBUnknownField *)other { + GPBUInt64Array *otherVarintList = other.varintList; + if (otherVarintList.count > 0) { + if (mutableVarintList_ == nil) { + mutableVarintList_ = [otherVarintList copy]; + } else { + [mutableVarintList_ addValuesFromArray:otherVarintList]; + } + } + + GPBUInt32Array *otherFixed32List = other.fixed32List; + if (otherFixed32List.count > 0) { + if (mutableFixed32List_ == nil) { + mutableFixed32List_ = [otherFixed32List copy]; + } else { + [mutableFixed32List_ addValuesFromArray:otherFixed32List]; + } + } + + GPBUInt64Array *otherFixed64List = other.fixed64List; + if (otherFixed64List.count > 0) { + if (mutableFixed64List_ == nil) { + mutableFixed64List_ = [otherFixed64List copy]; + } else { + [mutableFixed64List_ addValuesFromArray:otherFixed64List]; + } + } + + NSArray *otherLengthDelimitedList = other.lengthDelimitedList; + if (otherLengthDelimitedList.count > 0) { + if (mutableLengthDelimitedList_ == nil) { + mutableLengthDelimitedList_ = [otherLengthDelimitedList mutableCopy]; + } else { + [mutableLengthDelimitedList_ + addObjectsFromArray:otherLengthDelimitedList]; + } + } + + NSArray *otherGroupList = other.groupList; + if (otherGroupList.count > 0) { + if (mutableGroupList_ == nil) { + mutableGroupList_ = + [[NSMutableArray alloc] initWithCapacity:otherGroupList.count]; + } + // Make our own mutable copies. + for (GPBUnknownFieldSet *group in otherGroupList) { + GPBUnknownFieldSet *copied = [group copy]; + [mutableGroupList_ addObject:copied]; + [copied release]; + } + } +} + +- (void)addVarint:(uint64_t)value { + if (mutableVarintList_ == nil) { + mutableVarintList_ = [[GPBUInt64Array alloc] initWithValues:&value count:1]; + } else { + [mutableVarintList_ addValue:value]; + } +} + +- (void)addFixed32:(uint32_t)value { + if (mutableFixed32List_ == nil) { + mutableFixed32List_ = + [[GPBUInt32Array alloc] initWithValues:&value count:1]; + } else { + [mutableFixed32List_ addValue:value]; + } +} + +- (void)addFixed64:(uint64_t)value { + if (mutableFixed64List_ == nil) { + mutableFixed64List_ = + [[GPBUInt64Array alloc] initWithValues:&value count:1]; + } else { + [mutableFixed64List_ addValue:value]; + } +} + +- (void)addLengthDelimited:(NSData *)value { + if (mutableLengthDelimitedList_ == nil) { + mutableLengthDelimitedList_ = + [[NSMutableArray alloc] initWithObjects:&value count:1]; + } else { + [mutableLengthDelimitedList_ addObject:value]; + } +} + +- (void)addGroup:(GPBUnknownFieldSet *)value { + if (mutableGroupList_ == nil) { + mutableGroupList_ = [[NSMutableArray alloc] initWithObjects:&value count:1]; + } else { + [mutableGroupList_ addObject:value]; + } +} + +#pragma clang diagnostic pop + +@end diff --git a/Pods/Protobuf/objectivec/GPBUnknownFieldSet.h b/Pods/Protobuf/objectivec/GPBUnknownFieldSet.h new file mode 100644 index 0000000..1b5f24f --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBUnknownFieldSet.h @@ -0,0 +1,82 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import + +@class GPBUnknownField; + +NS_ASSUME_NONNULL_BEGIN + +/** + * A collection of unknown fields. Fields parsed from the binary representation + * of a message that are unknown end up in an instance of this set. This only + * applies for files declared with the "proto2" syntax. Files declared with the + * "proto3" syntax discard the unknown values. + **/ +@interface GPBUnknownFieldSet : NSObject + +/** + * Tests to see if the given field number has a value. + * + * @param number The field number to check. + * + * @return YES if there is an unknown field for the given field number. + **/ +- (BOOL)hasField:(int32_t)number; + +/** + * Fetches the GPBUnknownField for the given field number. + * + * @param number The field number to look up. + * + * @return The GPBUnknownField or nil if none found. + **/ +- (nullable GPBUnknownField *)getField:(int32_t)number; + +/** + * @return The number of fields in this set. + **/ +- (NSUInteger)countOfFields; + +/** + * Adds the given field to the set. + * + * @param field The field to add to the set. + **/ +- (void)addField:(GPBUnknownField *)field; + +/** + * @return An array of the GPBUnknownFields sorted by the field numbers. + **/ +- (NSArray *)sortedFields; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Pods/Protobuf/objectivec/GPBUnknownFieldSet.m b/Pods/Protobuf/objectivec/GPBUnknownFieldSet.m new file mode 100644 index 0000000..a7335f0 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBUnknownFieldSet.m @@ -0,0 +1,395 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import "GPBUnknownFieldSet_PackagePrivate.h" + +#import "GPBCodedInputStream_PackagePrivate.h" +#import "GPBCodedOutputStream.h" +#import "GPBUnknownField_PackagePrivate.h" +#import "GPBUtilities.h" +#import "GPBWireFormat.h" + +#pragma mark Helpers + +static void checkNumber(int32_t number) { + if (number == 0) { + [NSException raise:NSInvalidArgumentException + format:@"Zero is not a valid field number."]; + } +} + +@implementation GPBUnknownFieldSet { + @package + CFMutableDictionaryRef fields_; +} + +static void CopyWorker(const void *key, const void *value, void *context) { +#pragma unused(key) + GPBUnknownField *field = value; + GPBUnknownFieldSet *result = context; + + GPBUnknownField *copied = [field copy]; + [result addField:copied]; + [copied release]; +} + +// Direct access is use for speed, to avoid even internally declaring things +// read/write, etc. The warning is enabled in the project to ensure code calling +// protos can turn on -Wdirect-ivar-access without issues. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdirect-ivar-access" + +- (id)copyWithZone:(NSZone *)zone { + GPBUnknownFieldSet *result = [[GPBUnknownFieldSet allocWithZone:zone] init]; + if (fields_) { + CFDictionaryApplyFunction(fields_, CopyWorker, result); + } + return result; +} + +- (void)dealloc { + if (fields_) { + CFRelease(fields_); + } + [super dealloc]; +} + +- (BOOL)isEqual:(id)object { + BOOL equal = NO; + if ([object isKindOfClass:[GPBUnknownFieldSet class]]) { + GPBUnknownFieldSet *set = (GPBUnknownFieldSet *)object; + if ((fields_ == NULL) && (set->fields_ == NULL)) { + equal = YES; + } else if ((fields_ != NULL) && (set->fields_ != NULL)) { + equal = CFEqual(fields_, set->fields_); + } + } + return equal; +} + +- (NSUInteger)hash { + // Return the hash of the fields dictionary (or just some value). + if (fields_) { + return CFHash(fields_); + } + return (NSUInteger)[GPBUnknownFieldSet class]; +} + +#pragma mark - Public Methods + +- (BOOL)hasField:(int32_t)number { + ssize_t key = number; + return fields_ ? (CFDictionaryGetValue(fields_, (void *)key) != nil) : NO; +} + +- (GPBUnknownField *)getField:(int32_t)number { + ssize_t key = number; + GPBUnknownField *result = + fields_ ? CFDictionaryGetValue(fields_, (void *)key) : nil; + return result; +} + +- (NSUInteger)countOfFields { + return fields_ ? CFDictionaryGetCount(fields_) : 0; +} + +- (NSArray *)sortedFields { + if (!fields_) return [NSArray array]; + size_t count = CFDictionaryGetCount(fields_); + ssize_t keys[count]; + GPBUnknownField *values[count]; + CFDictionaryGetKeysAndValues(fields_, (const void **)keys, + (const void **)values); + struct GPBFieldPair { + ssize_t key; + GPBUnknownField *value; + } pairs[count]; + for (size_t i = 0; i < count; ++i) { + pairs[i].key = keys[i]; + pairs[i].value = values[i]; + }; + qsort_b(pairs, count, sizeof(struct GPBFieldPair), + ^(const void *first, const void *second) { + const struct GPBFieldPair *a = first; + const struct GPBFieldPair *b = second; + return (a->key > b->key) ? 1 : ((a->key == b->key) ? 0 : -1); + }); + for (size_t i = 0; i < count; ++i) { + values[i] = pairs[i].value; + }; + return [NSArray arrayWithObjects:values count:count]; +} + +#pragma mark - Internal Methods + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)output { + if (!fields_) return; + size_t count = CFDictionaryGetCount(fields_); + ssize_t keys[count]; + GPBUnknownField *values[count]; + CFDictionaryGetKeysAndValues(fields_, (const void **)keys, + (const void **)values); + if (count > 1) { + struct GPBFieldPair { + ssize_t key; + GPBUnknownField *value; + } pairs[count]; + + for (size_t i = 0; i < count; ++i) { + pairs[i].key = keys[i]; + pairs[i].value = values[i]; + }; + qsort_b(pairs, count, sizeof(struct GPBFieldPair), + ^(const void *first, const void *second) { + const struct GPBFieldPair *a = first; + const struct GPBFieldPair *b = second; + return (a->key > b->key) ? 1 : ((a->key == b->key) ? 0 : -1); + }); + for (size_t i = 0; i < count; ++i) { + GPBUnknownField *value = pairs[i].value; + [value writeToOutput:output]; + } + } else { + [values[0] writeToOutput:output]; + } +} + +- (NSString *)description { + NSMutableString *description = [NSMutableString + stringWithFormat:@"<%@ %p>: TextFormat: {\n", [self class], self]; + NSString *textFormat = GPBTextFormatForUnknownFieldSet(self, @" "); + [description appendString:textFormat]; + [description appendString:@"}"]; + return description; +} + +static void GPBUnknownFieldSetSerializedSize(const void *key, const void *value, + void *context) { +#pragma unused(key) + GPBUnknownField *field = value; + size_t *result = context; + *result += [field serializedSize]; +} + +- (size_t)serializedSize { + size_t result = 0; + if (fields_) { + CFDictionaryApplyFunction(fields_, GPBUnknownFieldSetSerializedSize, + &result); + } + return result; +} + +static void GPBUnknownFieldSetWriteAsMessageSetTo(const void *key, + const void *value, + void *context) { +#pragma unused(key) + GPBUnknownField *field = value; + GPBCodedOutputStream *output = context; + [field writeAsMessageSetExtensionToOutput:output]; +} + +- (void)writeAsMessageSetTo:(GPBCodedOutputStream *)output { + if (fields_) { + CFDictionaryApplyFunction(fields_, GPBUnknownFieldSetWriteAsMessageSetTo, + output); + } +} + +static void GPBUnknownFieldSetSerializedSizeAsMessageSet(const void *key, + const void *value, + void *context) { +#pragma unused(key) + GPBUnknownField *field = value; + size_t *result = context; + *result += [field serializedSizeAsMessageSetExtension]; +} + +- (size_t)serializedSizeAsMessageSet { + size_t result = 0; + if (fields_) { + CFDictionaryApplyFunction( + fields_, GPBUnknownFieldSetSerializedSizeAsMessageSet, &result); + } + return result; +} + +- (NSData *)data { + NSMutableData *data = [NSMutableData dataWithLength:self.serializedSize]; + GPBCodedOutputStream *output = + [[GPBCodedOutputStream alloc] initWithData:data]; + [self writeToCodedOutputStream:output]; + [output release]; + return data; +} + ++ (BOOL)isFieldTag:(int32_t)tag { + return GPBWireFormatGetTagWireType(tag) != GPBWireFormatEndGroup; +} + +- (void)addField:(GPBUnknownField *)field { + int32_t number = [field number]; + checkNumber(number); + if (!fields_) { + // Use a custom dictionary here because the keys are numbers and conversion + // back and forth from NSNumber isn't worth the cost. + fields_ = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL, + &kCFTypeDictionaryValueCallBacks); + } + ssize_t key = number; + CFDictionarySetValue(fields_, (const void *)key, field); +} + +- (GPBUnknownField *)mutableFieldForNumber:(int32_t)number create:(BOOL)create { + ssize_t key = number; + GPBUnknownField *existing = + fields_ ? CFDictionaryGetValue(fields_, (const void *)key) : nil; + if (!existing && create) { + existing = [[GPBUnknownField alloc] initWithNumber:number]; + // This retains existing. + [self addField:existing]; + [existing release]; + } + return existing; +} + +static void GPBUnknownFieldSetMergeUnknownFields(const void *key, + const void *value, + void *context) { +#pragma unused(key) + GPBUnknownField *field = value; + GPBUnknownFieldSet *self = context; + + int32_t number = [field number]; + checkNumber(number); + GPBUnknownField *oldField = [self mutableFieldForNumber:number create:NO]; + if (oldField) { + [oldField mergeFromField:field]; + } else { + // Merge only comes from GPBMessage's mergeFrom:, so it means we are on + // mutable message and are an mutable instance, so make sure we need + // mutable fields. + GPBUnknownField *fieldCopy = [field copy]; + [self addField:fieldCopy]; + [fieldCopy release]; + } +} + +- (void)mergeUnknownFields:(GPBUnknownFieldSet *)other { + if (other && other->fields_) { + CFDictionaryApplyFunction(other->fields_, + GPBUnknownFieldSetMergeUnknownFields, self); + } +} + +- (void)mergeFromData:(NSData *)data { + GPBCodedInputStream *input = [[GPBCodedInputStream alloc] initWithData:data]; + [self mergeFromCodedInputStream:input]; + [input checkLastTagWas:0]; + [input release]; +} + +- (void)mergeVarintField:(int32_t)number value:(int32_t)value { + checkNumber(number); + [[self mutableFieldForNumber:number create:YES] addVarint:value]; +} + +- (BOOL)mergeFieldFrom:(int32_t)tag input:(GPBCodedInputStream *)input { + NSAssert(GPBWireFormatIsValidTag(tag), @"Got passed an invalid tag"); + int32_t number = GPBWireFormatGetTagFieldNumber(tag); + GPBCodedInputStreamState *state = &input->state_; + switch (GPBWireFormatGetTagWireType(tag)) { + case GPBWireFormatVarint: { + GPBUnknownField *field = [self mutableFieldForNumber:number create:YES]; + [field addVarint:GPBCodedInputStreamReadInt64(state)]; + return YES; + } + case GPBWireFormatFixed64: { + GPBUnknownField *field = [self mutableFieldForNumber:number create:YES]; + [field addFixed64:GPBCodedInputStreamReadFixed64(state)]; + return YES; + } + case GPBWireFormatLengthDelimited: { + NSData *data = GPBCodedInputStreamReadRetainedBytes(state); + GPBUnknownField *field = [self mutableFieldForNumber:number create:YES]; + [field addLengthDelimited:data]; + [data release]; + return YES; + } + case GPBWireFormatStartGroup: { + GPBUnknownFieldSet *unknownFieldSet = [[GPBUnknownFieldSet alloc] init]; + [input readUnknownGroup:number message:unknownFieldSet]; + GPBUnknownField *field = [self mutableFieldForNumber:number create:YES]; + [field addGroup:unknownFieldSet]; + [unknownFieldSet release]; + return YES; + } + case GPBWireFormatEndGroup: + return NO; + case GPBWireFormatFixed32: { + GPBUnknownField *field = [self mutableFieldForNumber:number create:YES]; + [field addFixed32:GPBCodedInputStreamReadFixed32(state)]; + return YES; + } + } +} + +- (void)mergeMessageSetMessage:(int32_t)number data:(NSData *)messageData { + [[self mutableFieldForNumber:number create:YES] + addLengthDelimited:messageData]; +} + +- (void)addUnknownMapEntry:(int32_t)fieldNum value:(NSData *)data { + GPBUnknownField *field = [self mutableFieldForNumber:fieldNum create:YES]; + [field addLengthDelimited:data]; +} + +- (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input { + while (YES) { + int32_t tag = GPBCodedInputStreamReadTag(&input->state_); + if (tag == 0 || ![self mergeFieldFrom:tag input:input]) { + break; + } + } +} + +- (void)getTags:(int32_t *)tags { + if (!fields_) return; + size_t count = CFDictionaryGetCount(fields_); + ssize_t keys[count]; + CFDictionaryGetKeysAndValues(fields_, (const void **)keys, NULL); + for (size_t i = 0; i < count; ++i) { + tags[i] = (int32_t)keys[i]; + } +} + +#pragma clang diagnostic pop + +@end diff --git a/Pods/Protobuf/objectivec/GPBUnknownFieldSet_PackagePrivate.h b/Pods/Protobuf/objectivec/GPBUnknownFieldSet_PackagePrivate.h new file mode 100644 index 0000000..e27127a --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBUnknownFieldSet_PackagePrivate.h @@ -0,0 +1,61 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import + +#import "GPBUnknownFieldSet.h" + +@class GPBCodedOutputStream; +@class GPBCodedInputStream; + +@interface GPBUnknownFieldSet () + ++ (BOOL)isFieldTag:(int32_t)tag; + +- (NSData *)data; + +- (size_t)serializedSize; +- (size_t)serializedSizeAsMessageSet; + +- (void)writeToCodedOutputStream:(GPBCodedOutputStream *)output; +- (void)writeAsMessageSetTo:(GPBCodedOutputStream *)output; + +- (void)mergeUnknownFields:(GPBUnknownFieldSet *)other; + +- (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input; +- (void)mergeFromData:(NSData *)data; + +- (void)mergeVarintField:(int32_t)number value:(int32_t)value; +- (BOOL)mergeFieldFrom:(int32_t)tag input:(GPBCodedInputStream *)input; +- (void)mergeMessageSetMessage:(int32_t)number data:(NSData *)messageData; + +- (void)addUnknownMapEntry:(int32_t)fieldNum value:(NSData *)data; + +@end diff --git a/Pods/Protobuf/objectivec/GPBUnknownField_PackagePrivate.h b/Pods/Protobuf/objectivec/GPBUnknownField_PackagePrivate.h new file mode 100644 index 0000000..2b4c789 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBUnknownField_PackagePrivate.h @@ -0,0 +1,47 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import + +#import "GPBUnknownField.h" + +@class GPBCodedOutputStream; + +@interface GPBUnknownField () + +- (void)writeToOutput:(GPBCodedOutputStream *)output; +- (size_t)serializedSize; + +- (void)writeAsMessageSetExtensionToOutput:(GPBCodedOutputStream *)output; +- (size_t)serializedSizeAsMessageSetExtension; + +- (void)mergeFromField:(GPBUnknownField *)other; + +@end diff --git a/Pods/Protobuf/objectivec/GPBUtilities.h b/Pods/Protobuf/objectivec/GPBUtilities.h new file mode 100644 index 0000000..5464dfb --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBUtilities.h @@ -0,0 +1,539 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import + +#import "GPBArray.h" +#import "GPBMessage.h" +#import "GPBRuntimeTypes.h" + +CF_EXTERN_C_BEGIN + +NS_ASSUME_NONNULL_BEGIN + +/** + * Generates a string that should be a valid "TextFormat" for the C++ version + * of Protocol Buffers. + * + * @param message The message to generate from. + * @param lineIndent A string to use as the prefix for all lines generated. Can + * be nil if no extra indent is needed. + * + * @return An NSString with the TextFormat of the message. + **/ +NSString *GPBTextFormatForMessage(GPBMessage *message, + NSString * __nullable lineIndent); + +/** + * Generates a string that should be a valid "TextFormat" for the C++ version + * of Protocol Buffers. + * + * @param unknownSet The unknown field set to generate from. + * @param lineIndent A string to use as the prefix for all lines generated. Can + * be nil if no extra indent is needed. + * + * @return An NSString with the TextFormat of the unknown field set. + **/ +NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet * __nullable unknownSet, + NSString * __nullable lineIndent); + +/** + * Checks if the given field number is set on a message. + * + * @param self The message to check. + * @param fieldNumber The field number to check. + * + * @return YES if the field number is set on the given message. + **/ +BOOL GPBMessageHasFieldNumberSet(GPBMessage *self, uint32_t fieldNumber); + +/** + * Checks if the given field is set on a message. + * + * @param self The message to check. + * @param field The field to check. + * + * @return YES if the field is set on the given message. + **/ +BOOL GPBMessageHasFieldSet(GPBMessage *self, GPBFieldDescriptor *field); + +/** + * Clears the given field for the given message. + * + * @param self The message for which to clear the field. + * @param field The field to clear. + **/ +void GPBClearMessageField(GPBMessage *self, GPBFieldDescriptor *field); + +//%PDDM-EXPAND GPB_ACCESSORS() +// This block of code is generated, do not edit it directly. + + +// +// Get/Set a given field from/to a message. +// + +// Single Fields + +/** + * Gets the value of a bytes field. + * + * @param self The message from which to get the field. + * @param field The field to get. + **/ +NSData *GPBGetMessageBytesField(GPBMessage *self, GPBFieldDescriptor *field); + +/** + * Sets the value of a bytes field. + * + * @param self The message into which to set the field. + * @param field The field to set. + * @param value The to set in the field. + **/ +void GPBSetMessageBytesField(GPBMessage *self, GPBFieldDescriptor *field, NSData *value); + +/** + * Gets the value of a string field. + * + * @param self The message from which to get the field. + * @param field The field to get. + **/ +NSString *GPBGetMessageStringField(GPBMessage *self, GPBFieldDescriptor *field); + +/** + * Sets the value of a string field. + * + * @param self The message into which to set the field. + * @param field The field to set. + * @param value The to set in the field. + **/ +void GPBSetMessageStringField(GPBMessage *self, GPBFieldDescriptor *field, NSString *value); + +/** + * Gets the value of a message field. + * + * @param self The message from which to get the field. + * @param field The field to get. + **/ +GPBMessage *GPBGetMessageMessageField(GPBMessage *self, GPBFieldDescriptor *field); + +/** + * Sets the value of a message field. + * + * @param self The message into which to set the field. + * @param field The field to set. + * @param value The to set in the field. + **/ +void GPBSetMessageMessageField(GPBMessage *self, GPBFieldDescriptor *field, GPBMessage *value); + +/** + * Gets the value of a group field. + * + * @param self The message from which to get the field. + * @param field The field to get. + **/ +GPBMessage *GPBGetMessageGroupField(GPBMessage *self, GPBFieldDescriptor *field); + +/** + * Sets the value of a group field. + * + * @param self The message into which to set the field. + * @param field The field to set. + * @param value The to set in the field. + **/ +void GPBSetMessageGroupField(GPBMessage *self, GPBFieldDescriptor *field, GPBMessage *value); + +/** + * Gets the value of a bool field. + * + * @param self The message from which to get the field. + * @param field The field to get. + **/ +BOOL GPBGetMessageBoolField(GPBMessage *self, GPBFieldDescriptor *field); + +/** + * Sets the value of a bool field. + * + * @param self The message into which to set the field. + * @param field The field to set. + * @param value The to set in the field. + **/ +void GPBSetMessageBoolField(GPBMessage *self, GPBFieldDescriptor *field, BOOL value); + +/** + * Gets the value of an int32 field. + * + * @param self The message from which to get the field. + * @param field The field to get. + **/ +int32_t GPBGetMessageInt32Field(GPBMessage *self, GPBFieldDescriptor *field); + +/** + * Sets the value of an int32 field. + * + * @param self The message into which to set the field. + * @param field The field to set. + * @param value The to set in the field. + **/ +void GPBSetMessageInt32Field(GPBMessage *self, GPBFieldDescriptor *field, int32_t value); + +/** + * Gets the value of an uint32 field. + * + * @param self The message from which to get the field. + * @param field The field to get. + **/ +uint32_t GPBGetMessageUInt32Field(GPBMessage *self, GPBFieldDescriptor *field); + +/** + * Sets the value of an uint32 field. + * + * @param self The message into which to set the field. + * @param field The field to set. + * @param value The to set in the field. + **/ +void GPBSetMessageUInt32Field(GPBMessage *self, GPBFieldDescriptor *field, uint32_t value); + +/** + * Gets the value of an int64 field. + * + * @param self The message from which to get the field. + * @param field The field to get. + **/ +int64_t GPBGetMessageInt64Field(GPBMessage *self, GPBFieldDescriptor *field); + +/** + * Sets the value of an int64 field. + * + * @param self The message into which to set the field. + * @param field The field to set. + * @param value The to set in the field. + **/ +void GPBSetMessageInt64Field(GPBMessage *self, GPBFieldDescriptor *field, int64_t value); + +/** + * Gets the value of an uint64 field. + * + * @param self The message from which to get the field. + * @param field The field to get. + **/ +uint64_t GPBGetMessageUInt64Field(GPBMessage *self, GPBFieldDescriptor *field); + +/** + * Sets the value of an uint64 field. + * + * @param self The message into which to set the field. + * @param field The field to set. + * @param value The to set in the field. + **/ +void GPBSetMessageUInt64Field(GPBMessage *self, GPBFieldDescriptor *field, uint64_t value); + +/** + * Gets the value of a float field. + * + * @param self The message from which to get the field. + * @param field The field to get. + **/ +float GPBGetMessageFloatField(GPBMessage *self, GPBFieldDescriptor *field); + +/** + * Sets the value of a float field. + * + * @param self The message into which to set the field. + * @param field The field to set. + * @param value The to set in the field. + **/ +void GPBSetMessageFloatField(GPBMessage *self, GPBFieldDescriptor *field, float value); + +/** + * Gets the value of a double field. + * + * @param self The message from which to get the field. + * @param field The field to get. + **/ +double GPBGetMessageDoubleField(GPBMessage *self, GPBFieldDescriptor *field); + +/** + * Sets the value of a double field. + * + * @param self The message into which to set the field. + * @param field The field to set. + * @param value The to set in the field. + **/ +void GPBSetMessageDoubleField(GPBMessage *self, GPBFieldDescriptor *field, double value); + +/** + * Gets the given enum field of a message. For proto3, if the value isn't a + * member of the enum, @c kGPBUnrecognizedEnumeratorValue will be returned. + * GPBGetMessageRawEnumField will bypass the check and return whatever value + * was set. + * + * @param self The message from which to get the field. + * @param field The field to get. + * + * @return The enum value for the given field. + **/ +int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field); + +/** + * Set the given enum field of a message. You can only set values that are + * members of the enum. + * + * @param self The message into which to set the field. + * @param field The field to set. + * @param value The enum value to set in the field. + **/ +void GPBSetMessageEnumField(GPBMessage *self, + GPBFieldDescriptor *field, + int32_t value); + +/** + * Get the given enum field of a message. No check is done to ensure the value + * was defined in the enum. + * + * @param self The message from which to get the field. + * @param field The field to get. + * + * @return The raw enum value for the given field. + **/ +int32_t GPBGetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field); + +/** + * Set the given enum field of a message. You can set the value to anything, + * even a value that is not a member of the enum. + * + * @param self The message into which to set the field. + * @param field The field to set. + * @param value The raw enum value to set in the field. + **/ +void GPBSetMessageRawEnumField(GPBMessage *self, + GPBFieldDescriptor *field, + int32_t value); + +// Repeated Fields + +/** + * Gets the value of a repeated field. + * + * @param self The message from which to get the field. + * @param field The repeated field to get. + * + * @return A GPB*Array or an NSMutableArray based on the field's type. + **/ +id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field); + +/** + * Sets the value of a repeated field. + * + * @param self The message into which to set the field. + * @param field The field to set. + * @param array A GPB*Array or NSMutableArray based on the field's type. + **/ +void GPBSetMessageRepeatedField(GPBMessage *self, + GPBFieldDescriptor *field, + id array); + +// Map Fields + +/** + * Gets the value of a map<> field. + * + * @param self The message from which to get the field. + * @param field The repeated field to get. + * + * @return A GPB*Dictionary or NSMutableDictionary based on the field's type. + **/ +id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field); + +/** + * Sets the value of a map<> field. + * + * @param self The message into which to set the field. + * @param field The field to set. + * @param dictionary A GPB*Dictionary or NSMutableDictionary based on the + * field's type. + **/ +void GPBSetMessageMapField(GPBMessage *self, + GPBFieldDescriptor *field, + id dictionary); + +//%PDDM-EXPAND-END GPB_ACCESSORS() + +/** + * Returns an empty NSData to assign to byte fields when you wish to assign them + * to empty. Prevents allocating a lot of little [NSData data] objects. + **/ +NSData *GPBEmptyNSData(void) __attribute__((pure)); + +/** + * Drops the `unknownFields` from the given message and from all sub message. + **/ +void GPBMessageDropUnknownFieldsRecursively(GPBMessage *message); + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + + +//%PDDM-DEFINE GPB_ACCESSORS() +//% +//%// +//%// Get/Set a given field from/to a message. +//%// +//% +//%// Single Fields +//% +//%GPB_ACCESSOR_SINGLE_FULL(Bytes, NSData, , *) +//%GPB_ACCESSOR_SINGLE_FULL(String, NSString, , *) +//%GPB_ACCESSOR_SINGLE_FULL(Message, GPBMessage, , *) +//%GPB_ACCESSOR_SINGLE_FULL(Group, GPBMessage, , *) +//%GPB_ACCESSOR_SINGLE(Bool, BOOL, ) +//%GPB_ACCESSOR_SINGLE(Int32, int32_t, n) +//%GPB_ACCESSOR_SINGLE(UInt32, uint32_t, n) +//%GPB_ACCESSOR_SINGLE(Int64, int64_t, n) +//%GPB_ACCESSOR_SINGLE(UInt64, uint64_t, n) +//%GPB_ACCESSOR_SINGLE(Float, float, ) +//%GPB_ACCESSOR_SINGLE(Double, double, ) +//%/** +//% * Gets the given enum field of a message. For proto3, if the value isn't a +//% * member of the enum, @c kGPBUnrecognizedEnumeratorValue will be returned. +//% * GPBGetMessageRawEnumField will bypass the check and return whatever value +//% * was set. +//% * +//% * @param self The message from which to get the field. +//% * @param field The field to get. +//% * +//% * @return The enum value for the given field. +//% **/ +//%int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field); +//% +//%/** +//% * Set the given enum field of a message. You can only set values that are +//% * members of the enum. +//% * +//% * @param self The message into which to set the field. +//% * @param field The field to set. +//% * @param value The enum value to set in the field. +//% **/ +//%void GPBSetMessageEnumField(GPBMessage *self, +//% GPBFieldDescriptor *field, +//% int32_t value); +//% +//%/** +//% * Get the given enum field of a message. No check is done to ensure the value +//% * was defined in the enum. +//% * +//% * @param self The message from which to get the field. +//% * @param field The field to get. +//% * +//% * @return The raw enum value for the given field. +//% **/ +//%int32_t GPBGetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field); +//% +//%/** +//% * Set the given enum field of a message. You can set the value to anything, +//% * even a value that is not a member of the enum. +//% * +//% * @param self The message into which to set the field. +//% * @param field The field to set. +//% * @param value The raw enum value to set in the field. +//% **/ +//%void GPBSetMessageRawEnumField(GPBMessage *self, +//% GPBFieldDescriptor *field, +//% int32_t value); +//% +//%// Repeated Fields +//% +//%/** +//% * Gets the value of a repeated field. +//% * +//% * @param self The message from which to get the field. +//% * @param field The repeated field to get. +//% * +//% * @return A GPB*Array or an NSMutableArray based on the field's type. +//% **/ +//%id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field); +//% +//%/** +//% * Sets the value of a repeated field. +//% * +//% * @param self The message into which to set the field. +//% * @param field The field to set. +//% * @param array A GPB*Array or NSMutableArray based on the field's type. +//% **/ +//%void GPBSetMessageRepeatedField(GPBMessage *self, +//% GPBFieldDescriptor *field, +//% id array); +//% +//%// Map Fields +//% +//%/** +//% * Gets the value of a map<> field. +//% * +//% * @param self The message from which to get the field. +//% * @param field The repeated field to get. +//% * +//% * @return A GPB*Dictionary or NSMutableDictionary based on the field's type. +//% **/ +//%id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field); +//% +//%/** +//% * Sets the value of a map<> field. +//% * +//% * @param self The message into which to set the field. +//% * @param field The field to set. +//% * @param dictionary A GPB*Dictionary or NSMutableDictionary based on the +//% * field's type. +//% **/ +//%void GPBSetMessageMapField(GPBMessage *self, +//% GPBFieldDescriptor *field, +//% id dictionary); +//% + +//%PDDM-DEFINE GPB_ACCESSOR_SINGLE(NAME, TYPE, AN) +//%GPB_ACCESSOR_SINGLE_FULL(NAME, TYPE, AN, ) +//%PDDM-DEFINE GPB_ACCESSOR_SINGLE_FULL(NAME, TYPE, AN, TisP) +//%/** +//% * Gets the value of a##AN NAME$L field. +//% * +//% * @param self The message from which to get the field. +//% * @param field The field to get. +//% **/ +//%TYPE TisP##GPBGetMessage##NAME##Field(GPBMessage *self, GPBFieldDescriptor *field); +//% +//%/** +//% * Sets the value of a##AN NAME$L field. +//% * +//% * @param self The message into which to set the field. +//% * @param field The field to set. +//% * @param value The to set in the field. +//% **/ +//%void GPBSetMessage##NAME##Field(GPBMessage *self, GPBFieldDescriptor *field, TYPE TisP##value); +//% diff --git a/Pods/Protobuf/objectivec/GPBUtilities.m b/Pods/Protobuf/objectivec/GPBUtilities.m new file mode 100644 index 0000000..5029ec7 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBUtilities.m @@ -0,0 +1,1923 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import "GPBUtilities_PackagePrivate.h" + +#import + +#import "GPBArray_PackagePrivate.h" +#import "GPBDescriptor_PackagePrivate.h" +#import "GPBDictionary_PackagePrivate.h" +#import "GPBMessage_PackagePrivate.h" +#import "GPBUnknownField.h" +#import "GPBUnknownFieldSet.h" + +// Direct access is use for speed, to avoid even internally declaring things +// read/write, etc. The warning is enabled in the project to ensure code calling +// protos can turn on -Wdirect-ivar-access without issues. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdirect-ivar-access" + +static void AppendTextFormatForMessage(GPBMessage *message, + NSMutableString *toStr, + NSString *lineIndent); + +NSData *GPBEmptyNSData(void) { + static dispatch_once_t onceToken; + static NSData *defaultNSData = nil; + dispatch_once(&onceToken, ^{ + defaultNSData = [[NSData alloc] init]; + }); + return defaultNSData; +} + +void GPBMessageDropUnknownFieldsRecursively(GPBMessage *initialMessage) { + if (!initialMessage) { + return; + } + + // Use an array as a list to process to avoid recursion. + NSMutableArray *todo = [NSMutableArray arrayWithObject:initialMessage]; + + while (todo.count) { + GPBMessage *msg = todo.lastObject; + [todo removeLastObject]; + + // Clear unknowns. + msg.unknownFields = nil; + + // Handle the message fields. + GPBDescriptor *descriptor = [[msg class] descriptor]; + for (GPBFieldDescriptor *field in descriptor->fields_) { + if (!GPBFieldDataTypeIsMessage(field)) { + continue; + } + switch (field.fieldType) { + case GPBFieldTypeSingle: + if (GPBGetHasIvarField(msg, field)) { + GPBMessage *fieldMessage = GPBGetObjectIvarWithFieldNoAutocreate(msg, field); + [todo addObject:fieldMessage]; + } + break; + + case GPBFieldTypeRepeated: { + NSArray *fieldMessages = GPBGetObjectIvarWithFieldNoAutocreate(msg, field); + if (fieldMessages.count) { + [todo addObjectsFromArray:fieldMessages]; + } + break; + } + + case GPBFieldTypeMap: { + id rawFieldMap = GPBGetObjectIvarWithFieldNoAutocreate(msg, field); + switch (field.mapKeyDataType) { + case GPBDataTypeBool: + [(GPBBoolObjectDictionary*)rawFieldMap enumerateKeysAndObjectsUsingBlock:^( + BOOL key, id _Nonnull object, BOOL * _Nonnull stop) { + #pragma unused(key, stop) + [todo addObject:object]; + }]; + break; + case GPBDataTypeFixed32: + case GPBDataTypeUInt32: + [(GPBUInt32ObjectDictionary*)rawFieldMap enumerateKeysAndObjectsUsingBlock:^( + uint32_t key, id _Nonnull object, BOOL * _Nonnull stop) { + #pragma unused(key, stop) + [todo addObject:object]; + }]; + break; + case GPBDataTypeInt32: + case GPBDataTypeSFixed32: + case GPBDataTypeSInt32: + [(GPBInt32ObjectDictionary*)rawFieldMap enumerateKeysAndObjectsUsingBlock:^( + int32_t key, id _Nonnull object, BOOL * _Nonnull stop) { + #pragma unused(key, stop) + [todo addObject:object]; + }]; + break; + case GPBDataTypeFixed64: + case GPBDataTypeUInt64: + [(GPBUInt64ObjectDictionary*)rawFieldMap enumerateKeysAndObjectsUsingBlock:^( + uint64_t key, id _Nonnull object, BOOL * _Nonnull stop) { + #pragma unused(key, stop) + [todo addObject:object]; + }]; + break; + case GPBDataTypeInt64: + case GPBDataTypeSFixed64: + case GPBDataTypeSInt64: + [(GPBInt64ObjectDictionary*)rawFieldMap enumerateKeysAndObjectsUsingBlock:^( + int64_t key, id _Nonnull object, BOOL * _Nonnull stop) { + #pragma unused(key, stop) + [todo addObject:object]; + }]; + break; + case GPBDataTypeString: + [(NSDictionary*)rawFieldMap enumerateKeysAndObjectsUsingBlock:^( + NSString * _Nonnull key, GPBMessage * _Nonnull obj, BOOL * _Nonnull stop) { + #pragma unused(key, stop) + [todo addObject:obj]; + }]; + break; + case GPBDataTypeFloat: + case GPBDataTypeDouble: + case GPBDataTypeEnum: + case GPBDataTypeBytes: + case GPBDataTypeGroup: + case GPBDataTypeMessage: + NSCAssert(NO, @"Aren't valid key types."); + } + break; + } // switch(field.mapKeyDataType) + } // switch(field.fieldType) + } // for(fields) + + // Handle any extensions holding messages. + for (GPBExtensionDescriptor *extension in [msg extensionsCurrentlySet]) { + if (!GPBDataTypeIsMessage(extension.dataType)) { + continue; + } + if (extension.isRepeated) { + NSArray *extMessages = [msg getExtension:extension]; + [todo addObjectsFromArray:extMessages]; + } else { + GPBMessage *extMessage = [msg getExtension:extension]; + [todo addObject:extMessage]; + } + } // for(extensionsCurrentlySet) + + } // while(todo.count) +} + + +// -- About Version Checks -- +// There's actually 3 places these checks all come into play: +// 1. When the generated source is compile into .o files, the header check +// happens. This is checking the protoc used matches the library being used +// when making the .o. +// 2. Every place a generated proto header is included in a developer's code, +// the header check comes into play again. But this time it is checking that +// the current library headers being used still support/match the ones for +// the generated code. +// 3. At runtime the final check here (GPBCheckRuntimeVersionsInternal), is +// called from the generated code passing in values captured when the +// generated code's .o was made. This checks that at runtime the generated +// code and runtime library match. + +void GPBCheckRuntimeVersionSupport(int32_t objcRuntimeVersion) { + // NOTE: This is passing the value captured in the compiled code to check + // against the values captured when the runtime support was compiled. This + // ensures the library code isn't in a different framework/library that + // was generated with a non matching version. + if (GOOGLE_PROTOBUF_OBJC_VERSION < objcRuntimeVersion) { + // Library is too old for headers. + [NSException raise:NSInternalInconsistencyException + format:@"Linked to ProtocolBuffer runtime version %d," + @" but code compiled needing atleast %d!", + GOOGLE_PROTOBUF_OBJC_VERSION, objcRuntimeVersion]; + } + if (objcRuntimeVersion < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION) { + // Headers are too old for library. + [NSException raise:NSInternalInconsistencyException + format:@"Proto generation source compiled against runtime" + @" version %d, but this version of the runtime only" + @" supports back to %d!", + objcRuntimeVersion, + GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION]; + } +} + +// This api is no longer used for version checks. 30001 is the last version +// using this old versioning model. When that support is removed, this function +// can be removed (along with the declaration in GPBUtilities_PackagePrivate.h). +void GPBCheckRuntimeVersionInternal(int32_t version) { + GPBInternalCompileAssert(GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION == 30001, + time_to_remove_this_old_version_shim); + if (version != GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION) { + [NSException raise:NSInternalInconsistencyException + format:@"Linked to ProtocolBuffer runtime version %d," + @" but code compiled with version %d!", + GOOGLE_PROTOBUF_OBJC_GEN_VERSION, version]; + } +} + +BOOL GPBMessageHasFieldNumberSet(GPBMessage *self, uint32_t fieldNumber) { + GPBDescriptor *descriptor = [self descriptor]; + GPBFieldDescriptor *field = [descriptor fieldWithNumber:fieldNumber]; + return GPBMessageHasFieldSet(self, field); +} + +BOOL GPBMessageHasFieldSet(GPBMessage *self, GPBFieldDescriptor *field) { + if (self == nil || field == nil) return NO; + + // Repeated/Map don't use the bit, they check the count. + if (GPBFieldIsMapOrArray(field)) { + // Array/map type doesn't matter, since GPB*Array/NSArray and + // GPB*Dictionary/NSDictionary all support -count; + NSArray *arrayOrMap = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + return (arrayOrMap.count > 0); + } else { + return GPBGetHasIvarField(self, field); + } +} + +void GPBClearMessageField(GPBMessage *self, GPBFieldDescriptor *field) { + // If not set, nothing to do. + if (!GPBGetHasIvarField(self, field)) { + return; + } + + if (GPBFieldStoresObject(field)) { + // Object types are handled slightly differently, they need to be released. + uint8_t *storage = (uint8_t *)self->messageStorage_; + id *typePtr = (id *)&storage[field->description_->offset]; + [*typePtr release]; + *typePtr = nil; + } else { + // POD types just need to clear the has bit as the Get* method will + // fetch the default when needed. + } + GPBSetHasIvarField(self, field, NO); +} + +BOOL GPBGetHasIvar(GPBMessage *self, int32_t idx, uint32_t fieldNumber) { + NSCAssert(self->messageStorage_ != NULL, + @"%@: All messages should have storage (from init)", + [self class]); + if (idx < 0) { + NSCAssert(fieldNumber != 0, @"Invalid field number."); + BOOL hasIvar = (self->messageStorage_->_has_storage_[-idx] == fieldNumber); + return hasIvar; + } else { + NSCAssert(idx != GPBNoHasBit, @"Invalid has bit."); + uint32_t byteIndex = idx / 32; + uint32_t bitMask = (1 << (idx % 32)); + BOOL hasIvar = + (self->messageStorage_->_has_storage_[byteIndex] & bitMask) ? YES : NO; + return hasIvar; + } +} + +uint32_t GPBGetHasOneof(GPBMessage *self, int32_t idx) { + NSCAssert(idx < 0, @"%@: invalid index (%d) for oneof.", + [self class], idx); + uint32_t result = self->messageStorage_->_has_storage_[-idx]; + return result; +} + +void GPBSetHasIvar(GPBMessage *self, int32_t idx, uint32_t fieldNumber, + BOOL value) { + if (idx < 0) { + NSCAssert(fieldNumber != 0, @"Invalid field number."); + uint32_t *has_storage = self->messageStorage_->_has_storage_; + has_storage[-idx] = (value ? fieldNumber : 0); + } else { + NSCAssert(idx != GPBNoHasBit, @"Invalid has bit."); + uint32_t *has_storage = self->messageStorage_->_has_storage_; + uint32_t byte = idx / 32; + uint32_t bitMask = (1 << (idx % 32)); + if (value) { + has_storage[byte] |= bitMask; + } else { + has_storage[byte] &= ~bitMask; + } + } +} + +void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof, + int32_t oneofHasIndex, uint32_t fieldNumberNotToClear) { + uint32_t fieldNumberSet = GPBGetHasOneof(self, oneofHasIndex); + if ((fieldNumberSet == fieldNumberNotToClear) || (fieldNumberSet == 0)) { + // Do nothing/nothing set in the oneof. + return; + } + + // Like GPBClearMessageField(), free the memory if an objecttype is set, + // pod types don't need to do anything. + GPBFieldDescriptor *fieldSet = [oneof fieldWithNumber:fieldNumberSet]; + NSCAssert(fieldSet, + @"%@: oneof set to something (%u) not in the oneof?", + [self class], fieldNumberSet); + if (fieldSet && GPBFieldStoresObject(fieldSet)) { + uint8_t *storage = (uint8_t *)self->messageStorage_; + id *typePtr = (id *)&storage[fieldSet->description_->offset]; + [*typePtr release]; + *typePtr = nil; + } + + // Set to nothing stored in the oneof. + // (field number doesn't matter since setting to nothing). + GPBSetHasIvar(self, oneofHasIndex, 1, NO); +} + +#pragma mark - IVar accessors + +//%PDDM-DEFINE IVAR_POD_ACCESSORS_DEFN(NAME, TYPE) +//%TYPE GPBGetMessage##NAME##Field(GPBMessage *self, +//% TYPE$S NAME$S GPBFieldDescriptor *field) { +//% if (GPBGetHasIvarField(self, field)) { +//% uint8_t *storage = (uint8_t *)self->messageStorage_; +//% TYPE *typePtr = (TYPE *)&storage[field->description_->offset]; +//% return *typePtr; +//% } else { +//% return field.defaultValue.value##NAME; +//% } +//%} +//% +//%// Only exists for public api, no core code should use this. +//%void GPBSetMessage##NAME##Field(GPBMessage *self, +//% NAME$S GPBFieldDescriptor *field, +//% NAME$S TYPE value) { +//% if (self == nil || field == nil) return; +//% GPBFileSyntax syntax = [self descriptor].file.syntax; +//% GPBSet##NAME##IvarWithFieldInternal(self, field, value, syntax); +//%} +//% +//%void GPBSet##NAME##IvarWithFieldInternal(GPBMessage *self, +//% NAME$S GPBFieldDescriptor *field, +//% NAME$S TYPE value, +//% NAME$S GPBFileSyntax syntax) { +//% GPBOneofDescriptor *oneof = field->containingOneof_; +//% if (oneof) { +//% GPBMessageFieldDescription *fieldDesc = field->description_; +//% GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); +//% } +//% NSCAssert(self->messageStorage_ != NULL, +//% @"%@: All messages should have storage (from init)", +//% [self class]); +//%#if defined(__clang_analyzer__) +//% if (self->messageStorage_ == NULL) return; +//%#endif +//% uint8_t *storage = (uint8_t *)self->messageStorage_; +//% TYPE *typePtr = (TYPE *)&storage[field->description_->offset]; +//% *typePtr = value; +//% // proto2: any value counts as having been set; proto3, it +//% // has to be a non zero value or be in a oneof. +//% BOOL hasValue = ((syntax == GPBFileSyntaxProto2) +//% || (value != (TYPE)0) +//% || (field->containingOneof_ != NULL)); +//% GPBSetHasIvarField(self, field, hasValue); +//% GPBBecomeVisibleToAutocreator(self); +//%} +//% +//%PDDM-DEFINE IVAR_ALIAS_DEFN_OBJECT(NAME, TYPE) +//%// Only exists for public api, no core code should use this. +//%TYPE *GPBGetMessage##NAME##Field(GPBMessage *self, +//% TYPE$S NAME$S GPBFieldDescriptor *field) { +//% return (TYPE *)GPBGetObjectIvarWithField(self, field); +//%} +//% +//%// Only exists for public api, no core code should use this. +//%void GPBSetMessage##NAME##Field(GPBMessage *self, +//% NAME$S GPBFieldDescriptor *field, +//% NAME$S TYPE *value) { +//% GPBSetObjectIvarWithField(self, field, (id)value); +//%} +//% + +// Object types are handled slightly differently, they need to be released +// and retained. + +void GPBSetAutocreatedRetainedObjectIvarWithField( + GPBMessage *self, GPBFieldDescriptor *field, + id __attribute__((ns_consumed)) value) { + uint8_t *storage = (uint8_t *)self->messageStorage_; + id *typePtr = (id *)&storage[field->description_->offset]; + NSCAssert(*typePtr == NULL, @"Can't set autocreated object more than once."); + *typePtr = value; +} + +void GPBClearAutocreatedMessageIvarWithField(GPBMessage *self, + GPBFieldDescriptor *field) { + if (GPBGetHasIvarField(self, field)) { + return; + } + uint8_t *storage = (uint8_t *)self->messageStorage_; + id *typePtr = (id *)&storage[field->description_->offset]; + GPBMessage *oldValue = *typePtr; + *typePtr = NULL; + GPBClearMessageAutocreator(oldValue); + [oldValue release]; +} + +// This exists only for briging some aliased types, nothing else should use it. +static void GPBSetObjectIvarWithField(GPBMessage *self, + GPBFieldDescriptor *field, id value) { + if (self == nil || field == nil) return; + GPBFileSyntax syntax = [self descriptor].file.syntax; + GPBSetRetainedObjectIvarWithFieldInternal(self, field, [value retain], + syntax); +} + +void GPBSetObjectIvarWithFieldInternal(GPBMessage *self, + GPBFieldDescriptor *field, id value, + GPBFileSyntax syntax) { + GPBSetRetainedObjectIvarWithFieldInternal(self, field, [value retain], + syntax); +} + +void GPBSetRetainedObjectIvarWithFieldInternal(GPBMessage *self, + GPBFieldDescriptor *field, + id value, GPBFileSyntax syntax) { + NSCAssert(self->messageStorage_ != NULL, + @"%@: All messages should have storage (from init)", + [self class]); +#if defined(__clang_analyzer__) + if (self->messageStorage_ == NULL) return; +#endif + GPBDataType fieldType = GPBGetFieldDataType(field); + BOOL isMapOrArray = GPBFieldIsMapOrArray(field); + BOOL fieldIsMessage = GPBDataTypeIsMessage(fieldType); +#ifdef DEBUG + if (value == nil && !isMapOrArray && !fieldIsMessage && + field.hasDefaultValue) { + // Setting a message to nil is an obvious way to "clear" the value + // as there is no way to set a non-empty default value for messages. + // + // For Strings and Bytes that have default values set it is not clear what + // should be done when their value is set to nil. Is the intention just to + // clear the set value and reset to default, or is the intention to set the + // value to the empty string/data? Arguments can be made for both cases. + // 'nil' has been abused as a replacement for an empty string/data in ObjC. + // We decided to be consistent with all "object" types and clear the has + // field, and fall back on the default value. The warning below will only + // appear in debug, but the could should be changed so the intention is + // clear. + NSString *hasSel = NSStringFromSelector(field->hasOrCountSel_); + NSString *propName = field.name; + NSString *className = self.descriptor.name; + NSLog(@"warning: '%@.%@ = nil;' is not clearly defined for fields with " + @"default values. Please use '%@.%@ = %@' if you want to set it to " + @"empty, or call '%@.%@ = NO' to reset it to it's default value of " + @"'%@'. Defaulting to resetting default value.", + className, propName, className, propName, + (fieldType == GPBDataTypeString) ? @"@\"\"" : @"GPBEmptyNSData()", + className, hasSel, field.defaultValue.valueString); + // Note: valueString, depending on the type, it could easily be + // valueData/valueMessage. + } +#endif // DEBUG + if (!isMapOrArray) { + // Non repeated/map can be in an oneof, clear any existing value from the + // oneof. + GPBOneofDescriptor *oneof = field->containingOneof_; + if (oneof) { + GPBMessageFieldDescription *fieldDesc = field->description_; + GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); + } + // Clear "has" if they are being set to nil. + BOOL setHasValue = (value != nil); + // Under proto3, Bytes & String fields get cleared by resetting them to + // their default (empty) values, so if they are set to something of length + // zero, they are being cleared. + if ((syntax == GPBFileSyntaxProto3) && !fieldIsMessage && + ([value length] == 0)) { + // Except, if the field was in a oneof, then it still gets recorded as + // having been set so the state of the oneof can be serialized back out. + if (!oneof) { + setHasValue = NO; + } + if (setHasValue) { + NSCAssert(value != nil, @"Should never be setting has for nil"); + } else { + // The value passed in was retained, it must be released since we + // aren't saving anything in the field. + [value release]; + value = nil; + } + } + GPBSetHasIvarField(self, field, setHasValue); + } + uint8_t *storage = (uint8_t *)self->messageStorage_; + id *typePtr = (id *)&storage[field->description_->offset]; + + id oldValue = *typePtr; + + *typePtr = value; + + if (oldValue) { + if (isMapOrArray) { + if (field.fieldType == GPBFieldTypeRepeated) { + // If the old array was autocreated by us, then clear it. + if (GPBDataTypeIsObject(fieldType)) { + if ([oldValue isKindOfClass:[GPBAutocreatedArray class]]) { + GPBAutocreatedArray *autoArray = oldValue; + if (autoArray->_autocreator == self) { + autoArray->_autocreator = nil; + } + } + } else { + // Type doesn't matter, it is a GPB*Array. + GPBInt32Array *gpbArray = oldValue; + if (gpbArray->_autocreator == self) { + gpbArray->_autocreator = nil; + } + } + } else { // GPBFieldTypeMap + // If the old map was autocreated by us, then clear it. + if ((field.mapKeyDataType == GPBDataTypeString) && + GPBDataTypeIsObject(fieldType)) { + if ([oldValue isKindOfClass:[GPBAutocreatedDictionary class]]) { + GPBAutocreatedDictionary *autoDict = oldValue; + if (autoDict->_autocreator == self) { + autoDict->_autocreator = nil; + } + } + } else { + // Type doesn't matter, it is a GPB*Dictionary. + GPBInt32Int32Dictionary *gpbDict = oldValue; + if (gpbDict->_autocreator == self) { + gpbDict->_autocreator = nil; + } + } + } + } else if (fieldIsMessage) { + // If the old message value was autocreated by us, then clear it. + GPBMessage *oldMessageValue = oldValue; + if (GPBWasMessageAutocreatedBy(oldMessageValue, self)) { + GPBClearMessageAutocreator(oldMessageValue); + } + } + [oldValue release]; + } + + GPBBecomeVisibleToAutocreator(self); +} + +id GPBGetObjectIvarWithFieldNoAutocreate(GPBMessage *self, + GPBFieldDescriptor *field) { + if (self->messageStorage_ == nil) { + return nil; + } + uint8_t *storage = (uint8_t *)self->messageStorage_; + id *typePtr = (id *)&storage[field->description_->offset]; + return *typePtr; +} + +id GPBGetObjectIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) { + NSCAssert(!GPBFieldIsMapOrArray(field), @"Shouldn't get here"); + if (GPBGetHasIvarField(self, field)) { + uint8_t *storage = (uint8_t *)self->messageStorage_; + id *typePtr = (id *)&storage[field->description_->offset]; + return *typePtr; + } + // Not set... + + // Non messages (string/data), get their default. + if (!GPBFieldDataTypeIsMessage(field)) { + return field.defaultValue.valueMessage; + } + + GPBPrepareReadOnlySemaphore(self); + dispatch_semaphore_wait(self->readOnlySemaphore_, DISPATCH_TIME_FOREVER); + GPBMessage *result = GPBGetObjectIvarWithFieldNoAutocreate(self, field); + if (!result) { + // For non repeated messages, create the object, set it and return it. + // This object will not initially be visible via GPBGetHasIvar, so + // we save its creator so it can become visible if it's mutated later. + result = GPBCreateMessageWithAutocreator(field.msgClass, self, field); + GPBSetAutocreatedRetainedObjectIvarWithField(self, field, result); + } + dispatch_semaphore_signal(self->readOnlySemaphore_); + return result; +} + +// Only exists for public api, no core code should use this. +int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field) { + GPBFileSyntax syntax = [self descriptor].file.syntax; + return GPBGetEnumIvarWithFieldInternal(self, field, syntax); +} + +int32_t GPBGetEnumIvarWithFieldInternal(GPBMessage *self, + GPBFieldDescriptor *field, + GPBFileSyntax syntax) { + int32_t result = GPBGetMessageInt32Field(self, field); + // If this is presevering unknown enums, make sure the value is valid before + // returning it. + if (GPBHasPreservingUnknownEnumSemantics(syntax) && + ![field isValidEnumValue:result]) { + result = kGPBUnrecognizedEnumeratorValue; + } + return result; +} + +// Only exists for public api, no core code should use this. +void GPBSetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field, + int32_t value) { + GPBFileSyntax syntax = [self descriptor].file.syntax; + GPBSetInt32IvarWithFieldInternal(self, field, value, syntax); +} + +void GPBSetEnumIvarWithFieldInternal(GPBMessage *self, + GPBFieldDescriptor *field, int32_t value, + GPBFileSyntax syntax) { + // Don't allow in unknown values. Proto3 can use the Raw method. + if (![field isValidEnumValue:value]) { + [NSException raise:NSInvalidArgumentException + format:@"%@.%@: Attempt to set an unknown enum value (%d)", + [self class], field.name, value]; + } + GPBSetInt32IvarWithFieldInternal(self, field, value, syntax); +} + +// Only exists for public api, no core code should use this. +int32_t GPBGetMessageRawEnumField(GPBMessage *self, + GPBFieldDescriptor *field) { + int32_t result = GPBGetMessageInt32Field(self, field); + return result; +} + +// Only exists for public api, no core code should use this. +void GPBSetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field, + int32_t value) { + GPBFileSyntax syntax = [self descriptor].file.syntax; + GPBSetInt32IvarWithFieldInternal(self, field, value, syntax); +} + +BOOL GPBGetMessageBoolField(GPBMessage *self, + GPBFieldDescriptor *field) { + if (GPBGetHasIvarField(self, field)) { + // Bools are stored in the has bits to avoid needing explicit space in the + // storage structure. + // (the field number passed to the HasIvar helper doesn't really matter + // since the offset is never negative) + GPBMessageFieldDescription *fieldDesc = field->description_; + return GPBGetHasIvar(self, (int32_t)(fieldDesc->offset), fieldDesc->number); + } else { + return field.defaultValue.valueBool; + } +} + +// Only exists for public api, no core code should use this. +void GPBSetMessageBoolField(GPBMessage *self, + GPBFieldDescriptor *field, + BOOL value) { + if (self == nil || field == nil) return; + GPBFileSyntax syntax = [self descriptor].file.syntax; + GPBSetBoolIvarWithFieldInternal(self, field, value, syntax); +} + +void GPBSetBoolIvarWithFieldInternal(GPBMessage *self, + GPBFieldDescriptor *field, + BOOL value, + GPBFileSyntax syntax) { + GPBMessageFieldDescription *fieldDesc = field->description_; + GPBOneofDescriptor *oneof = field->containingOneof_; + if (oneof) { + GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); + } + + // Bools are stored in the has bits to avoid needing explicit space in the + // storage structure. + // (the field number passed to the HasIvar helper doesn't really matter since + // the offset is never negative) + GPBSetHasIvar(self, (int32_t)(fieldDesc->offset), fieldDesc->number, value); + + // proto2: any value counts as having been set; proto3, it + // has to be a non zero value or be in a oneof. + BOOL hasValue = ((syntax == GPBFileSyntaxProto2) + || (value != (BOOL)0) + || (field->containingOneof_ != NULL)); + GPBSetHasIvarField(self, field, hasValue); + GPBBecomeVisibleToAutocreator(self); +} + +//%PDDM-EXPAND IVAR_POD_ACCESSORS_DEFN(Int32, int32_t) +// This block of code is generated, do not edit it directly. + +int32_t GPBGetMessageInt32Field(GPBMessage *self, + GPBFieldDescriptor *field) { + if (GPBGetHasIvarField(self, field)) { + uint8_t *storage = (uint8_t *)self->messageStorage_; + int32_t *typePtr = (int32_t *)&storage[field->description_->offset]; + return *typePtr; + } else { + return field.defaultValue.valueInt32; + } +} + +// Only exists for public api, no core code should use this. +void GPBSetMessageInt32Field(GPBMessage *self, + GPBFieldDescriptor *field, + int32_t value) { + if (self == nil || field == nil) return; + GPBFileSyntax syntax = [self descriptor].file.syntax; + GPBSetInt32IvarWithFieldInternal(self, field, value, syntax); +} + +void GPBSetInt32IvarWithFieldInternal(GPBMessage *self, + GPBFieldDescriptor *field, + int32_t value, + GPBFileSyntax syntax) { + GPBOneofDescriptor *oneof = field->containingOneof_; + if (oneof) { + GPBMessageFieldDescription *fieldDesc = field->description_; + GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); + } + NSCAssert(self->messageStorage_ != NULL, + @"%@: All messages should have storage (from init)", + [self class]); +#if defined(__clang_analyzer__) + if (self->messageStorage_ == NULL) return; +#endif + uint8_t *storage = (uint8_t *)self->messageStorage_; + int32_t *typePtr = (int32_t *)&storage[field->description_->offset]; + *typePtr = value; + // proto2: any value counts as having been set; proto3, it + // has to be a non zero value or be in a oneof. + BOOL hasValue = ((syntax == GPBFileSyntaxProto2) + || (value != (int32_t)0) + || (field->containingOneof_ != NULL)); + GPBSetHasIvarField(self, field, hasValue); + GPBBecomeVisibleToAutocreator(self); +} + +//%PDDM-EXPAND IVAR_POD_ACCESSORS_DEFN(UInt32, uint32_t) +// This block of code is generated, do not edit it directly. + +uint32_t GPBGetMessageUInt32Field(GPBMessage *self, + GPBFieldDescriptor *field) { + if (GPBGetHasIvarField(self, field)) { + uint8_t *storage = (uint8_t *)self->messageStorage_; + uint32_t *typePtr = (uint32_t *)&storage[field->description_->offset]; + return *typePtr; + } else { + return field.defaultValue.valueUInt32; + } +} + +// Only exists for public api, no core code should use this. +void GPBSetMessageUInt32Field(GPBMessage *self, + GPBFieldDescriptor *field, + uint32_t value) { + if (self == nil || field == nil) return; + GPBFileSyntax syntax = [self descriptor].file.syntax; + GPBSetUInt32IvarWithFieldInternal(self, field, value, syntax); +} + +void GPBSetUInt32IvarWithFieldInternal(GPBMessage *self, + GPBFieldDescriptor *field, + uint32_t value, + GPBFileSyntax syntax) { + GPBOneofDescriptor *oneof = field->containingOneof_; + if (oneof) { + GPBMessageFieldDescription *fieldDesc = field->description_; + GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); + } + NSCAssert(self->messageStorage_ != NULL, + @"%@: All messages should have storage (from init)", + [self class]); +#if defined(__clang_analyzer__) + if (self->messageStorage_ == NULL) return; +#endif + uint8_t *storage = (uint8_t *)self->messageStorage_; + uint32_t *typePtr = (uint32_t *)&storage[field->description_->offset]; + *typePtr = value; + // proto2: any value counts as having been set; proto3, it + // has to be a non zero value or be in a oneof. + BOOL hasValue = ((syntax == GPBFileSyntaxProto2) + || (value != (uint32_t)0) + || (field->containingOneof_ != NULL)); + GPBSetHasIvarField(self, field, hasValue); + GPBBecomeVisibleToAutocreator(self); +} + +//%PDDM-EXPAND IVAR_POD_ACCESSORS_DEFN(Int64, int64_t) +// This block of code is generated, do not edit it directly. + +int64_t GPBGetMessageInt64Field(GPBMessage *self, + GPBFieldDescriptor *field) { + if (GPBGetHasIvarField(self, field)) { + uint8_t *storage = (uint8_t *)self->messageStorage_; + int64_t *typePtr = (int64_t *)&storage[field->description_->offset]; + return *typePtr; + } else { + return field.defaultValue.valueInt64; + } +} + +// Only exists for public api, no core code should use this. +void GPBSetMessageInt64Field(GPBMessage *self, + GPBFieldDescriptor *field, + int64_t value) { + if (self == nil || field == nil) return; + GPBFileSyntax syntax = [self descriptor].file.syntax; + GPBSetInt64IvarWithFieldInternal(self, field, value, syntax); +} + +void GPBSetInt64IvarWithFieldInternal(GPBMessage *self, + GPBFieldDescriptor *field, + int64_t value, + GPBFileSyntax syntax) { + GPBOneofDescriptor *oneof = field->containingOneof_; + if (oneof) { + GPBMessageFieldDescription *fieldDesc = field->description_; + GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); + } + NSCAssert(self->messageStorage_ != NULL, + @"%@: All messages should have storage (from init)", + [self class]); +#if defined(__clang_analyzer__) + if (self->messageStorage_ == NULL) return; +#endif + uint8_t *storage = (uint8_t *)self->messageStorage_; + int64_t *typePtr = (int64_t *)&storage[field->description_->offset]; + *typePtr = value; + // proto2: any value counts as having been set; proto3, it + // has to be a non zero value or be in a oneof. + BOOL hasValue = ((syntax == GPBFileSyntaxProto2) + || (value != (int64_t)0) + || (field->containingOneof_ != NULL)); + GPBSetHasIvarField(self, field, hasValue); + GPBBecomeVisibleToAutocreator(self); +} + +//%PDDM-EXPAND IVAR_POD_ACCESSORS_DEFN(UInt64, uint64_t) +// This block of code is generated, do not edit it directly. + +uint64_t GPBGetMessageUInt64Field(GPBMessage *self, + GPBFieldDescriptor *field) { + if (GPBGetHasIvarField(self, field)) { + uint8_t *storage = (uint8_t *)self->messageStorage_; + uint64_t *typePtr = (uint64_t *)&storage[field->description_->offset]; + return *typePtr; + } else { + return field.defaultValue.valueUInt64; + } +} + +// Only exists for public api, no core code should use this. +void GPBSetMessageUInt64Field(GPBMessage *self, + GPBFieldDescriptor *field, + uint64_t value) { + if (self == nil || field == nil) return; + GPBFileSyntax syntax = [self descriptor].file.syntax; + GPBSetUInt64IvarWithFieldInternal(self, field, value, syntax); +} + +void GPBSetUInt64IvarWithFieldInternal(GPBMessage *self, + GPBFieldDescriptor *field, + uint64_t value, + GPBFileSyntax syntax) { + GPBOneofDescriptor *oneof = field->containingOneof_; + if (oneof) { + GPBMessageFieldDescription *fieldDesc = field->description_; + GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); + } + NSCAssert(self->messageStorage_ != NULL, + @"%@: All messages should have storage (from init)", + [self class]); +#if defined(__clang_analyzer__) + if (self->messageStorage_ == NULL) return; +#endif + uint8_t *storage = (uint8_t *)self->messageStorage_; + uint64_t *typePtr = (uint64_t *)&storage[field->description_->offset]; + *typePtr = value; + // proto2: any value counts as having been set; proto3, it + // has to be a non zero value or be in a oneof. + BOOL hasValue = ((syntax == GPBFileSyntaxProto2) + || (value != (uint64_t)0) + || (field->containingOneof_ != NULL)); + GPBSetHasIvarField(self, field, hasValue); + GPBBecomeVisibleToAutocreator(self); +} + +//%PDDM-EXPAND IVAR_POD_ACCESSORS_DEFN(Float, float) +// This block of code is generated, do not edit it directly. + +float GPBGetMessageFloatField(GPBMessage *self, + GPBFieldDescriptor *field) { + if (GPBGetHasIvarField(self, field)) { + uint8_t *storage = (uint8_t *)self->messageStorage_; + float *typePtr = (float *)&storage[field->description_->offset]; + return *typePtr; + } else { + return field.defaultValue.valueFloat; + } +} + +// Only exists for public api, no core code should use this. +void GPBSetMessageFloatField(GPBMessage *self, + GPBFieldDescriptor *field, + float value) { + if (self == nil || field == nil) return; + GPBFileSyntax syntax = [self descriptor].file.syntax; + GPBSetFloatIvarWithFieldInternal(self, field, value, syntax); +} + +void GPBSetFloatIvarWithFieldInternal(GPBMessage *self, + GPBFieldDescriptor *field, + float value, + GPBFileSyntax syntax) { + GPBOneofDescriptor *oneof = field->containingOneof_; + if (oneof) { + GPBMessageFieldDescription *fieldDesc = field->description_; + GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); + } + NSCAssert(self->messageStorage_ != NULL, + @"%@: All messages should have storage (from init)", + [self class]); +#if defined(__clang_analyzer__) + if (self->messageStorage_ == NULL) return; +#endif + uint8_t *storage = (uint8_t *)self->messageStorage_; + float *typePtr = (float *)&storage[field->description_->offset]; + *typePtr = value; + // proto2: any value counts as having been set; proto3, it + // has to be a non zero value or be in a oneof. + BOOL hasValue = ((syntax == GPBFileSyntaxProto2) + || (value != (float)0) + || (field->containingOneof_ != NULL)); + GPBSetHasIvarField(self, field, hasValue); + GPBBecomeVisibleToAutocreator(self); +} + +//%PDDM-EXPAND IVAR_POD_ACCESSORS_DEFN(Double, double) +// This block of code is generated, do not edit it directly. + +double GPBGetMessageDoubleField(GPBMessage *self, + GPBFieldDescriptor *field) { + if (GPBGetHasIvarField(self, field)) { + uint8_t *storage = (uint8_t *)self->messageStorage_; + double *typePtr = (double *)&storage[field->description_->offset]; + return *typePtr; + } else { + return field.defaultValue.valueDouble; + } +} + +// Only exists for public api, no core code should use this. +void GPBSetMessageDoubleField(GPBMessage *self, + GPBFieldDescriptor *field, + double value) { + if (self == nil || field == nil) return; + GPBFileSyntax syntax = [self descriptor].file.syntax; + GPBSetDoubleIvarWithFieldInternal(self, field, value, syntax); +} + +void GPBSetDoubleIvarWithFieldInternal(GPBMessage *self, + GPBFieldDescriptor *field, + double value, + GPBFileSyntax syntax) { + GPBOneofDescriptor *oneof = field->containingOneof_; + if (oneof) { + GPBMessageFieldDescription *fieldDesc = field->description_; + GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); + } + NSCAssert(self->messageStorage_ != NULL, + @"%@: All messages should have storage (from init)", + [self class]); +#if defined(__clang_analyzer__) + if (self->messageStorage_ == NULL) return; +#endif + uint8_t *storage = (uint8_t *)self->messageStorage_; + double *typePtr = (double *)&storage[field->description_->offset]; + *typePtr = value; + // proto2: any value counts as having been set; proto3, it + // has to be a non zero value or be in a oneof. + BOOL hasValue = ((syntax == GPBFileSyntaxProto2) + || (value != (double)0) + || (field->containingOneof_ != NULL)); + GPBSetHasIvarField(self, field, hasValue); + GPBBecomeVisibleToAutocreator(self); +} + +//%PDDM-EXPAND-END (6 expansions) + +// Aliases are function calls that are virtually the same. + +//%PDDM-EXPAND IVAR_ALIAS_DEFN_OBJECT(String, NSString) +// This block of code is generated, do not edit it directly. + +// Only exists for public api, no core code should use this. +NSString *GPBGetMessageStringField(GPBMessage *self, + GPBFieldDescriptor *field) { + return (NSString *)GPBGetObjectIvarWithField(self, field); +} + +// Only exists for public api, no core code should use this. +void GPBSetMessageStringField(GPBMessage *self, + GPBFieldDescriptor *field, + NSString *value) { + GPBSetObjectIvarWithField(self, field, (id)value); +} + +//%PDDM-EXPAND IVAR_ALIAS_DEFN_OBJECT(Bytes, NSData) +// This block of code is generated, do not edit it directly. + +// Only exists for public api, no core code should use this. +NSData *GPBGetMessageBytesField(GPBMessage *self, + GPBFieldDescriptor *field) { + return (NSData *)GPBGetObjectIvarWithField(self, field); +} + +// Only exists for public api, no core code should use this. +void GPBSetMessageBytesField(GPBMessage *self, + GPBFieldDescriptor *field, + NSData *value) { + GPBSetObjectIvarWithField(self, field, (id)value); +} + +//%PDDM-EXPAND IVAR_ALIAS_DEFN_OBJECT(Message, GPBMessage) +// This block of code is generated, do not edit it directly. + +// Only exists for public api, no core code should use this. +GPBMessage *GPBGetMessageMessageField(GPBMessage *self, + GPBFieldDescriptor *field) { + return (GPBMessage *)GPBGetObjectIvarWithField(self, field); +} + +// Only exists for public api, no core code should use this. +void GPBSetMessageMessageField(GPBMessage *self, + GPBFieldDescriptor *field, + GPBMessage *value) { + GPBSetObjectIvarWithField(self, field, (id)value); +} + +//%PDDM-EXPAND IVAR_ALIAS_DEFN_OBJECT(Group, GPBMessage) +// This block of code is generated, do not edit it directly. + +// Only exists for public api, no core code should use this. +GPBMessage *GPBGetMessageGroupField(GPBMessage *self, + GPBFieldDescriptor *field) { + return (GPBMessage *)GPBGetObjectIvarWithField(self, field); +} + +// Only exists for public api, no core code should use this. +void GPBSetMessageGroupField(GPBMessage *self, + GPBFieldDescriptor *field, + GPBMessage *value) { + GPBSetObjectIvarWithField(self, field, (id)value); +} + +//%PDDM-EXPAND-END (4 expansions) + +// GPBGetMessageRepeatedField is defined in GPBMessage.m + +// Only exists for public api, no core code should use this. +void GPBSetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field, id array) { +#if defined(DEBUG) && DEBUG + if (field.fieldType != GPBFieldTypeRepeated) { + [NSException raise:NSInvalidArgumentException + format:@"%@.%@ is not a repeated field.", + [self class], field.name]; + } + Class expectedClass = Nil; + switch (GPBGetFieldDataType(field)) { + case GPBDataTypeBool: + expectedClass = [GPBBoolArray class]; + break; + case GPBDataTypeSFixed32: + case GPBDataTypeInt32: + case GPBDataTypeSInt32: + expectedClass = [GPBInt32Array class]; + break; + case GPBDataTypeFixed32: + case GPBDataTypeUInt32: + expectedClass = [GPBUInt32Array class]; + break; + case GPBDataTypeSFixed64: + case GPBDataTypeInt64: + case GPBDataTypeSInt64: + expectedClass = [GPBInt64Array class]; + break; + case GPBDataTypeFixed64: + case GPBDataTypeUInt64: + expectedClass = [GPBUInt64Array class]; + break; + case GPBDataTypeFloat: + expectedClass = [GPBFloatArray class]; + break; + case GPBDataTypeDouble: + expectedClass = [GPBDoubleArray class]; + break; + case GPBDataTypeBytes: + case GPBDataTypeString: + case GPBDataTypeMessage: + case GPBDataTypeGroup: + expectedClass = [NSMutableArray class]; + break; + case GPBDataTypeEnum: + expectedClass = [GPBEnumArray class]; + break; + } + if (array && ![array isKindOfClass:expectedClass]) { + [NSException raise:NSInvalidArgumentException + format:@"%@.%@: Expected %@ object, got %@.", + [self class], field.name, expectedClass, [array class]]; + } +#endif + GPBSetObjectIvarWithField(self, field, array); +} + +#if defined(DEBUG) && DEBUG +static NSString *TypeToStr(GPBDataType dataType) { + switch (dataType) { + case GPBDataTypeBool: + return @"Bool"; + case GPBDataTypeSFixed32: + case GPBDataTypeInt32: + case GPBDataTypeSInt32: + return @"Int32"; + case GPBDataTypeFixed32: + case GPBDataTypeUInt32: + return @"UInt32"; + case GPBDataTypeSFixed64: + case GPBDataTypeInt64: + case GPBDataTypeSInt64: + return @"Int64"; + case GPBDataTypeFixed64: + case GPBDataTypeUInt64: + return @"UInt64"; + case GPBDataTypeFloat: + return @"Float"; + case GPBDataTypeDouble: + return @"Double"; + case GPBDataTypeBytes: + case GPBDataTypeString: + case GPBDataTypeMessage: + case GPBDataTypeGroup: + return @"Object"; + case GPBDataTypeEnum: + return @"Bool"; + } +} +#endif + +// GPBGetMessageMapField is defined in GPBMessage.m + +// Only exists for public api, no core code should use this. +void GPBSetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field, + id dictionary) { +#if defined(DEBUG) && DEBUG + if (field.fieldType != GPBFieldTypeMap) { + [NSException raise:NSInvalidArgumentException + format:@"%@.%@ is not a map<> field.", + [self class], field.name]; + } + if (dictionary) { + GPBDataType keyDataType = field.mapKeyDataType; + GPBDataType valueDataType = GPBGetFieldDataType(field); + NSString *keyStr = TypeToStr(keyDataType); + NSString *valueStr = TypeToStr(valueDataType); + if (keyDataType == GPBDataTypeString) { + keyStr = @"String"; + } + Class expectedClass = Nil; + if ((keyDataType == GPBDataTypeString) && + GPBDataTypeIsObject(valueDataType)) { + expectedClass = [NSMutableDictionary class]; + } else { + NSString *className = + [NSString stringWithFormat:@"GPB%@%@Dictionary", keyStr, valueStr]; + expectedClass = NSClassFromString(className); + NSCAssert(expectedClass, @"Missing a class (%@)?", expectedClass); + } + if (![dictionary isKindOfClass:expectedClass]) { + [NSException raise:NSInvalidArgumentException + format:@"%@.%@: Expected %@ object, got %@.", + [self class], field.name, expectedClass, + [dictionary class]]; + } + } +#endif + GPBSetObjectIvarWithField(self, field, dictionary); +} + +#pragma mark - Misc Dynamic Runtime Utils + +const char *GPBMessageEncodingForSelector(SEL selector, BOOL instanceSel) { + Protocol *protocol = + objc_getProtocol(GPBStringifySymbol(GPBMessageSignatureProtocol)); + struct objc_method_description description = + protocol_getMethodDescription(protocol, selector, NO, instanceSel); + return description.types; +} + +#pragma mark - Text Format Support + +static void AppendStringEscaped(NSString *toPrint, NSMutableString *destStr) { + [destStr appendString:@"\""]; + NSUInteger len = [toPrint length]; + for (NSUInteger i = 0; i < len; ++i) { + unichar aChar = [toPrint characterAtIndex:i]; + switch (aChar) { + case '\n': [destStr appendString:@"\\n"]; break; + case '\r': [destStr appendString:@"\\r"]; break; + case '\t': [destStr appendString:@"\\t"]; break; + case '\"': [destStr appendString:@"\\\""]; break; + case '\'': [destStr appendString:@"\\\'"]; break; + case '\\': [destStr appendString:@"\\\\"]; break; + default: + // This differs slightly from the C++ code in that the C++ doesn't + // generate UTF8; it looks at the string in UTF8, but escapes every + // byte > 0x7E. + if (aChar < 0x20) { + [destStr appendFormat:@"\\%d%d%d", + (aChar / 64), ((aChar % 64) / 8), (aChar % 8)]; + } else { + [destStr appendFormat:@"%C", aChar]; + } + break; + } + } + [destStr appendString:@"\""]; +} + +static void AppendBufferAsString(NSData *buffer, NSMutableString *destStr) { + const char *src = (const char *)[buffer bytes]; + size_t srcLen = [buffer length]; + [destStr appendString:@"\""]; + for (const char *srcEnd = src + srcLen; src < srcEnd; src++) { + switch (*src) { + case '\n': [destStr appendString:@"\\n"]; break; + case '\r': [destStr appendString:@"\\r"]; break; + case '\t': [destStr appendString:@"\\t"]; break; + case '\"': [destStr appendString:@"\\\""]; break; + case '\'': [destStr appendString:@"\\\'"]; break; + case '\\': [destStr appendString:@"\\\\"]; break; + default: + if (isprint(*src)) { + [destStr appendFormat:@"%c", *src]; + } else { + // NOTE: doing hex means you have to worry about the letter after + // the hex being another hex char and forcing that to be escaped, so + // use octal to keep it simple. + [destStr appendFormat:@"\\%03o", (uint8_t)(*src)]; + } + break; + } + } + [destStr appendString:@"\""]; +} + +static void AppendTextFormatForMapMessageField( + id map, GPBFieldDescriptor *field, NSMutableString *toStr, + NSString *lineIndent, NSString *fieldName, NSString *lineEnding) { + GPBDataType keyDataType = field.mapKeyDataType; + GPBDataType valueDataType = GPBGetFieldDataType(field); + BOOL isMessageValue = GPBDataTypeIsMessage(valueDataType); + + NSString *msgStartFirst = + [NSString stringWithFormat:@"%@%@ {%@\n", lineIndent, fieldName, lineEnding]; + NSString *msgStart = + [NSString stringWithFormat:@"%@%@ {\n", lineIndent, fieldName]; + NSString *msgEnd = [NSString stringWithFormat:@"%@}\n", lineIndent]; + + NSString *keyLine = [NSString stringWithFormat:@"%@ key: ", lineIndent]; + NSString *valueLine = [NSString stringWithFormat:@"%@ value%s ", lineIndent, + (isMessageValue ? "" : ":")]; + + __block BOOL isFirst = YES; + + if ((keyDataType == GPBDataTypeString) && + GPBDataTypeIsObject(valueDataType)) { + // map is an NSDictionary. + NSDictionary *dict = map; + [dict enumerateKeysAndObjectsUsingBlock:^(NSString *key, id value, BOOL *stop) { + #pragma unused(stop) + [toStr appendString:(isFirst ? msgStartFirst : msgStart)]; + isFirst = NO; + + [toStr appendString:keyLine]; + AppendStringEscaped(key, toStr); + [toStr appendString:@"\n"]; + + [toStr appendString:valueLine]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wswitch-enum" + switch (valueDataType) { + case GPBDataTypeString: + AppendStringEscaped(value, toStr); + break; + + case GPBDataTypeBytes: + AppendBufferAsString(value, toStr); + break; + + case GPBDataTypeMessage: + [toStr appendString:@"{\n"]; + NSString *subIndent = [lineIndent stringByAppendingString:@" "]; + AppendTextFormatForMessage(value, toStr, subIndent); + [toStr appendFormat:@"%@ }", lineIndent]; + break; + + default: + NSCAssert(NO, @"Can't happen"); + break; + } +#pragma clang diagnostic pop + [toStr appendString:@"\n"]; + + [toStr appendString:msgEnd]; + }]; + } else { + // map is one of the GPB*Dictionary classes, type doesn't matter. + GPBInt32Int32Dictionary *dict = map; + [dict enumerateForTextFormat:^(id keyObj, id valueObj) { + [toStr appendString:(isFirst ? msgStartFirst : msgStart)]; + isFirst = NO; + + // Key always is a NSString. + if (keyDataType == GPBDataTypeString) { + [toStr appendString:keyLine]; + AppendStringEscaped(keyObj, toStr); + [toStr appendString:@"\n"]; + } else { + [toStr appendFormat:@"%@%@\n", keyLine, keyObj]; + } + + [toStr appendString:valueLine]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wswitch-enum" + switch (valueDataType) { + case GPBDataTypeString: + AppendStringEscaped(valueObj, toStr); + break; + + case GPBDataTypeBytes: + AppendBufferAsString(valueObj, toStr); + break; + + case GPBDataTypeMessage: + [toStr appendString:@"{\n"]; + NSString *subIndent = [lineIndent stringByAppendingString:@" "]; + AppendTextFormatForMessage(valueObj, toStr, subIndent); + [toStr appendFormat:@"%@ }", lineIndent]; + break; + + case GPBDataTypeEnum: { + int32_t enumValue = [valueObj intValue]; + NSString *valueStr = nil; + GPBEnumDescriptor *descriptor = field.enumDescriptor; + if (descriptor) { + valueStr = [descriptor textFormatNameForValue:enumValue]; + } + if (valueStr) { + [toStr appendString:valueStr]; + } else { + [toStr appendFormat:@"%d", enumValue]; + } + break; + } + + default: + NSCAssert(valueDataType != GPBDataTypeGroup, @"Can't happen"); + // Everything else is a NSString. + [toStr appendString:valueObj]; + break; + } +#pragma clang diagnostic pop + [toStr appendString:@"\n"]; + + [toStr appendString:msgEnd]; + }]; + } +} + +static void AppendTextFormatForMessageField(GPBMessage *message, + GPBFieldDescriptor *field, + NSMutableString *toStr, + NSString *lineIndent) { + id arrayOrMap; + NSUInteger count; + GPBFieldType fieldType = field.fieldType; + switch (fieldType) { + case GPBFieldTypeSingle: + arrayOrMap = nil; + count = (GPBGetHasIvarField(message, field) ? 1 : 0); + break; + + case GPBFieldTypeRepeated: + // Will be NSArray or GPB*Array, type doesn't matter, they both + // implement count. + arrayOrMap = GPBGetObjectIvarWithFieldNoAutocreate(message, field); + count = [(NSArray *)arrayOrMap count]; + break; + + case GPBFieldTypeMap: { + // Will be GPB*Dictionary or NSMutableDictionary, type doesn't matter, + // they both implement count. + arrayOrMap = GPBGetObjectIvarWithFieldNoAutocreate(message, field); + count = [(NSDictionary *)arrayOrMap count]; + break; + } + } + + if (count == 0) { + // Nothing to print, out of here. + return; + } + + NSString *lineEnding = @""; + + // If the name can't be reversed or support for extra info was turned off, + // this can return nil. + NSString *fieldName = [field textFormatName]; + if ([fieldName length] == 0) { + fieldName = [NSString stringWithFormat:@"%u", GPBFieldNumber(field)]; + // If there is only one entry, put the objc name as a comment, other wise + // add it before the repeated values. + if (count > 1) { + [toStr appendFormat:@"%@# %@\n", lineIndent, field.name]; + } else { + lineEnding = [NSString stringWithFormat:@" # %@", field.name]; + } + } + + if (fieldType == GPBFieldTypeMap) { + AppendTextFormatForMapMessageField(arrayOrMap, field, toStr, lineIndent, + fieldName, lineEnding); + return; + } + + id array = arrayOrMap; + const BOOL isRepeated = (array != nil); + + GPBDataType fieldDataType = GPBGetFieldDataType(field); + BOOL isMessageField = GPBDataTypeIsMessage(fieldDataType); + for (NSUInteger j = 0; j < count; ++j) { + // Start the line. + [toStr appendFormat:@"%@%@%s ", lineIndent, fieldName, + (isMessageField ? "" : ":")]; + + // The value. + switch (fieldDataType) { +#define FIELD_CASE(GPBDATATYPE, CTYPE, REAL_TYPE, ...) \ + case GPBDataType##GPBDATATYPE: { \ + CTYPE v = (isRepeated ? [(GPB##REAL_TYPE##Array *)array valueAtIndex:j] \ + : GPBGetMessage##REAL_TYPE##Field(message, field)); \ + [toStr appendFormat:__VA_ARGS__, v]; \ + break; \ + } + + FIELD_CASE(Int32, int32_t, Int32, @"%d") + FIELD_CASE(SInt32, int32_t, Int32, @"%d") + FIELD_CASE(SFixed32, int32_t, Int32, @"%d") + FIELD_CASE(UInt32, uint32_t, UInt32, @"%u") + FIELD_CASE(Fixed32, uint32_t, UInt32, @"%u") + FIELD_CASE(Int64, int64_t, Int64, @"%lld") + FIELD_CASE(SInt64, int64_t, Int64, @"%lld") + FIELD_CASE(SFixed64, int64_t, Int64, @"%lld") + FIELD_CASE(UInt64, uint64_t, UInt64, @"%llu") + FIELD_CASE(Fixed64, uint64_t, UInt64, @"%llu") + FIELD_CASE(Float, float, Float, @"%.*g", FLT_DIG) + FIELD_CASE(Double, double, Double, @"%.*lg", DBL_DIG) + +#undef FIELD_CASE + + case GPBDataTypeEnum: { + int32_t v = (isRepeated ? [(GPBEnumArray *)array rawValueAtIndex:j] + : GPBGetMessageInt32Field(message, field)); + NSString *valueStr = nil; + GPBEnumDescriptor *descriptor = field.enumDescriptor; + if (descriptor) { + valueStr = [descriptor textFormatNameForValue:v]; + } + if (valueStr) { + [toStr appendString:valueStr]; + } else { + [toStr appendFormat:@"%d", v]; + } + break; + } + + case GPBDataTypeBool: { + BOOL v = (isRepeated ? [(GPBBoolArray *)array valueAtIndex:j] + : GPBGetMessageBoolField(message, field)); + [toStr appendString:(v ? @"true" : @"false")]; + break; + } + + case GPBDataTypeString: { + NSString *v = (isRepeated ? [(NSArray *)array objectAtIndex:j] + : GPBGetMessageStringField(message, field)); + AppendStringEscaped(v, toStr); + break; + } + + case GPBDataTypeBytes: { + NSData *v = (isRepeated ? [(NSArray *)array objectAtIndex:j] + : GPBGetMessageBytesField(message, field)); + AppendBufferAsString(v, toStr); + break; + } + + case GPBDataTypeGroup: + case GPBDataTypeMessage: { + GPBMessage *v = + (isRepeated ? [(NSArray *)array objectAtIndex:j] + : GPBGetObjectIvarWithField(message, field)); + [toStr appendFormat:@"{%@\n", lineEnding]; + NSString *subIndent = [lineIndent stringByAppendingString:@" "]; + AppendTextFormatForMessage(v, toStr, subIndent); + [toStr appendFormat:@"%@}", lineIndent]; + lineEnding = @""; + break; + } + + } // switch(fieldDataType) + + // End the line. + [toStr appendFormat:@"%@\n", lineEnding]; + + } // for(count) +} + +static void AppendTextFormatForMessageExtensionRange(GPBMessage *message, + NSArray *activeExtensions, + GPBExtensionRange range, + NSMutableString *toStr, + NSString *lineIndent) { + uint32_t start = range.start; + uint32_t end = range.end; + for (GPBExtensionDescriptor *extension in activeExtensions) { + uint32_t fieldNumber = extension.fieldNumber; + if (fieldNumber < start) { + // Not there yet. + continue; + } + if (fieldNumber > end) { + // Done. + break; + } + + id rawExtValue = [message getExtension:extension]; + BOOL isRepeated = extension.isRepeated; + + NSUInteger numValues = 1; + NSString *lineEnding = @""; + if (isRepeated) { + numValues = [(NSArray *)rawExtValue count]; + } + + NSString *singletonName = extension.singletonName; + if (numValues == 1) { + lineEnding = [NSString stringWithFormat:@" # [%@]", singletonName]; + } else { + [toStr appendFormat:@"%@# [%@]\n", lineIndent, singletonName]; + } + + GPBDataType extDataType = extension.dataType; + for (NSUInteger j = 0; j < numValues; ++j) { + id curValue = (isRepeated ? [rawExtValue objectAtIndex:j] : rawExtValue); + + // Start the line. + [toStr appendFormat:@"%@%u%s ", lineIndent, fieldNumber, + (GPBDataTypeIsMessage(extDataType) ? "" : ":")]; + + // The value. + switch (extDataType) { +#define FIELD_CASE(GPBDATATYPE, CTYPE, NUMSELECTOR, ...) \ + case GPBDataType##GPBDATATYPE: { \ + CTYPE v = [(NSNumber *)curValue NUMSELECTOR]; \ + [toStr appendFormat:__VA_ARGS__, v]; \ + break; \ + } + + FIELD_CASE(Int32, int32_t, intValue, @"%d") + FIELD_CASE(SInt32, int32_t, intValue, @"%d") + FIELD_CASE(SFixed32, int32_t, unsignedIntValue, @"%d") + FIELD_CASE(UInt32, uint32_t, unsignedIntValue, @"%u") + FIELD_CASE(Fixed32, uint32_t, unsignedIntValue, @"%u") + FIELD_CASE(Int64, int64_t, longLongValue, @"%lld") + FIELD_CASE(SInt64, int64_t, longLongValue, @"%lld") + FIELD_CASE(SFixed64, int64_t, longLongValue, @"%lld") + FIELD_CASE(UInt64, uint64_t, unsignedLongLongValue, @"%llu") + FIELD_CASE(Fixed64, uint64_t, unsignedLongLongValue, @"%llu") + FIELD_CASE(Float, float, floatValue, @"%.*g", FLT_DIG) + FIELD_CASE(Double, double, doubleValue, @"%.*lg", DBL_DIG) + // TODO: Add a comment with the enum name from enum descriptors + // (might not be real value, so leave it as a comment, ObjC compiler + // name mangles differently). Doesn't look like we actually generate + // an enum descriptor reference like we do for normal fields, so this + // will take a compiler change. + FIELD_CASE(Enum, int32_t, intValue, @"%d") + +#undef FIELD_CASE + + case GPBDataTypeBool: + [toStr appendString:([(NSNumber *)curValue boolValue] ? @"true" + : @"false")]; + break; + + case GPBDataTypeString: + AppendStringEscaped(curValue, toStr); + break; + + case GPBDataTypeBytes: + AppendBufferAsString((NSData *)curValue, toStr); + break; + + case GPBDataTypeGroup: + case GPBDataTypeMessage: { + [toStr appendFormat:@"{%@\n", lineEnding]; + NSString *subIndent = [lineIndent stringByAppendingString:@" "]; + AppendTextFormatForMessage(curValue, toStr, subIndent); + [toStr appendFormat:@"%@}", lineIndent]; + lineEnding = @""; + break; + } + + } // switch(extDataType) + + } // for(numValues) + + // End the line. + [toStr appendFormat:@"%@\n", lineEnding]; + + } // for..in(activeExtensions) +} + +static void AppendTextFormatForMessage(GPBMessage *message, + NSMutableString *toStr, + NSString *lineIndent) { + GPBDescriptor *descriptor = [message descriptor]; + NSArray *fieldsArray = descriptor->fields_; + NSUInteger fieldCount = fieldsArray.count; + const GPBExtensionRange *extensionRanges = descriptor.extensionRanges; + NSUInteger extensionRangesCount = descriptor.extensionRangesCount; + NSArray *activeExtensions = [[message extensionsCurrentlySet] + sortedArrayUsingSelector:@selector(compareByFieldNumber:)]; + for (NSUInteger i = 0, j = 0; i < fieldCount || j < extensionRangesCount;) { + if (i == fieldCount) { + AppendTextFormatForMessageExtensionRange( + message, activeExtensions, extensionRanges[j++], toStr, lineIndent); + } else if (j == extensionRangesCount || + GPBFieldNumber(fieldsArray[i]) < extensionRanges[j].start) { + AppendTextFormatForMessageField(message, fieldsArray[i++], toStr, + lineIndent); + } else { + AppendTextFormatForMessageExtensionRange( + message, activeExtensions, extensionRanges[j++], toStr, lineIndent); + } + } + + NSString *unknownFieldsStr = + GPBTextFormatForUnknownFieldSet(message.unknownFields, lineIndent); + if ([unknownFieldsStr length] > 0) { + [toStr appendFormat:@"%@# --- Unknown fields ---\n", lineIndent]; + [toStr appendString:unknownFieldsStr]; + } +} + +NSString *GPBTextFormatForMessage(GPBMessage *message, NSString *lineIndent) { + if (message == nil) return @""; + if (lineIndent == nil) lineIndent = @""; + + NSMutableString *buildString = [NSMutableString string]; + AppendTextFormatForMessage(message, buildString, lineIndent); + return buildString; +} + +NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet *unknownSet, + NSString *lineIndent) { + if (unknownSet == nil) return @""; + if (lineIndent == nil) lineIndent = @""; + + NSMutableString *result = [NSMutableString string]; + for (GPBUnknownField *field in [unknownSet sortedFields]) { + int32_t fieldNumber = [field number]; + +#define PRINT_LOOP(PROPNAME, CTYPE, FORMAT) \ + [field.PROPNAME \ + enumerateValuesWithBlock:^(CTYPE value, NSUInteger idx, BOOL * stop) { \ + _Pragma("unused(idx, stop)"); \ + [result \ + appendFormat:@"%@%d: " #FORMAT "\n", lineIndent, fieldNumber, value]; \ + }]; + + PRINT_LOOP(varintList, uint64_t, %llu); + PRINT_LOOP(fixed32List, uint32_t, 0x%X); + PRINT_LOOP(fixed64List, uint64_t, 0x%llX); + +#undef PRINT_LOOP + + // NOTE: C++ version of TextFormat tries to parse this as a message + // and print that if it succeeds. + for (NSData *data in field.lengthDelimitedList) { + [result appendFormat:@"%@%d: ", lineIndent, fieldNumber]; + AppendBufferAsString(data, result); + [result appendString:@"\n"]; + } + + for (GPBUnknownFieldSet *subUnknownSet in field.groupList) { + [result appendFormat:@"%@%d: {\n", lineIndent, fieldNumber]; + NSString *subIndent = [lineIndent stringByAppendingString:@" "]; + NSString *subUnknwonSetStr = + GPBTextFormatForUnknownFieldSet(subUnknownSet, subIndent); + [result appendString:subUnknwonSetStr]; + [result appendFormat:@"%@}\n", lineIndent]; + } + } + return result; +} + +// Helpers to decode a varint. Not using GPBCodedInputStream version because +// that needs a state object, and we don't want to create an input stream out +// of the data. +GPB_INLINE int8_t ReadRawByteFromData(const uint8_t **data) { + int8_t result = *((int8_t *)(*data)); + ++(*data); + return result; +} + +static int32_t ReadRawVarint32FromData(const uint8_t **data) { + int8_t tmp = ReadRawByteFromData(data); + if (tmp >= 0) { + return tmp; + } + int32_t result = tmp & 0x7f; + if ((tmp = ReadRawByteFromData(data)) >= 0) { + result |= tmp << 7; + } else { + result |= (tmp & 0x7f) << 7; + if ((tmp = ReadRawByteFromData(data)) >= 0) { + result |= tmp << 14; + } else { + result |= (tmp & 0x7f) << 14; + if ((tmp = ReadRawByteFromData(data)) >= 0) { + result |= tmp << 21; + } else { + result |= (tmp & 0x7f) << 21; + result |= (tmp = ReadRawByteFromData(data)) << 28; + if (tmp < 0) { + // Discard upper 32 bits. + for (int i = 0; i < 5; i++) { + if (ReadRawByteFromData(data) >= 0) { + return result; + } + } + [NSException raise:NSParseErrorException + format:@"Unable to read varint32"]; + } + } + } + } + return result; +} + +NSString *GPBDecodeTextFormatName(const uint8_t *decodeData, int32_t key, + NSString *inputStr) { + // decodData form: + // varint32: num entries + // for each entry: + // varint32: key + // bytes*: decode data + // + // decode data one of two forms: + // 1: a \0 followed by the string followed by an \0 + // 2: bytecodes to transform an input into the right thing, ending with \0 + // + // the bytes codes are of the form: + // 0xabbccccc + // 0x0 (all zeros), end. + // a - if set, add an underscore + // bb - 00 ccccc bytes as is + // bb - 10 ccccc upper first, as is on rest, ccccc byte total + // bb - 01 ccccc lower first, as is on rest, ccccc byte total + // bb - 11 ccccc all upper, ccccc byte total + + if (!decodeData || !inputStr) { + return nil; + } + + // Find key + const uint8_t *scan = decodeData; + int32_t numEntries = ReadRawVarint32FromData(&scan); + BOOL foundKey = NO; + while (!foundKey && (numEntries > 0)) { + --numEntries; + int32_t dataKey = ReadRawVarint32FromData(&scan); + if (dataKey == key) { + foundKey = YES; + } else { + // If it is a inlined string, it will start with \0; if it is bytecode it + // will start with a code. So advance one (skipping the inline string + // marker), and then loop until reaching the end marker (\0). + ++scan; + while (*scan != 0) ++scan; + // Now move past the end marker. + ++scan; + } + } + + if (!foundKey) { + return nil; + } + + // Decode + + if (*scan == 0) { + // Inline string. Move over the marker, and NSString can take it as + // UTF8. + ++scan; + NSString *result = [NSString stringWithUTF8String:(const char *)scan]; + return result; + } + + NSMutableString *result = + [NSMutableString stringWithCapacity:[inputStr length]]; + + const uint8_t kAddUnderscore = 0b10000000; + const uint8_t kOpMask = 0b01100000; + // const uint8_t kOpAsIs = 0b00000000; + const uint8_t kOpFirstUpper = 0b01000000; + const uint8_t kOpFirstLower = 0b00100000; + const uint8_t kOpAllUpper = 0b01100000; + const uint8_t kSegmentLenMask = 0b00011111; + + NSInteger i = 0; + for (; *scan != 0; ++scan) { + if (*scan & kAddUnderscore) { + [result appendString:@"_"]; + } + int segmentLen = *scan & kSegmentLenMask; + uint8_t decodeOp = *scan & kOpMask; + + // Do op specific handling of the first character. + if (decodeOp == kOpFirstUpper) { + unichar c = [inputStr characterAtIndex:i]; + [result appendFormat:@"%c", toupper((char)c)]; + ++i; + --segmentLen; + } else if (decodeOp == kOpFirstLower) { + unichar c = [inputStr characterAtIndex:i]; + [result appendFormat:@"%c", tolower((char)c)]; + ++i; + --segmentLen; + } + // else op == kOpAsIs || op == kOpAllUpper + + // Now pull over the rest of the length for this segment. + for (int x = 0; x < segmentLen; ++x) { + unichar c = [inputStr characterAtIndex:(i + x)]; + if (decodeOp == kOpAllUpper) { + [result appendFormat:@"%c", toupper((char)c)]; + } else { + [result appendFormat:@"%C", c]; + } + } + i += segmentLen; + } + + return result; +} + +#pragma clang diagnostic pop + +BOOL GPBClassHasSel(Class aClass, SEL sel) { + // NOTE: We have to use class_copyMethodList, all other runtime method + // lookups actually also resolve the method implementation and this + // is called from within those methods. + + BOOL result = NO; + unsigned int methodCount = 0; + Method *methodList = class_copyMethodList(aClass, &methodCount); + for (unsigned int i = 0; i < methodCount; ++i) { + SEL methodSelector = method_getName(methodList[i]); + if (methodSelector == sel) { + result = YES; + break; + } + } + free(methodList); + return result; +} + +#pragma mark - GPBMessageSignatureProtocol + +// A series of selectors that are used solely to get @encoding values +// for them by the dynamic protobuf runtime code. An object using the protocol +// needs to be declared for the protocol to be valid at runtime. +@interface GPBMessageSignatureProtocol : NSObject +@end +@implementation GPBMessageSignatureProtocol +@end diff --git a/Pods/Protobuf/objectivec/GPBUtilities_PackagePrivate.h b/Pods/Protobuf/objectivec/GPBUtilities_PackagePrivate.h new file mode 100644 index 0000000..16859d4 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBUtilities_PackagePrivate.h @@ -0,0 +1,350 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import + +#import "GPBUtilities.h" + +#import "GPBDescriptor_PackagePrivate.h" + +// Macros for stringifying library symbols. These are used in the generated +// PB descriptor classes wherever a library symbol name is represented as a +// string. See README.google for more information. +#define GPBStringify(S) #S +#define GPBStringifySymbol(S) GPBStringify(S) + +#define GPBNSStringify(S) @#S +#define GPBNSStringifySymbol(S) GPBNSStringify(S) + +// Constant to internally mark when there is no has bit. +#define GPBNoHasBit INT32_MAX + +CF_EXTERN_C_BEGIN + +// These two are used to inject a runtime check for version mismatch into the +// generated sources to make sure they are linked with a supporting runtime. +void GPBCheckRuntimeVersionSupport(int32_t objcRuntimeVersion); +GPB_INLINE void GPB_DEBUG_CHECK_RUNTIME_VERSIONS() { + // NOTE: By being inline here, this captures the value from the library's + // headers at the time the generated code was compiled. +#if defined(DEBUG) && DEBUG + GPBCheckRuntimeVersionSupport(GOOGLE_PROTOBUF_OBJC_VERSION); +#endif +} + +// Legacy version of the checks, remove when GOOGLE_PROTOBUF_OBJC_GEN_VERSION +// goes away (see more info in GPBBootstrap.h). +void GPBCheckRuntimeVersionInternal(int32_t version); +GPB_INLINE void GPBDebugCheckRuntimeVersion() { +#if defined(DEBUG) && DEBUG + GPBCheckRuntimeVersionInternal(GOOGLE_PROTOBUF_OBJC_GEN_VERSION); +#endif +} + +// Conversion functions for de/serializing floating point types. + +GPB_INLINE int64_t GPBConvertDoubleToInt64(double v) { + union { double f; int64_t i; } u; + u.f = v; + return u.i; +} + +GPB_INLINE int32_t GPBConvertFloatToInt32(float v) { + union { float f; int32_t i; } u; + u.f = v; + return u.i; +} + +GPB_INLINE double GPBConvertInt64ToDouble(int64_t v) { + union { double f; int64_t i; } u; + u.i = v; + return u.f; +} + +GPB_INLINE float GPBConvertInt32ToFloat(int32_t v) { + union { float f; int32_t i; } u; + u.i = v; + return u.f; +} + +GPB_INLINE int32_t GPBLogicalRightShift32(int32_t value, int32_t spaces) { + return (int32_t)((uint32_t)(value) >> spaces); +} + +GPB_INLINE int64_t GPBLogicalRightShift64(int64_t value, int32_t spaces) { + return (int64_t)((uint64_t)(value) >> spaces); +} + +// Decode a ZigZag-encoded 32-bit value. ZigZag encodes signed integers +// into values that can be efficiently encoded with varint. (Otherwise, +// negative values must be sign-extended to 64 bits to be varint encoded, +// thus always taking 10 bytes on the wire.) +GPB_INLINE int32_t GPBDecodeZigZag32(uint32_t n) { + return (int32_t)(GPBLogicalRightShift32((int32_t)n, 1) ^ -((int32_t)(n) & 1)); +} + +// Decode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers +// into values that can be efficiently encoded with varint. (Otherwise, +// negative values must be sign-extended to 64 bits to be varint encoded, +// thus always taking 10 bytes on the wire.) +GPB_INLINE int64_t GPBDecodeZigZag64(uint64_t n) { + return (int64_t)(GPBLogicalRightShift64((int64_t)n, 1) ^ -((int64_t)(n) & 1)); +} + +// Encode a ZigZag-encoded 32-bit value. ZigZag encodes signed integers +// into values that can be efficiently encoded with varint. (Otherwise, +// negative values must be sign-extended to 64 bits to be varint encoded, +// thus always taking 10 bytes on the wire.) +GPB_INLINE uint32_t GPBEncodeZigZag32(int32_t n) { + // Note: the right-shift must be arithmetic + return (uint32_t)((n << 1) ^ (n >> 31)); +} + +// Encode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers +// into values that can be efficiently encoded with varint. (Otherwise, +// negative values must be sign-extended to 64 bits to be varint encoded, +// thus always taking 10 bytes on the wire.) +GPB_INLINE uint64_t GPBEncodeZigZag64(int64_t n) { + // Note: the right-shift must be arithmetic + return (uint64_t)((n << 1) ^ (n >> 63)); +} + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wswitch-enum" +#pragma clang diagnostic ignored "-Wdirect-ivar-access" + +GPB_INLINE BOOL GPBDataTypeIsObject(GPBDataType type) { + switch (type) { + case GPBDataTypeBytes: + case GPBDataTypeString: + case GPBDataTypeMessage: + case GPBDataTypeGroup: + return YES; + default: + return NO; + } +} + +GPB_INLINE BOOL GPBDataTypeIsMessage(GPBDataType type) { + switch (type) { + case GPBDataTypeMessage: + case GPBDataTypeGroup: + return YES; + default: + return NO; + } +} + +GPB_INLINE BOOL GPBFieldDataTypeIsMessage(GPBFieldDescriptor *field) { + return GPBDataTypeIsMessage(field->description_->dataType); +} + +GPB_INLINE BOOL GPBFieldDataTypeIsObject(GPBFieldDescriptor *field) { + return GPBDataTypeIsObject(field->description_->dataType); +} + +GPB_INLINE BOOL GPBExtensionIsMessage(GPBExtensionDescriptor *ext) { + return GPBDataTypeIsMessage(ext->description_->dataType); +} + +// The field is an array/map or it has an object value. +GPB_INLINE BOOL GPBFieldStoresObject(GPBFieldDescriptor *field) { + GPBMessageFieldDescription *desc = field->description_; + if ((desc->flags & (GPBFieldRepeated | GPBFieldMapKeyMask)) != 0) { + return YES; + } + return GPBDataTypeIsObject(desc->dataType); +} + +BOOL GPBGetHasIvar(GPBMessage *self, int32_t index, uint32_t fieldNumber); +void GPBSetHasIvar(GPBMessage *self, int32_t idx, uint32_t fieldNumber, + BOOL value); +uint32_t GPBGetHasOneof(GPBMessage *self, int32_t index); + +GPB_INLINE BOOL +GPBGetHasIvarField(GPBMessage *self, GPBFieldDescriptor *field) { + GPBMessageFieldDescription *fieldDesc = field->description_; + return GPBGetHasIvar(self, fieldDesc->hasIndex, fieldDesc->number); +} +GPB_INLINE void GPBSetHasIvarField(GPBMessage *self, GPBFieldDescriptor *field, + BOOL value) { + GPBMessageFieldDescription *fieldDesc = field->description_; + GPBSetHasIvar(self, fieldDesc->hasIndex, fieldDesc->number, value); +} + +void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof, + int32_t oneofHasIndex, uint32_t fieldNumberNotToClear); + +#pragma clang diagnostic pop + +//%PDDM-DEFINE GPB_IVAR_SET_DECL(NAME, TYPE) +//%void GPBSet##NAME##IvarWithFieldInternal(GPBMessage *self, +//% NAME$S GPBFieldDescriptor *field, +//% NAME$S TYPE value, +//% NAME$S GPBFileSyntax syntax); +//%PDDM-EXPAND GPB_IVAR_SET_DECL(Bool, BOOL) +// This block of code is generated, do not edit it directly. + +void GPBSetBoolIvarWithFieldInternal(GPBMessage *self, + GPBFieldDescriptor *field, + BOOL value, + GPBFileSyntax syntax); +//%PDDM-EXPAND GPB_IVAR_SET_DECL(Int32, int32_t) +// This block of code is generated, do not edit it directly. + +void GPBSetInt32IvarWithFieldInternal(GPBMessage *self, + GPBFieldDescriptor *field, + int32_t value, + GPBFileSyntax syntax); +//%PDDM-EXPAND GPB_IVAR_SET_DECL(UInt32, uint32_t) +// This block of code is generated, do not edit it directly. + +void GPBSetUInt32IvarWithFieldInternal(GPBMessage *self, + GPBFieldDescriptor *field, + uint32_t value, + GPBFileSyntax syntax); +//%PDDM-EXPAND GPB_IVAR_SET_DECL(Int64, int64_t) +// This block of code is generated, do not edit it directly. + +void GPBSetInt64IvarWithFieldInternal(GPBMessage *self, + GPBFieldDescriptor *field, + int64_t value, + GPBFileSyntax syntax); +//%PDDM-EXPAND GPB_IVAR_SET_DECL(UInt64, uint64_t) +// This block of code is generated, do not edit it directly. + +void GPBSetUInt64IvarWithFieldInternal(GPBMessage *self, + GPBFieldDescriptor *field, + uint64_t value, + GPBFileSyntax syntax); +//%PDDM-EXPAND GPB_IVAR_SET_DECL(Float, float) +// This block of code is generated, do not edit it directly. + +void GPBSetFloatIvarWithFieldInternal(GPBMessage *self, + GPBFieldDescriptor *field, + float value, + GPBFileSyntax syntax); +//%PDDM-EXPAND GPB_IVAR_SET_DECL(Double, double) +// This block of code is generated, do not edit it directly. + +void GPBSetDoubleIvarWithFieldInternal(GPBMessage *self, + GPBFieldDescriptor *field, + double value, + GPBFileSyntax syntax); +//%PDDM-EXPAND GPB_IVAR_SET_DECL(Enum, int32_t) +// This block of code is generated, do not edit it directly. + +void GPBSetEnumIvarWithFieldInternal(GPBMessage *self, + GPBFieldDescriptor *field, + int32_t value, + GPBFileSyntax syntax); +//%PDDM-EXPAND-END (8 expansions) + +int32_t GPBGetEnumIvarWithFieldInternal(GPBMessage *self, + GPBFieldDescriptor *field, + GPBFileSyntax syntax); + +id GPBGetObjectIvarWithField(GPBMessage *self, GPBFieldDescriptor *field); + +void GPBSetObjectIvarWithFieldInternal(GPBMessage *self, + GPBFieldDescriptor *field, id value, + GPBFileSyntax syntax); +void GPBSetRetainedObjectIvarWithFieldInternal(GPBMessage *self, + GPBFieldDescriptor *field, + id __attribute__((ns_consumed)) + value, + GPBFileSyntax syntax); + +// GPBGetObjectIvarWithField will automatically create the field (message) if +// it doesn't exist. GPBGetObjectIvarWithFieldNoAutocreate will return nil. +id GPBGetObjectIvarWithFieldNoAutocreate(GPBMessage *self, + GPBFieldDescriptor *field); + +void GPBSetAutocreatedRetainedObjectIvarWithField( + GPBMessage *self, GPBFieldDescriptor *field, + id __attribute__((ns_consumed)) value); + +// Clears and releases the autocreated message ivar, if it's autocreated. If +// it's not set as autocreated, this method does nothing. +void GPBClearAutocreatedMessageIvarWithField(GPBMessage *self, + GPBFieldDescriptor *field); + +// Returns an Objective C encoding for |selector|. |instanceSel| should be +// YES if it's an instance selector (as opposed to a class selector). +// |selector| must be a selector from MessageSignatureProtocol. +const char *GPBMessageEncodingForSelector(SEL selector, BOOL instanceSel); + +// Helper for text format name encoding. +// decodeData is the data describing the sepecial decodes. +// key and inputString are the input that needs decoding. +NSString *GPBDecodeTextFormatName(const uint8_t *decodeData, int32_t key, + NSString *inputString); + +// A series of selectors that are used solely to get @encoding values +// for them by the dynamic protobuf runtime code. See +// GPBMessageEncodingForSelector for details. +@protocol GPBMessageSignatureProtocol +@optional + +#define GPB_MESSAGE_SIGNATURE_ENTRY(TYPE, NAME) \ + -(TYPE)get##NAME; \ + -(void)set##NAME : (TYPE)value; \ + -(TYPE)get##NAME##AtIndex : (NSUInteger)index; + +GPB_MESSAGE_SIGNATURE_ENTRY(BOOL, Bool) +GPB_MESSAGE_SIGNATURE_ENTRY(uint32_t, Fixed32) +GPB_MESSAGE_SIGNATURE_ENTRY(int32_t, SFixed32) +GPB_MESSAGE_SIGNATURE_ENTRY(float, Float) +GPB_MESSAGE_SIGNATURE_ENTRY(uint64_t, Fixed64) +GPB_MESSAGE_SIGNATURE_ENTRY(int64_t, SFixed64) +GPB_MESSAGE_SIGNATURE_ENTRY(double, Double) +GPB_MESSAGE_SIGNATURE_ENTRY(int32_t, Int32) +GPB_MESSAGE_SIGNATURE_ENTRY(int64_t, Int64) +GPB_MESSAGE_SIGNATURE_ENTRY(int32_t, SInt32) +GPB_MESSAGE_SIGNATURE_ENTRY(int64_t, SInt64) +GPB_MESSAGE_SIGNATURE_ENTRY(uint32_t, UInt32) +GPB_MESSAGE_SIGNATURE_ENTRY(uint64_t, UInt64) +GPB_MESSAGE_SIGNATURE_ENTRY(NSData *, Bytes) +GPB_MESSAGE_SIGNATURE_ENTRY(NSString *, String) +GPB_MESSAGE_SIGNATURE_ENTRY(GPBMessage *, Message) +GPB_MESSAGE_SIGNATURE_ENTRY(GPBMessage *, Group) +GPB_MESSAGE_SIGNATURE_ENTRY(int32_t, Enum) + +#undef GPB_MESSAGE_SIGNATURE_ENTRY + +- (id)getArray; +- (NSUInteger)getArrayCount; +- (void)setArray:(NSArray *)array; ++ (id)getClassValue; +@end + +BOOL GPBClassHasSel(Class aClass, SEL sel); + +CF_EXTERN_C_END diff --git a/Pods/Protobuf/objectivec/GPBWellKnownTypes.h b/Pods/Protobuf/objectivec/GPBWellKnownTypes.h new file mode 100644 index 0000000..04df417 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBWellKnownTypes.h @@ -0,0 +1,245 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import + #import + #import +#else + #import "google/protobuf/Any.pbobjc.h" + #import "google/protobuf/Duration.pbobjc.h" + #import "google/protobuf/Timestamp.pbobjc.h" +#endif + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - Errors + +/** NSError domain used for errors. */ +extern NSString *const GPBWellKnownTypesErrorDomain; + +/** Error code for NSError with GPBWellKnownTypesErrorDomain. */ +typedef NS_ENUM(NSInteger, GPBWellKnownTypesErrorCode) { + /** The type_url could not be computed for the requested GPBMessage class. */ + GPBWellKnownTypesErrorCodeFailedToComputeTypeURL = -100, + /** type_url in a Any doesn’t match that of the requested GPBMessage class. */ + GPBWellKnownTypesErrorCodeTypeURLMismatch = -101, +}; + +#pragma mark - GPBTimestamp + +/** + * Category for GPBTimestamp to work with standard Foundation time/date types. + **/ +@interface GPBTimestamp (GBPWellKnownTypes) + +/** The NSDate representation of this GPBTimestamp. */ +@property(nonatomic, readwrite, strong) NSDate *date; + +/** + * The NSTimeInterval representation of this GPBTimestamp. + * + * @note: Not all second/nanos combinations can be represented in a + * NSTimeInterval, so getting this could be a lossy transform. + **/ +@property(nonatomic, readwrite) NSTimeInterval timeIntervalSince1970; + +/** + * Initializes a GPBTimestamp with the given NSDate. + * + * @param date The date to configure the GPBTimestamp with. + * + * @return A newly initialized GPBTimestamp. + **/ +- (instancetype)initWithDate:(NSDate *)date; + +/** + * Initializes a GPBTimestamp with the given NSTimeInterval. + * + * @param timeIntervalSince1970 Time interval to configure the GPBTimestamp with. + * + * @return A newly initialized GPBTimestamp. + **/ +- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970; + +@end + +#pragma mark - GPBDuration + +/** + * Category for GPBDuration to work with standard Foundation time type. + **/ +@interface GPBDuration (GBPWellKnownTypes) + +/** + * The NSTimeInterval representation of this GPBDuration. + * + * @note: Not all second/nanos combinations can be represented in a + * NSTimeInterval, so getting this could be a lossy transform. + **/ +@property(nonatomic, readwrite) NSTimeInterval timeInterval; + +/** + * Initializes a GPBDuration with the given NSTimeInterval. + * + * @param timeInterval Time interval to configure the GPBDuration with. + * + * @return A newly initialized GPBDuration. + **/ +- (instancetype)initWithTimeInterval:(NSTimeInterval)timeInterval; + +// These next two methods are deprecated because GBPDuration has no need of a +// "base" time. The older methods were about symmetry with GBPTimestamp, but +// the unix epoch usage is too confusing. + +/** Deprecated, use timeInterval instead. */ +@property(nonatomic, readwrite) NSTimeInterval timeIntervalSince1970 + __attribute__((deprecated("Use timeInterval"))); +/** Deprecated, use initWithTimeInterval: instead. */ +- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 + __attribute__((deprecated("Use initWithTimeInterval:"))); + +@end + +#pragma mark - GPBAny + +/** + * Category for GPBAny to help work with the message within the object. + **/ +@interface GPBAny (GBPWellKnownTypes) + +/** + * Convenience method to create a GPBAny containing the serialized message. + * This uses type.googleapis.com/ as the type_url's prefix. + * + * @param message The message to be packed into the GPBAny. + * @param errorPtr Pointer to an error that will be populated if something goes + * wrong. + * + * @return A newly configured GPBAny with the given message, or nil on failure. + */ ++ (nullable instancetype)anyWithMessage:(nonnull GPBMessage *)message + error:(NSError **)errorPtr; + +/** + * Convenience method to create a GPBAny containing the serialized message. + * + * @param message The message to be packed into the GPBAny. + * @param typeURLPrefix The URL prefix to apply for type_url. + * @param errorPtr Pointer to an error that will be populated if something + * goes wrong. + * + * @return A newly configured GPBAny with the given message, or nil on failure. + */ ++ (nullable instancetype)anyWithMessage:(nonnull GPBMessage *)message + typeURLPrefix:(nonnull NSString *)typeURLPrefix + error:(NSError **)errorPtr; + +/** + * Initializes a GPBAny to contain the serialized message. This uses + * type.googleapis.com/ as the type_url's prefix. + * + * @param message The message to be packed into the GPBAny. + * @param errorPtr Pointer to an error that will be populated if something goes + * wrong. + * + * @return A newly configured GPBAny with the given message, or nil on failure. + */ +- (nullable instancetype)initWithMessage:(nonnull GPBMessage *)message + error:(NSError **)errorPtr; + +/** + * Initializes a GPBAny to contain the serialized message. + * + * @param message The message to be packed into the GPBAny. + * @param typeURLPrefix The URL prefix to apply for type_url. + * @param errorPtr Pointer to an error that will be populated if something + * goes wrong. + * + * @return A newly configured GPBAny with the given message, or nil on failure. + */ +- (nullable instancetype)initWithMessage:(nonnull GPBMessage *)message + typeURLPrefix:(nonnull NSString *)typeURLPrefix + error:(NSError **)errorPtr; + +/** + * Packs the serialized message into this GPBAny. This uses + * type.googleapis.com/ as the type_url's prefix. + * + * @param message The message to be packed into the GPBAny. + * @param errorPtr Pointer to an error that will be populated if something goes + * wrong. + * + * @return Whether the packing was successful or not. + */ +- (BOOL)packWithMessage:(nonnull GPBMessage *)message + error:(NSError **)errorPtr; + +/** + * Packs the serialized message into this GPBAny. + * + * @param message The message to be packed into the GPBAny. + * @param typeURLPrefix The URL prefix to apply for type_url. + * @param errorPtr Pointer to an error that will be populated if something + * goes wrong. + * + * @return Whether the packing was successful or not. + */ +- (BOOL)packWithMessage:(nonnull GPBMessage *)message + typeURLPrefix:(nonnull NSString *)typeURLPrefix + error:(NSError **)errorPtr; + +/** + * Unpacks the serialized message as if it was an instance of the given class. + * + * @note When checking type_url, the base URL is not checked, only the fully + * qualified name. + * + * @param messageClass The class to use to deserialize the contained message. + * @param errorPtr Pointer to an error that will be populated if something + * goes wrong. + * + * @return An instance of the given class populated with the contained data, or + * nil on failure. + */ +- (nullable GPBMessage *)unpackMessageClass:(Class)messageClass + error:(NSError **)errorPtr; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Pods/Protobuf/objectivec/GPBWellKnownTypes.m b/Pods/Protobuf/objectivec/GPBWellKnownTypes.m new file mode 100644 index 0000000..2808afe --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBWellKnownTypes.m @@ -0,0 +1,272 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Importing sources here to force the linker to include our category methods in +// the static library. If these were compiled separately, the category methods +// below would be stripped by the linker. + +#import "GPBWellKnownTypes.h" + +#import "GPBUtilities_PackagePrivate.h" + +NSString *const GPBWellKnownTypesErrorDomain = + GPBNSStringifySymbol(GPBWellKnownTypesErrorDomain); + +static NSString *kTypePrefixGoogleApisCom = @"type.googleapis.com/"; + +static NSTimeInterval TimeIntervalFromSecondsAndNanos(int64_t seconds, + int32_t nanos) { + return seconds + (NSTimeInterval)nanos / 1e9; +} + +static int32_t SecondsAndNanosFromTimeInterval(NSTimeInterval time, + int64_t *outSeconds, + BOOL nanosMustBePositive) { + NSTimeInterval seconds; + NSTimeInterval nanos = modf(time, &seconds); + + if (nanosMustBePositive && (nanos < 0)) { + // Per Timestamp.proto, nanos is non-negative and "Negative second values with + // fractions must still have non-negative nanos values that count forward in + // time. Must be from 0 to 999,999,999 inclusive." + --seconds; + nanos = 1.0 + nanos; + } + + nanos *= 1e9; + *outSeconds = (int64_t)seconds; + return (int32_t)nanos; +} + +static NSString *BuildTypeURL(NSString *typeURLPrefix, NSString *fullName) { + if (typeURLPrefix.length == 0) { + return fullName; + } + + if ([typeURLPrefix hasSuffix:@"/"]) { + return [typeURLPrefix stringByAppendingString:fullName]; + } + + return [NSString stringWithFormat:@"%@/%@", typeURLPrefix, fullName]; +} + +static NSString *ParseTypeFromURL(NSString *typeURLString) { + NSRange range = [typeURLString rangeOfString:@"/" options:NSBackwardsSearch]; + if ((range.location == NSNotFound) || + (NSMaxRange(range) == typeURLString.length)) { + return nil; + } + NSString *result = [typeURLString substringFromIndex:range.location + 1]; + return result; +} + +#pragma mark - GPBTimestamp + +@implementation GPBTimestamp (GBPWellKnownTypes) + +- (instancetype)initWithDate:(NSDate *)date { + return [self initWithTimeIntervalSince1970:date.timeIntervalSince1970]; +} + +- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 { + if ((self = [super init])) { + int64_t seconds; + int32_t nanos = SecondsAndNanosFromTimeInterval( + timeIntervalSince1970, &seconds, YES); + self.seconds = seconds; + self.nanos = nanos; + } + return self; +} + +- (NSDate *)date { + return [NSDate dateWithTimeIntervalSince1970:self.timeIntervalSince1970]; +} + +- (void)setDate:(NSDate *)date { + self.timeIntervalSince1970 = date.timeIntervalSince1970; +} + +- (NSTimeInterval)timeIntervalSince1970 { + return TimeIntervalFromSecondsAndNanos(self.seconds, self.nanos); +} + +- (void)setTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 { + int64_t seconds; + int32_t nanos = + SecondsAndNanosFromTimeInterval(timeIntervalSince1970, &seconds, YES); + self.seconds = seconds; + self.nanos = nanos; +} + +@end + +#pragma mark - GPBDuration + +@implementation GPBDuration (GBPWellKnownTypes) + +- (instancetype)initWithTimeInterval:(NSTimeInterval)timeInterval { + if ((self = [super init])) { + int64_t seconds; + int32_t nanos = SecondsAndNanosFromTimeInterval( + timeInterval, &seconds, NO); + self.seconds = seconds; + self.nanos = nanos; + } + return self; +} + +- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 { + return [self initWithTimeInterval:timeIntervalSince1970]; +} + +- (NSTimeInterval)timeInterval { + return TimeIntervalFromSecondsAndNanos(self.seconds, self.nanos); +} + +- (void)setTimeInterval:(NSTimeInterval)timeInterval { + int64_t seconds; + int32_t nanos = + SecondsAndNanosFromTimeInterval(timeInterval, &seconds, NO); + self.seconds = seconds; + self.nanos = nanos; +} + +- (NSTimeInterval)timeIntervalSince1970 { + return self.timeInterval; +} + +- (void)setTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 { + self.timeInterval = timeIntervalSince1970; +} + +@end + +#pragma mark - GPBAny + +@implementation GPBAny (GBPWellKnownTypes) + ++ (instancetype)anyWithMessage:(GPBMessage *)message + error:(NSError **)errorPtr { + return [self anyWithMessage:message + typeURLPrefix:kTypePrefixGoogleApisCom + error:errorPtr]; +} + ++ (instancetype)anyWithMessage:(GPBMessage *)message + typeURLPrefix:(NSString *)typeURLPrefix + error:(NSError **)errorPtr { + return [[[self alloc] initWithMessage:message + typeURLPrefix:typeURLPrefix + error:errorPtr] autorelease]; +} + +- (instancetype)initWithMessage:(GPBMessage *)message + error:(NSError **)errorPtr { + return [self initWithMessage:message + typeURLPrefix:kTypePrefixGoogleApisCom + error:errorPtr]; +} + +- (instancetype)initWithMessage:(GPBMessage *)message + typeURLPrefix:(NSString *)typeURLPrefix + error:(NSError **)errorPtr { + self = [self init]; + if (self) { + if (![self packWithMessage:message + typeURLPrefix:typeURLPrefix + error:errorPtr]) { + [self release]; + self = nil; + } + } + return self; +} + +- (BOOL)packWithMessage:(GPBMessage *)message + error:(NSError **)errorPtr { + return [self packWithMessage:message + typeURLPrefix:kTypePrefixGoogleApisCom + error:errorPtr]; +} + +- (BOOL)packWithMessage:(GPBMessage *)message + typeURLPrefix:(NSString *)typeURLPrefix + error:(NSError **)errorPtr { + NSString *fullName = [message descriptor].fullName; + if (fullName.length == 0) { + if (errorPtr) { + *errorPtr = + [NSError errorWithDomain:GPBWellKnownTypesErrorDomain + code:GPBWellKnownTypesErrorCodeFailedToComputeTypeURL + userInfo:nil]; + } + return NO; + } + if (errorPtr) { + *errorPtr = nil; + } + self.typeURL = BuildTypeURL(typeURLPrefix, fullName); + self.value = message.data; + return YES; +} + +- (GPBMessage *)unpackMessageClass:(Class)messageClass + error:(NSError **)errorPtr { + NSString *fullName = [messageClass descriptor].fullName; + if (fullName.length == 0) { + if (errorPtr) { + *errorPtr = + [NSError errorWithDomain:GPBWellKnownTypesErrorDomain + code:GPBWellKnownTypesErrorCodeFailedToComputeTypeURL + userInfo:nil]; + } + return nil; + } + + NSString *expectedFullName = ParseTypeFromURL(self.typeURL); + if ((expectedFullName == nil) || ![expectedFullName isEqual:fullName]) { + if (errorPtr) { + *errorPtr = + [NSError errorWithDomain:GPBWellKnownTypesErrorDomain + code:GPBWellKnownTypesErrorCodeTypeURLMismatch + userInfo:nil]; + } + return nil; + } + + // Any is proto3, which means no extensions, so this assumes anything put + // within an any also won't need extensions. A second helper could be added + // if needed. + return [messageClass parseFromData:self.value + error:errorPtr]; +} + +@end diff --git a/Pods/Protobuf/objectivec/GPBWireFormat.h b/Pods/Protobuf/objectivec/GPBWireFormat.h new file mode 100644 index 0000000..c5941a3 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBWireFormat.h @@ -0,0 +1,73 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import "GPBRuntimeTypes.h" + +CF_EXTERN_C_BEGIN + +NS_ASSUME_NONNULL_BEGIN + +typedef enum { + GPBWireFormatVarint = 0, + GPBWireFormatFixed64 = 1, + GPBWireFormatLengthDelimited = 2, + GPBWireFormatStartGroup = 3, + GPBWireFormatEndGroup = 4, + GPBWireFormatFixed32 = 5, +} GPBWireFormat; + +enum { + GPBWireFormatMessageSetItem = 1, + GPBWireFormatMessageSetTypeId = 2, + GPBWireFormatMessageSetMessage = 3 +}; + +uint32_t GPBWireFormatMakeTag(uint32_t fieldNumber, GPBWireFormat wireType) + __attribute__((const)); +GPBWireFormat GPBWireFormatGetTagWireType(uint32_t tag) __attribute__((const)); +uint32_t GPBWireFormatGetTagFieldNumber(uint32_t tag) __attribute__((const)); +BOOL GPBWireFormatIsValidTag(uint32_t tag) __attribute__((const)); + +GPBWireFormat GPBWireFormatForType(GPBDataType dataType, BOOL isPacked) + __attribute__((const)); + +#define GPBWireFormatMessageSetItemTag \ + (GPBWireFormatMakeTag(GPBWireFormatMessageSetItem, GPBWireFormatStartGroup)) +#define GPBWireFormatMessageSetItemEndTag \ + (GPBWireFormatMakeTag(GPBWireFormatMessageSetItem, GPBWireFormatEndGroup)) +#define GPBWireFormatMessageSetTypeIdTag \ + (GPBWireFormatMakeTag(GPBWireFormatMessageSetTypeId, GPBWireFormatVarint)) +#define GPBWireFormatMessageSetMessageTag \ + (GPBWireFormatMakeTag(GPBWireFormatMessageSetMessage, \ + GPBWireFormatLengthDelimited)) + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END diff --git a/Pods/Protobuf/objectivec/GPBWireFormat.m b/Pods/Protobuf/objectivec/GPBWireFormat.m new file mode 100644 index 0000000..860a339 --- /dev/null +++ b/Pods/Protobuf/objectivec/GPBWireFormat.m @@ -0,0 +1,85 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#import "GPBWireFormat.h" + +#import "GPBUtilities_PackagePrivate.h" + +enum { + GPBWireFormatTagTypeBits = 3, + GPBWireFormatTagTypeMask = 7 /* = (1 << GPBWireFormatTagTypeBits) - 1 */, +}; + +uint32_t GPBWireFormatMakeTag(uint32_t fieldNumber, GPBWireFormat wireType) { + return (fieldNumber << GPBWireFormatTagTypeBits) | wireType; +} + +GPBWireFormat GPBWireFormatGetTagWireType(uint32_t tag) { + return (GPBWireFormat)(tag & GPBWireFormatTagTypeMask); +} + +uint32_t GPBWireFormatGetTagFieldNumber(uint32_t tag) { + return GPBLogicalRightShift32(tag, GPBWireFormatTagTypeBits); +} + +BOOL GPBWireFormatIsValidTag(uint32_t tag) { + uint32_t formatBits = (tag & GPBWireFormatTagTypeMask); + // The valid GPBWireFormat* values are 0-5, anything else is not a valid tag. + BOOL result = (formatBits <= 5); + return result; +} + +GPBWireFormat GPBWireFormatForType(GPBDataType type, BOOL isPacked) { + if (isPacked) { + return GPBWireFormatLengthDelimited; + } + + static const GPBWireFormat format[GPBDataType_Count] = { + GPBWireFormatVarint, // GPBDataTypeBool + GPBWireFormatFixed32, // GPBDataTypeFixed32 + GPBWireFormatFixed32, // GPBDataTypeSFixed32 + GPBWireFormatFixed32, // GPBDataTypeFloat + GPBWireFormatFixed64, // GPBDataTypeFixed64 + GPBWireFormatFixed64, // GPBDataTypeSFixed64 + GPBWireFormatFixed64, // GPBDataTypeDouble + GPBWireFormatVarint, // GPBDataTypeInt32 + GPBWireFormatVarint, // GPBDataTypeInt64 + GPBWireFormatVarint, // GPBDataTypeSInt32 + GPBWireFormatVarint, // GPBDataTypeSInt64 + GPBWireFormatVarint, // GPBDataTypeUInt32 + GPBWireFormatVarint, // GPBDataTypeUInt64 + GPBWireFormatLengthDelimited, // GPBDataTypeBytes + GPBWireFormatLengthDelimited, // GPBDataTypeString + GPBWireFormatLengthDelimited, // GPBDataTypeMessage + GPBWireFormatStartGroup, // GPBDataTypeGroup + GPBWireFormatVarint // GPBDataTypeEnum + }; + return format[type]; +} diff --git a/Pods/Protobuf/objectivec/google/protobuf/Any.pbobjc.h b/Pods/Protobuf/objectivec/google/protobuf/Any.pbobjc.h new file mode 100644 index 0000000..b17e76f --- /dev/null +++ b/Pods/Protobuf/objectivec/google/protobuf/Any.pbobjc.h @@ -0,0 +1,173 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/any.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers.h" +#endif + +#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002 +#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. +#endif +#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION +#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. +#endif + +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +CF_EXTERN_C_BEGIN + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - GPBAnyRoot + +/** + * Exposes the extension registry for this file. + * + * The base class provides: + * @code + * + (GPBExtensionRegistry *)extensionRegistry; + * @endcode + * which is a @c GPBExtensionRegistry that includes all the extensions defined by + * this file and all files that it depends on. + **/ +@interface GPBAnyRoot : GPBRootObject +@end + +#pragma mark - GPBAny + +typedef GPB_ENUM(GPBAny_FieldNumber) { + GPBAny_FieldNumber_TypeURL = 1, + GPBAny_FieldNumber_Value = 2, +}; + +/** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := ptypes.MarshalAny(foo) + * ... + * foo := &pb.Foo{} + * if err := ptypes.UnmarshalAny(any, foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `\@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "\@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `\@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "\@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + **/ +@interface GPBAny : GPBMessage + +/** + * A URL/resource name whose content describes the type of the + * serialized protocol buffer message. + * + * For URLs which use the scheme `http`, `https`, or no scheme, the + * following restrictions and interpretations apply: + * + * * If no scheme is provided, `https` is assumed. + * * The last segment of the URL's path must represent the fully + * qualified name of the type (as in `path/google.protobuf.Duration`). + * The name should be in a canonical form (e.g., leading "." is + * not accepted). + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + **/ +@property(nonatomic, readwrite, copy, null_resettable) NSString *typeURL; + +/** Must be a valid serialized protocol buffer of the above specified type. */ +@property(nonatomic, readwrite, copy, null_resettable) NSData *value; + +@end + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) diff --git a/Pods/Protobuf/objectivec/google/protobuf/Any.pbobjc.m b/Pods/Protobuf/objectivec/google/protobuf/Any.pbobjc.m new file mode 100644 index 0000000..d210643 --- /dev/null +++ b/Pods/Protobuf/objectivec/google/protobuf/Any.pbobjc.m @@ -0,0 +1,112 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/any.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers_RuntimeSupport.h" +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "google/protobuf/Any.pbobjc.h" +#endif +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +#pragma mark - GPBAnyRoot + +@implementation GPBAnyRoot + +// No extensions in the file and no imports, so no need to generate +// +extensionRegistry. + +@end + +#pragma mark - GPBAnyRoot_FileDescriptor + +static GPBFileDescriptor *GPBAnyRoot_FileDescriptor(void) { + // This is called by +initialize so there is no need to worry + // about thread safety of the singleton. + static GPBFileDescriptor *descriptor = NULL; + if (!descriptor) { + GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); + descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf" + objcPrefix:@"GPB" + syntax:GPBFileSyntaxProto3]; + } + return descriptor; +} + +#pragma mark - GPBAny + +@implementation GPBAny + +@dynamic typeURL; +@dynamic value; + +typedef struct GPBAny__storage_ { + uint32_t _has_storage_[1]; + NSString *typeURL; + NSData *value; +} GPBAny__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "typeURL", + .dataTypeSpecific.className = NULL, + .number = GPBAny_FieldNumber_TypeURL, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBAny__storage_, typeURL), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom), + .dataType = GPBDataTypeString, + }, + { + .name = "value", + .dataTypeSpecific.className = NULL, + .number = GPBAny_FieldNumber_Value, + .hasIndex = 1, + .offset = (uint32_t)offsetof(GPBAny__storage_, value), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeBytes, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBAny class] + rootClass:[GPBAnyRoot class] + file:GPBAnyRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBAny__storage_) + flags:GPBDescriptorInitializationFlag_None]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\001\001\004\241!!\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) diff --git a/Pods/Protobuf/objectivec/google/protobuf/Api.pbobjc.h b/Pods/Protobuf/objectivec/google/protobuf/Api.pbobjc.h new file mode 100644 index 0000000..095fc2c --- /dev/null +++ b/Pods/Protobuf/objectivec/google/protobuf/Api.pbobjc.h @@ -0,0 +1,307 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/api.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers.h" +#endif + +#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002 +#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. +#endif +#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION +#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. +#endif + +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +CF_EXTERN_C_BEGIN + +@class GPBMethod; +@class GPBMixin; +@class GPBOption; +@class GPBSourceContext; +GPB_ENUM_FWD_DECLARE(GPBSyntax); + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - GPBApiRoot + +/** + * Exposes the extension registry for this file. + * + * The base class provides: + * @code + * + (GPBExtensionRegistry *)extensionRegistry; + * @endcode + * which is a @c GPBExtensionRegistry that includes all the extensions defined by + * this file and all files that it depends on. + **/ +@interface GPBApiRoot : GPBRootObject +@end + +#pragma mark - GPBApi + +typedef GPB_ENUM(GPBApi_FieldNumber) { + GPBApi_FieldNumber_Name = 1, + GPBApi_FieldNumber_MethodsArray = 2, + GPBApi_FieldNumber_OptionsArray = 3, + GPBApi_FieldNumber_Version = 4, + GPBApi_FieldNumber_SourceContext = 5, + GPBApi_FieldNumber_MixinsArray = 6, + GPBApi_FieldNumber_Syntax = 7, +}; + +/** + * Api is a light-weight descriptor for an API Interface. + * + * Interfaces are also described as "protocol buffer services" in some contexts, + * such as by the "service" keyword in a .proto file, but they are different + * from API Services, which represent a concrete implementation of an interface + * as opposed to simply a description of methods and bindings. They are also + * sometimes simply referred to as "APIs" in other contexts, such as the name of + * this message itself. See https://cloud.google.com/apis/design/glossary for + * detailed terminology. + **/ +@interface GPBApi : GPBMessage + +/** + * The fully qualified name of this interface, including package name + * followed by the interface's simple name. + **/ +@property(nonatomic, readwrite, copy, null_resettable) NSString *name; + +/** The methods of this interface, in unspecified order. */ +@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *methodsArray; +/** The number of items in @c methodsArray without causing the array to be created. */ +@property(nonatomic, readonly) NSUInteger methodsArray_Count; + +/** Any metadata attached to the interface. */ +@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray; +/** The number of items in @c optionsArray without causing the array to be created. */ +@property(nonatomic, readonly) NSUInteger optionsArray_Count; + +/** + * A version string for this interface. If specified, must have the form + * `major-version.minor-version`, as in `1.10`. If the minor version is + * omitted, it defaults to zero. If the entire version field is empty, the + * major version is derived from the package name, as outlined below. If the + * field is not empty, the version in the package name will be verified to be + * consistent with what is provided here. + * + * The versioning schema uses [semantic + * versioning](http://semver.org) where the major version number + * indicates a breaking change and the minor version an additive, + * non-breaking change. Both version numbers are signals to users + * what to expect from different versions, and should be carefully + * chosen based on the product plan. + * + * The major version is also reflected in the package name of the + * interface, which must end in `v`, as in + * `google.feature.v1`. For major versions 0 and 1, the suffix can + * be omitted. Zero major versions must only be used for + * experimental, non-GA interfaces. + **/ +@property(nonatomic, readwrite, copy, null_resettable) NSString *version; + +/** + * Source context for the protocol buffer service represented by this + * message. + **/ +@property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext; +/** Test to see if @c sourceContext has been set. */ +@property(nonatomic, readwrite) BOOL hasSourceContext; + +/** Included interfaces. See [Mixin][]. */ +@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *mixinsArray; +/** The number of items in @c mixinsArray without causing the array to be created. */ +@property(nonatomic, readonly) NSUInteger mixinsArray_Count; + +/** The source syntax of the service. */ +@property(nonatomic, readwrite) enum GPBSyntax syntax; + +@end + +/** + * Fetches the raw value of a @c GPBApi's @c syntax property, even + * if the value was not defined by the enum at the time the code was generated. + **/ +int32_t GPBApi_Syntax_RawValue(GPBApi *message); +/** + * Sets the raw value of an @c GPBApi's @c syntax property, allowing + * it to be set to a value that was not defined by the enum at the time the code + * was generated. + **/ +void SetGPBApi_Syntax_RawValue(GPBApi *message, int32_t value); + +#pragma mark - GPBMethod + +typedef GPB_ENUM(GPBMethod_FieldNumber) { + GPBMethod_FieldNumber_Name = 1, + GPBMethod_FieldNumber_RequestTypeURL = 2, + GPBMethod_FieldNumber_RequestStreaming = 3, + GPBMethod_FieldNumber_ResponseTypeURL = 4, + GPBMethod_FieldNumber_ResponseStreaming = 5, + GPBMethod_FieldNumber_OptionsArray = 6, + GPBMethod_FieldNumber_Syntax = 7, +}; + +/** + * Method represents a method of an API interface. + **/ +@interface GPBMethod : GPBMessage + +/** The simple name of this method. */ +@property(nonatomic, readwrite, copy, null_resettable) NSString *name; + +/** A URL of the input message type. */ +@property(nonatomic, readwrite, copy, null_resettable) NSString *requestTypeURL; + +/** If true, the request is streamed. */ +@property(nonatomic, readwrite) BOOL requestStreaming; + +/** The URL of the output message type. */ +@property(nonatomic, readwrite, copy, null_resettable) NSString *responseTypeURL; + +/** If true, the response is streamed. */ +@property(nonatomic, readwrite) BOOL responseStreaming; + +/** Any metadata attached to the method. */ +@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray; +/** The number of items in @c optionsArray without causing the array to be created. */ +@property(nonatomic, readonly) NSUInteger optionsArray_Count; + +/** The source syntax of this method. */ +@property(nonatomic, readwrite) enum GPBSyntax syntax; + +@end + +/** + * Fetches the raw value of a @c GPBMethod's @c syntax property, even + * if the value was not defined by the enum at the time the code was generated. + **/ +int32_t GPBMethod_Syntax_RawValue(GPBMethod *message); +/** + * Sets the raw value of an @c GPBMethod's @c syntax property, allowing + * it to be set to a value that was not defined by the enum at the time the code + * was generated. + **/ +void SetGPBMethod_Syntax_RawValue(GPBMethod *message, int32_t value); + +#pragma mark - GPBMixin + +typedef GPB_ENUM(GPBMixin_FieldNumber) { + GPBMixin_FieldNumber_Name = 1, + GPBMixin_FieldNumber_Root = 2, +}; + +/** + * Declares an API Interface to be included in this interface. The including + * interface must redeclare all the methods from the included interface, but + * documentation and options are inherited as follows: + * + * - If after comment and whitespace stripping, the documentation + * string of the redeclared method is empty, it will be inherited + * from the original method. + * + * - Each annotation belonging to the service config (http, + * visibility) which is not set in the redeclared method will be + * inherited. + * + * - If an http annotation is inherited, the path pattern will be + * modified as follows. Any version prefix will be replaced by the + * version of the including interface plus the [root][] path if + * specified. + * + * Example of a simple mixin: + * + * package google.acl.v1; + * service AccessControl { + * // Get the underlying ACL object. + * rpc GetAcl(GetAclRequest) returns (Acl) { + * option (google.api.http).get = "/v1/{resource=**}:getAcl"; + * } + * } + * + * package google.storage.v2; + * service Storage { + * rpc GetAcl(GetAclRequest) returns (Acl); + * + * // Get a data record. + * rpc GetData(GetDataRequest) returns (Data) { + * option (google.api.http).get = "/v2/{resource=**}"; + * } + * } + * + * Example of a mixin configuration: + * + * apis: + * - name: google.storage.v2.Storage + * mixins: + * - name: google.acl.v1.AccessControl + * + * The mixin construct implies that all methods in `AccessControl` are + * also declared with same name and request/response types in + * `Storage`. A documentation generator or annotation processor will + * see the effective `Storage.GetAcl` method after inherting + * documentation and annotations as follows: + * + * service Storage { + * // Get the underlying ACL object. + * rpc GetAcl(GetAclRequest) returns (Acl) { + * option (google.api.http).get = "/v2/{resource=**}:getAcl"; + * } + * ... + * } + * + * Note how the version in the path pattern changed from `v1` to `v2`. + * + * If the `root` field in the mixin is specified, it should be a + * relative path under which inherited HTTP paths are placed. Example: + * + * apis: + * - name: google.storage.v2.Storage + * mixins: + * - name: google.acl.v1.AccessControl + * root: acls + * + * This implies the following inherited HTTP annotation: + * + * service Storage { + * // Get the underlying ACL object. + * rpc GetAcl(GetAclRequest) returns (Acl) { + * option (google.api.http).get = "/v2/acls/{resource=**}:getAcl"; + * } + * ... + * } + **/ +@interface GPBMixin : GPBMessage + +/** The fully qualified name of the interface which is included. */ +@property(nonatomic, readwrite, copy, null_resettable) NSString *name; + +/** + * If non-empty specifies a path under which inherited HTTP paths + * are rooted. + **/ +@property(nonatomic, readwrite, copy, null_resettable) NSString *root; + +@end + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) diff --git a/Pods/Protobuf/objectivec/google/protobuf/Api.pbobjc.m b/Pods/Protobuf/objectivec/google/protobuf/Api.pbobjc.m new file mode 100644 index 0000000..58b4715 --- /dev/null +++ b/Pods/Protobuf/objectivec/google/protobuf/Api.pbobjc.m @@ -0,0 +1,356 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/api.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers_RuntimeSupport.h" +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import + #import + #import +#else + #import "google/protobuf/Api.pbobjc.h" + #import "google/protobuf/SourceContext.pbobjc.h" + #import "google/protobuf/Type.pbobjc.h" +#endif +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +#pragma mark - GPBApiRoot + +@implementation GPBApiRoot + +// No extensions in the file and none of the imports (direct or indirect) +// defined extensions, so no need to generate +extensionRegistry. + +@end + +#pragma mark - GPBApiRoot_FileDescriptor + +static GPBFileDescriptor *GPBApiRoot_FileDescriptor(void) { + // This is called by +initialize so there is no need to worry + // about thread safety of the singleton. + static GPBFileDescriptor *descriptor = NULL; + if (!descriptor) { + GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); + descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf" + objcPrefix:@"GPB" + syntax:GPBFileSyntaxProto3]; + } + return descriptor; +} + +#pragma mark - GPBApi + +@implementation GPBApi + +@dynamic name; +@dynamic methodsArray, methodsArray_Count; +@dynamic optionsArray, optionsArray_Count; +@dynamic version; +@dynamic hasSourceContext, sourceContext; +@dynamic mixinsArray, mixinsArray_Count; +@dynamic syntax; + +typedef struct GPBApi__storage_ { + uint32_t _has_storage_[1]; + GPBSyntax syntax; + NSString *name; + NSMutableArray *methodsArray; + NSMutableArray *optionsArray; + NSString *version; + GPBSourceContext *sourceContext; + NSMutableArray *mixinsArray; +} GPBApi__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "name", + .dataTypeSpecific.className = NULL, + .number = GPBApi_FieldNumber_Name, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBApi__storage_, name), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeString, + }, + { + .name = "methodsArray", + .dataTypeSpecific.className = GPBStringifySymbol(GPBMethod), + .number = GPBApi_FieldNumber_MethodsArray, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBApi__storage_, methodsArray), + .flags = GPBFieldRepeated, + .dataType = GPBDataTypeMessage, + }, + { + .name = "optionsArray", + .dataTypeSpecific.className = GPBStringifySymbol(GPBOption), + .number = GPBApi_FieldNumber_OptionsArray, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBApi__storage_, optionsArray), + .flags = GPBFieldRepeated, + .dataType = GPBDataTypeMessage, + }, + { + .name = "version", + .dataTypeSpecific.className = NULL, + .number = GPBApi_FieldNumber_Version, + .hasIndex = 1, + .offset = (uint32_t)offsetof(GPBApi__storage_, version), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeString, + }, + { + .name = "sourceContext", + .dataTypeSpecific.className = GPBStringifySymbol(GPBSourceContext), + .number = GPBApi_FieldNumber_SourceContext, + .hasIndex = 2, + .offset = (uint32_t)offsetof(GPBApi__storage_, sourceContext), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + { + .name = "mixinsArray", + .dataTypeSpecific.className = GPBStringifySymbol(GPBMixin), + .number = GPBApi_FieldNumber_MixinsArray, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBApi__storage_, mixinsArray), + .flags = GPBFieldRepeated, + .dataType = GPBDataTypeMessage, + }, + { + .name = "syntax", + .dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor, + .number = GPBApi_FieldNumber_Syntax, + .hasIndex = 3, + .offset = (uint32_t)offsetof(GPBApi__storage_, syntax), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor), + .dataType = GPBDataTypeEnum, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBApi class] + rootClass:[GPBApiRoot class] + file:GPBApiRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBApi__storage_) + flags:GPBDescriptorInitializationFlag_None]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +int32_t GPBApi_Syntax_RawValue(GPBApi *message) { + GPBDescriptor *descriptor = [GPBApi descriptor]; + GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBApi_FieldNumber_Syntax]; + return GPBGetMessageInt32Field(message, field); +} + +void SetGPBApi_Syntax_RawValue(GPBApi *message, int32_t value) { + GPBDescriptor *descriptor = [GPBApi descriptor]; + GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBApi_FieldNumber_Syntax]; + GPBSetInt32IvarWithFieldInternal(message, field, value, descriptor.file.syntax); +} + +#pragma mark - GPBMethod + +@implementation GPBMethod + +@dynamic name; +@dynamic requestTypeURL; +@dynamic requestStreaming; +@dynamic responseTypeURL; +@dynamic responseStreaming; +@dynamic optionsArray, optionsArray_Count; +@dynamic syntax; + +typedef struct GPBMethod__storage_ { + uint32_t _has_storage_[1]; + GPBSyntax syntax; + NSString *name; + NSString *requestTypeURL; + NSString *responseTypeURL; + NSMutableArray *optionsArray; +} GPBMethod__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "name", + .dataTypeSpecific.className = NULL, + .number = GPBMethod_FieldNumber_Name, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBMethod__storage_, name), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeString, + }, + { + .name = "requestTypeURL", + .dataTypeSpecific.className = NULL, + .number = GPBMethod_FieldNumber_RequestTypeURL, + .hasIndex = 1, + .offset = (uint32_t)offsetof(GPBMethod__storage_, requestTypeURL), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom), + .dataType = GPBDataTypeString, + }, + { + .name = "requestStreaming", + .dataTypeSpecific.className = NULL, + .number = GPBMethod_FieldNumber_RequestStreaming, + .hasIndex = 2, + .offset = 3, // Stored in _has_storage_ to save space. + .flags = GPBFieldOptional, + .dataType = GPBDataTypeBool, + }, + { + .name = "responseTypeURL", + .dataTypeSpecific.className = NULL, + .number = GPBMethod_FieldNumber_ResponseTypeURL, + .hasIndex = 4, + .offset = (uint32_t)offsetof(GPBMethod__storage_, responseTypeURL), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom), + .dataType = GPBDataTypeString, + }, + { + .name = "responseStreaming", + .dataTypeSpecific.className = NULL, + .number = GPBMethod_FieldNumber_ResponseStreaming, + .hasIndex = 5, + .offset = 6, // Stored in _has_storage_ to save space. + .flags = GPBFieldOptional, + .dataType = GPBDataTypeBool, + }, + { + .name = "optionsArray", + .dataTypeSpecific.className = GPBStringifySymbol(GPBOption), + .number = GPBMethod_FieldNumber_OptionsArray, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBMethod__storage_, optionsArray), + .flags = GPBFieldRepeated, + .dataType = GPBDataTypeMessage, + }, + { + .name = "syntax", + .dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor, + .number = GPBMethod_FieldNumber_Syntax, + .hasIndex = 7, + .offset = (uint32_t)offsetof(GPBMethod__storage_, syntax), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor), + .dataType = GPBDataTypeEnum, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBMethod class] + rootClass:[GPBApiRoot class] + file:GPBApiRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBMethod__storage_) + flags:GPBDescriptorInitializationFlag_None]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\002\002\007\244\241!!\000\004\010\244\241!!\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +int32_t GPBMethod_Syntax_RawValue(GPBMethod *message) { + GPBDescriptor *descriptor = [GPBMethod descriptor]; + GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBMethod_FieldNumber_Syntax]; + return GPBGetMessageInt32Field(message, field); +} + +void SetGPBMethod_Syntax_RawValue(GPBMethod *message, int32_t value) { + GPBDescriptor *descriptor = [GPBMethod descriptor]; + GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBMethod_FieldNumber_Syntax]; + GPBSetInt32IvarWithFieldInternal(message, field, value, descriptor.file.syntax); +} + +#pragma mark - GPBMixin + +@implementation GPBMixin + +@dynamic name; +@dynamic root; + +typedef struct GPBMixin__storage_ { + uint32_t _has_storage_[1]; + NSString *name; + NSString *root; +} GPBMixin__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "name", + .dataTypeSpecific.className = NULL, + .number = GPBMixin_FieldNumber_Name, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBMixin__storage_, name), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeString, + }, + { + .name = "root", + .dataTypeSpecific.className = NULL, + .number = GPBMixin_FieldNumber_Root, + .hasIndex = 1, + .offset = (uint32_t)offsetof(GPBMixin__storage_, root), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeString, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBMixin class] + rootClass:[GPBApiRoot class] + file:GPBApiRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBMixin__storage_) + flags:GPBDescriptorInitializationFlag_None]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) diff --git a/Pods/Protobuf/objectivec/google/protobuf/Duration.pbobjc.h b/Pods/Protobuf/objectivec/google/protobuf/Duration.pbobjc.h new file mode 100644 index 0000000..d9a388a --- /dev/null +++ b/Pods/Protobuf/objectivec/google/protobuf/Duration.pbobjc.h @@ -0,0 +1,141 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/duration.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers.h" +#endif + +#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002 +#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. +#endif +#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION +#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. +#endif + +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +CF_EXTERN_C_BEGIN + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - GPBDurationRoot + +/** + * Exposes the extension registry for this file. + * + * The base class provides: + * @code + * + (GPBExtensionRegistry *)extensionRegistry; + * @endcode + * which is a @c GPBExtensionRegistry that includes all the extensions defined by + * this file and all files that it depends on. + **/ +@interface GPBDurationRoot : GPBRootObject +@end + +#pragma mark - GPBDuration + +typedef GPB_ENUM(GPBDuration_FieldNumber) { + GPBDuration_FieldNumber_Seconds = 1, + GPBDuration_FieldNumber_Nanos = 2, +}; + +/** + * A Duration represents a signed, fixed-length span of time represented + * as a count of seconds and fractions of seconds at nanosecond + * resolution. It is independent of any calendar and concepts like "day" + * or "month". It is related to Timestamp in that the difference between + * two Timestamp values is a Duration and it can be added or subtracted + * from a Timestamp. Range is approximately +-10,000 years. + * + * # Examples + * + * Example 1: Compute Duration from two Timestamps in pseudo code. + * + * Timestamp start = ...; + * Timestamp end = ...; + * Duration duration = ...; + * + * duration.seconds = end.seconds - start.seconds; + * duration.nanos = end.nanos - start.nanos; + * + * if (duration.seconds < 0 && duration.nanos > 0) { + * duration.seconds += 1; + * duration.nanos -= 1000000000; + * } else if (durations.seconds > 0 && duration.nanos < 0) { + * duration.seconds -= 1; + * duration.nanos += 1000000000; + * } + * + * Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. + * + * Timestamp start = ...; + * Duration duration = ...; + * Timestamp end = ...; + * + * end.seconds = start.seconds + duration.seconds; + * end.nanos = start.nanos + duration.nanos; + * + * if (end.nanos < 0) { + * end.seconds -= 1; + * end.nanos += 1000000000; + * } else if (end.nanos >= 1000000000) { + * end.seconds += 1; + * end.nanos -= 1000000000; + * } + * + * Example 3: Compute Duration from datetime.timedelta in Python. + * + * td = datetime.timedelta(days=3, minutes=10) + * duration = Duration() + * duration.FromTimedelta(td) + * + * # JSON Mapping + * + * In JSON format, the Duration type is encoded as a string rather than an + * object, where the string ends in the suffix "s" (indicating seconds) and + * is preceded by the number of seconds, with nanoseconds expressed as + * fractional seconds. For example, 3 seconds with 0 nanoseconds should be + * encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should + * be expressed in JSON format as "3.000000001s", and 3 seconds and 1 + * microsecond should be expressed in JSON format as "3.000001s". + **/ +@interface GPBDuration : GPBMessage + +/** + * Signed seconds of the span of time. Must be from -315,576,000,000 + * to +315,576,000,000 inclusive. Note: these bounds are computed from: + * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years + **/ +@property(nonatomic, readwrite) int64_t seconds; + +/** + * Signed fractions of a second at nanosecond resolution of the span + * of time. Durations less than one second are represented with a 0 + * `seconds` field and a positive or negative `nanos` field. For durations + * of one second or more, a non-zero value for the `nanos` field must be + * of the same sign as the `seconds` field. Must be from -999,999,999 + * to +999,999,999 inclusive. + **/ +@property(nonatomic, readwrite) int32_t nanos; + +@end + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) diff --git a/Pods/Protobuf/objectivec/google/protobuf/Duration.pbobjc.m b/Pods/Protobuf/objectivec/google/protobuf/Duration.pbobjc.m new file mode 100644 index 0000000..bafb64a --- /dev/null +++ b/Pods/Protobuf/objectivec/google/protobuf/Duration.pbobjc.m @@ -0,0 +1,107 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/duration.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers_RuntimeSupport.h" +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "google/protobuf/Duration.pbobjc.h" +#endif +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +#pragma mark - GPBDurationRoot + +@implementation GPBDurationRoot + +// No extensions in the file and no imports, so no need to generate +// +extensionRegistry. + +@end + +#pragma mark - GPBDurationRoot_FileDescriptor + +static GPBFileDescriptor *GPBDurationRoot_FileDescriptor(void) { + // This is called by +initialize so there is no need to worry + // about thread safety of the singleton. + static GPBFileDescriptor *descriptor = NULL; + if (!descriptor) { + GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); + descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf" + objcPrefix:@"GPB" + syntax:GPBFileSyntaxProto3]; + } + return descriptor; +} + +#pragma mark - GPBDuration + +@implementation GPBDuration + +@dynamic seconds; +@dynamic nanos; + +typedef struct GPBDuration__storage_ { + uint32_t _has_storage_[1]; + int32_t nanos; + int64_t seconds; +} GPBDuration__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "seconds", + .dataTypeSpecific.className = NULL, + .number = GPBDuration_FieldNumber_Seconds, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBDuration__storage_, seconds), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeInt64, + }, + { + .name = "nanos", + .dataTypeSpecific.className = NULL, + .number = GPBDuration_FieldNumber_Nanos, + .hasIndex = 1, + .offset = (uint32_t)offsetof(GPBDuration__storage_, nanos), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeInt32, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBDuration class] + rootClass:[GPBDurationRoot class] + file:GPBDurationRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBDuration__storage_) + flags:GPBDescriptorInitializationFlag_None]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) diff --git a/Pods/Protobuf/objectivec/google/protobuf/Empty.pbobjc.h b/Pods/Protobuf/objectivec/google/protobuf/Empty.pbobjc.h new file mode 100644 index 0000000..bd49cfd --- /dev/null +++ b/Pods/Protobuf/objectivec/google/protobuf/Empty.pbobjc.h @@ -0,0 +1,70 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/empty.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers.h" +#endif + +#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002 +#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. +#endif +#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION +#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. +#endif + +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +CF_EXTERN_C_BEGIN + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - GPBEmptyRoot + +/** + * Exposes the extension registry for this file. + * + * The base class provides: + * @code + * + (GPBExtensionRegistry *)extensionRegistry; + * @endcode + * which is a @c GPBExtensionRegistry that includes all the extensions defined by + * this file and all files that it depends on. + **/ +@interface GPBEmptyRoot : GPBRootObject +@end + +#pragma mark - GPBEmpty + +/** + * A generic empty message that you can re-use to avoid defining duplicated + * empty messages in your APIs. A typical example is to use it as the request + * or the response type of an API method. For instance: + * + * service Foo { + * rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); + * } + * + * The JSON representation for `Empty` is empty JSON object `{}`. + **/ +@interface GPBEmpty : GPBMessage + +@end + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) diff --git a/Pods/Protobuf/objectivec/google/protobuf/Empty.pbobjc.m b/Pods/Protobuf/objectivec/google/protobuf/Empty.pbobjc.m new file mode 100644 index 0000000..506b500 --- /dev/null +++ b/Pods/Protobuf/objectivec/google/protobuf/Empty.pbobjc.m @@ -0,0 +1,83 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/empty.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers_RuntimeSupport.h" +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "google/protobuf/Empty.pbobjc.h" +#endif +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +#pragma mark - GPBEmptyRoot + +@implementation GPBEmptyRoot + +// No extensions in the file and no imports, so no need to generate +// +extensionRegistry. + +@end + +#pragma mark - GPBEmptyRoot_FileDescriptor + +static GPBFileDescriptor *GPBEmptyRoot_FileDescriptor(void) { + // This is called by +initialize so there is no need to worry + // about thread safety of the singleton. + static GPBFileDescriptor *descriptor = NULL; + if (!descriptor) { + GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); + descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf" + objcPrefix:@"GPB" + syntax:GPBFileSyntaxProto3]; + } + return descriptor; +} + +#pragma mark - GPBEmpty + +@implementation GPBEmpty + + +typedef struct GPBEmpty__storage_ { + uint32_t _has_storage_[1]; +} GPBEmpty__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBEmpty class] + rootClass:[GPBEmptyRoot class] + file:GPBEmptyRoot_FileDescriptor() + fields:NULL + fieldCount:0 + storageSize:sizeof(GPBEmpty__storage_) + flags:GPBDescriptorInitializationFlag_None]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) diff --git a/Pods/Protobuf/objectivec/google/protobuf/FieldMask.pbobjc.h b/Pods/Protobuf/objectivec/google/protobuf/FieldMask.pbobjc.h new file mode 100644 index 0000000..75cf856 --- /dev/null +++ b/Pods/Protobuf/objectivec/google/protobuf/FieldMask.pbobjc.h @@ -0,0 +1,277 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/field_mask.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers.h" +#endif + +#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002 +#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. +#endif +#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION +#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. +#endif + +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +CF_EXTERN_C_BEGIN + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - GPBFieldMaskRoot + +/** + * Exposes the extension registry for this file. + * + * The base class provides: + * @code + * + (GPBExtensionRegistry *)extensionRegistry; + * @endcode + * which is a @c GPBExtensionRegistry that includes all the extensions defined by + * this file and all files that it depends on. + **/ +@interface GPBFieldMaskRoot : GPBRootObject +@end + +#pragma mark - GPBFieldMask + +typedef GPB_ENUM(GPBFieldMask_FieldNumber) { + GPBFieldMask_FieldNumber_PathsArray = 1, +}; + +/** + * `FieldMask` represents a set of symbolic field paths, for example: + * + * paths: "f.a" + * paths: "f.b.d" + * + * Here `f` represents a field in some root message, `a` and `b` + * fields in the message found in `f`, and `d` a field found in the + * message in `f.b`. + * + * Field masks are used to specify a subset of fields that should be + * returned by a get operation or modified by an update operation. + * Field masks also have a custom JSON encoding (see below). + * + * # Field Masks in Projections + * + * When used in the context of a projection, a response message or + * sub-message is filtered by the API to only contain those fields as + * specified in the mask. For example, if the mask in the previous + * example is applied to a response message as follows: + * + * f { + * a : 22 + * b { + * d : 1 + * x : 2 + * } + * y : 13 + * } + * z: 8 + * + * The result will not contain specific values for fields x,y and z + * (their value will be set to the default, and omitted in proto text + * output): + * + * + * f { + * a : 22 + * b { + * d : 1 + * } + * } + * + * A repeated field is not allowed except at the last position of a + * paths string. + * + * If a FieldMask object is not present in a get operation, the + * operation applies to all fields (as if a FieldMask of all fields + * had been specified). + * + * Note that a field mask does not necessarily apply to the + * top-level response message. In case of a REST get operation, the + * field mask applies directly to the response, but in case of a REST + * list operation, the mask instead applies to each individual message + * in the returned resource list. In case of a REST custom method, + * other definitions may be used. Where the mask applies will be + * clearly documented together with its declaration in the API. In + * any case, the effect on the returned resource/resources is required + * behavior for APIs. + * + * # Field Masks in Update Operations + * + * A field mask in update operations specifies which fields of the + * targeted resource are going to be updated. The API is required + * to only change the values of the fields as specified in the mask + * and leave the others untouched. If a resource is passed in to + * describe the updated values, the API ignores the values of all + * fields not covered by the mask. + * + * If a repeated field is specified for an update operation, the existing + * repeated values in the target resource will be overwritten by the new values. + * Note that a repeated field is only allowed in the last position of a `paths` + * string. + * + * If a sub-message is specified in the last position of the field mask for an + * update operation, then the existing sub-message in the target resource is + * overwritten. Given the target message: + * + * f { + * b { + * d : 1 + * x : 2 + * } + * c : 1 + * } + * + * And an update message: + * + * f { + * b { + * d : 10 + * } + * } + * + * then if the field mask is: + * + * paths: "f.b" + * + * then the result will be: + * + * f { + * b { + * d : 10 + * } + * c : 1 + * } + * + * However, if the update mask was: + * + * paths: "f.b.d" + * + * then the result would be: + * + * f { + * b { + * d : 10 + * x : 2 + * } + * c : 1 + * } + * + * In order to reset a field's value to the default, the field must + * be in the mask and set to the default value in the provided resource. + * Hence, in order to reset all fields of a resource, provide a default + * instance of the resource and set all fields in the mask, or do + * not provide a mask as described below. + * + * If a field mask is not present on update, the operation applies to + * all fields (as if a field mask of all fields has been specified). + * Note that in the presence of schema evolution, this may mean that + * fields the client does not know and has therefore not filled into + * the request will be reset to their default. If this is unwanted + * behavior, a specific service may require a client to always specify + * a field mask, producing an error if not. + * + * As with get operations, the location of the resource which + * describes the updated values in the request message depends on the + * operation kind. In any case, the effect of the field mask is + * required to be honored by the API. + * + * ## Considerations for HTTP REST + * + * The HTTP kind of an update operation which uses a field mask must + * be set to PATCH instead of PUT in order to satisfy HTTP semantics + * (PUT must only be used for full updates). + * + * # JSON Encoding of Field Masks + * + * In JSON, a field mask is encoded as a single string where paths are + * separated by a comma. Fields name in each path are converted + * to/from lower-camel naming conventions. + * + * As an example, consider the following message declarations: + * + * message Profile { + * User user = 1; + * Photo photo = 2; + * } + * message User { + * string display_name = 1; + * string address = 2; + * } + * + * In proto a field mask for `Profile` may look as such: + * + * mask { + * paths: "user.display_name" + * paths: "photo" + * } + * + * In JSON, the same mask is represented as below: + * + * { + * mask: "user.displayName,photo" + * } + * + * # Field Masks and Oneof Fields + * + * Field masks treat fields in oneofs just as regular fields. Consider the + * following message: + * + * message SampleMessage { + * oneof test_oneof { + * string name = 4; + * SubMessage sub_message = 9; + * } + * } + * + * The field mask can be: + * + * mask { + * paths: "name" + * } + * + * Or: + * + * mask { + * paths: "sub_message" + * } + * + * Note that oneof type names ("test_oneof" in this case) cannot be used in + * paths. + * + * ## Field Mask Verification + * + * The implementation of the all the API methods, which have any FieldMask type + * field in the request, should verify the included field paths, and return + * `INVALID_ARGUMENT` error if any path is duplicated or unmappable. + **/ +@interface GPBFieldMask : GPBMessage + +/** The set of field mask paths. */ +@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *pathsArray; +/** The number of items in @c pathsArray without causing the array to be created. */ +@property(nonatomic, readonly) NSUInteger pathsArray_Count; + +@end + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) diff --git a/Pods/Protobuf/objectivec/google/protobuf/FieldMask.pbobjc.m b/Pods/Protobuf/objectivec/google/protobuf/FieldMask.pbobjc.m new file mode 100644 index 0000000..b0915af --- /dev/null +++ b/Pods/Protobuf/objectivec/google/protobuf/FieldMask.pbobjc.m @@ -0,0 +1,96 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/field_mask.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers_RuntimeSupport.h" +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "google/protobuf/FieldMask.pbobjc.h" +#endif +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +#pragma mark - GPBFieldMaskRoot + +@implementation GPBFieldMaskRoot + +// No extensions in the file and no imports, so no need to generate +// +extensionRegistry. + +@end + +#pragma mark - GPBFieldMaskRoot_FileDescriptor + +static GPBFileDescriptor *GPBFieldMaskRoot_FileDescriptor(void) { + // This is called by +initialize so there is no need to worry + // about thread safety of the singleton. + static GPBFileDescriptor *descriptor = NULL; + if (!descriptor) { + GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); + descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf" + objcPrefix:@"GPB" + syntax:GPBFileSyntaxProto3]; + } + return descriptor; +} + +#pragma mark - GPBFieldMask + +@implementation GPBFieldMask + +@dynamic pathsArray, pathsArray_Count; + +typedef struct GPBFieldMask__storage_ { + uint32_t _has_storage_[1]; + NSMutableArray *pathsArray; +} GPBFieldMask__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "pathsArray", + .dataTypeSpecific.className = NULL, + .number = GPBFieldMask_FieldNumber_PathsArray, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBFieldMask__storage_, pathsArray), + .flags = GPBFieldRepeated, + .dataType = GPBDataTypeString, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBFieldMask class] + rootClass:[GPBFieldMaskRoot class] + file:GPBFieldMaskRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBFieldMask__storage_) + flags:GPBDescriptorInitializationFlag_None]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) diff --git a/Pods/Protobuf/objectivec/google/protobuf/SourceContext.pbobjc.h b/Pods/Protobuf/objectivec/google/protobuf/SourceContext.pbobjc.h new file mode 100644 index 0000000..799d190 --- /dev/null +++ b/Pods/Protobuf/objectivec/google/protobuf/SourceContext.pbobjc.h @@ -0,0 +1,73 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/source_context.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers.h" +#endif + +#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002 +#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. +#endif +#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION +#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. +#endif + +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +CF_EXTERN_C_BEGIN + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - GPBSourceContextRoot + +/** + * Exposes the extension registry for this file. + * + * The base class provides: + * @code + * + (GPBExtensionRegistry *)extensionRegistry; + * @endcode + * which is a @c GPBExtensionRegistry that includes all the extensions defined by + * this file and all files that it depends on. + **/ +@interface GPBSourceContextRoot : GPBRootObject +@end + +#pragma mark - GPBSourceContext + +typedef GPB_ENUM(GPBSourceContext_FieldNumber) { + GPBSourceContext_FieldNumber_FileName = 1, +}; + +/** + * `SourceContext` represents information about the source of a + * protobuf element, like the file in which it is defined. + **/ +@interface GPBSourceContext : GPBMessage + +/** + * The path-qualified name of the .proto file that contained the associated + * protobuf element. For example: `"google/protobuf/source_context.proto"`. + **/ +@property(nonatomic, readwrite, copy, null_resettable) NSString *fileName; + +@end + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) diff --git a/Pods/Protobuf/objectivec/google/protobuf/SourceContext.pbobjc.m b/Pods/Protobuf/objectivec/google/protobuf/SourceContext.pbobjc.m new file mode 100644 index 0000000..83bfa34 --- /dev/null +++ b/Pods/Protobuf/objectivec/google/protobuf/SourceContext.pbobjc.m @@ -0,0 +1,96 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/source_context.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers_RuntimeSupport.h" +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "google/protobuf/SourceContext.pbobjc.h" +#endif +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +#pragma mark - GPBSourceContextRoot + +@implementation GPBSourceContextRoot + +// No extensions in the file and no imports, so no need to generate +// +extensionRegistry. + +@end + +#pragma mark - GPBSourceContextRoot_FileDescriptor + +static GPBFileDescriptor *GPBSourceContextRoot_FileDescriptor(void) { + // This is called by +initialize so there is no need to worry + // about thread safety of the singleton. + static GPBFileDescriptor *descriptor = NULL; + if (!descriptor) { + GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); + descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf" + objcPrefix:@"GPB" + syntax:GPBFileSyntaxProto3]; + } + return descriptor; +} + +#pragma mark - GPBSourceContext + +@implementation GPBSourceContext + +@dynamic fileName; + +typedef struct GPBSourceContext__storage_ { + uint32_t _has_storage_[1]; + NSString *fileName; +} GPBSourceContext__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "fileName", + .dataTypeSpecific.className = NULL, + .number = GPBSourceContext_FieldNumber_FileName, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBSourceContext__storage_, fileName), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeString, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBSourceContext class] + rootClass:[GPBSourceContextRoot class] + file:GPBSourceContextRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBSourceContext__storage_) + flags:GPBDescriptorInitializationFlag_None]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) diff --git a/Pods/Protobuf/objectivec/google/protobuf/Struct.pbobjc.h b/Pods/Protobuf/objectivec/google/protobuf/Struct.pbobjc.h new file mode 100644 index 0000000..3fc80ca --- /dev/null +++ b/Pods/Protobuf/objectivec/google/protobuf/Struct.pbobjc.h @@ -0,0 +1,200 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/struct.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers.h" +#endif + +#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002 +#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. +#endif +#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION +#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. +#endif + +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +CF_EXTERN_C_BEGIN + +@class GPBListValue; +@class GPBStruct; +@class GPBValue; + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - Enum GPBNullValue + +/** + * `NullValue` is a singleton enumeration to represent the null value for the + * `Value` type union. + * + * The JSON representation for `NullValue` is JSON `null`. + **/ +typedef GPB_ENUM(GPBNullValue) { + /** + * Value used if any message's field encounters a value that is not defined + * by this enum. The message will also have C functions to get/set the rawValue + * of the field. + **/ + GPBNullValue_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue, + /** Null value. */ + GPBNullValue_NullValue = 0, +}; + +GPBEnumDescriptor *GPBNullValue_EnumDescriptor(void); + +/** + * Checks to see if the given value is defined by the enum or was not known at + * the time this source was generated. + **/ +BOOL GPBNullValue_IsValidValue(int32_t value); + +#pragma mark - GPBStructRoot + +/** + * Exposes the extension registry for this file. + * + * The base class provides: + * @code + * + (GPBExtensionRegistry *)extensionRegistry; + * @endcode + * which is a @c GPBExtensionRegistry that includes all the extensions defined by + * this file and all files that it depends on. + **/ +@interface GPBStructRoot : GPBRootObject +@end + +#pragma mark - GPBStruct + +typedef GPB_ENUM(GPBStruct_FieldNumber) { + GPBStruct_FieldNumber_Fields = 1, +}; + +/** + * `Struct` represents a structured data value, consisting of fields + * which map to dynamically typed values. In some languages, `Struct` + * might be supported by a native representation. For example, in + * scripting languages like JS a struct is represented as an + * object. The details of that representation are described together + * with the proto support for the language. + * + * The JSON representation for `Struct` is JSON object. + **/ +@interface GPBStruct : GPBMessage + +/** Unordered map of dynamically typed values. */ +@property(nonatomic, readwrite, strong, null_resettable) NSMutableDictionary *fields; +/** The number of items in @c fields without causing the array to be created. */ +@property(nonatomic, readonly) NSUInteger fields_Count; + +@end + +#pragma mark - GPBValue + +typedef GPB_ENUM(GPBValue_FieldNumber) { + GPBValue_FieldNumber_NullValue = 1, + GPBValue_FieldNumber_NumberValue = 2, + GPBValue_FieldNumber_StringValue = 3, + GPBValue_FieldNumber_BoolValue = 4, + GPBValue_FieldNumber_StructValue = 5, + GPBValue_FieldNumber_ListValue = 6, +}; + +typedef GPB_ENUM(GPBValue_Kind_OneOfCase) { + GPBValue_Kind_OneOfCase_GPBUnsetOneOfCase = 0, + GPBValue_Kind_OneOfCase_NullValue = 1, + GPBValue_Kind_OneOfCase_NumberValue = 2, + GPBValue_Kind_OneOfCase_StringValue = 3, + GPBValue_Kind_OneOfCase_BoolValue = 4, + GPBValue_Kind_OneOfCase_StructValue = 5, + GPBValue_Kind_OneOfCase_ListValue = 6, +}; + +/** + * `Value` represents a dynamically typed value which can be either + * null, a number, a string, a boolean, a recursive struct value, or a + * list of values. A producer of value is expected to set one of that + * variants, absence of any variant indicates an error. + * + * The JSON representation for `Value` is JSON value. + **/ +@interface GPBValue : GPBMessage + +/** The kind of value. */ +@property(nonatomic, readonly) GPBValue_Kind_OneOfCase kindOneOfCase; + +/** Represents a null value. */ +@property(nonatomic, readwrite) GPBNullValue nullValue; + +/** Represents a double value. */ +@property(nonatomic, readwrite) double numberValue; + +/** Represents a string value. */ +@property(nonatomic, readwrite, copy, null_resettable) NSString *stringValue; + +/** Represents a boolean value. */ +@property(nonatomic, readwrite) BOOL boolValue; + +/** Represents a structured value. */ +@property(nonatomic, readwrite, strong, null_resettable) GPBStruct *structValue; + +/** Represents a repeated `Value`. */ +@property(nonatomic, readwrite, strong, null_resettable) GPBListValue *listValue; + +@end + +/** + * Fetches the raw value of a @c GPBValue's @c nullValue property, even + * if the value was not defined by the enum at the time the code was generated. + **/ +int32_t GPBValue_NullValue_RawValue(GPBValue *message); +/** + * Sets the raw value of an @c GPBValue's @c nullValue property, allowing + * it to be set to a value that was not defined by the enum at the time the code + * was generated. + **/ +void SetGPBValue_NullValue_RawValue(GPBValue *message, int32_t value); + +/** + * Clears whatever value was set for the oneof 'kind'. + **/ +void GPBValue_ClearKindOneOfCase(GPBValue *message); + +#pragma mark - GPBListValue + +typedef GPB_ENUM(GPBListValue_FieldNumber) { + GPBListValue_FieldNumber_ValuesArray = 1, +}; + +/** + * `ListValue` is a wrapper around a repeated field of values. + * + * The JSON representation for `ListValue` is JSON array. + **/ +@interface GPBListValue : GPBMessage + +/** Repeated field of dynamically typed values. */ +@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *valuesArray; +/** The number of items in @c valuesArray without causing the array to be created. */ +@property(nonatomic, readonly) NSUInteger valuesArray_Count; + +@end + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) diff --git a/Pods/Protobuf/objectivec/google/protobuf/Struct.pbobjc.m b/Pods/Protobuf/objectivec/google/protobuf/Struct.pbobjc.m new file mode 100644 index 0000000..f36ec58 --- /dev/null +++ b/Pods/Protobuf/objectivec/google/protobuf/Struct.pbobjc.m @@ -0,0 +1,293 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/struct.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers_RuntimeSupport.h" +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "google/protobuf/Struct.pbobjc.h" +#endif +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#pragma clang diagnostic ignored "-Wdirect-ivar-access" + +#pragma mark - GPBStructRoot + +@implementation GPBStructRoot + +// No extensions in the file and no imports, so no need to generate +// +extensionRegistry. + +@end + +#pragma mark - GPBStructRoot_FileDescriptor + +static GPBFileDescriptor *GPBStructRoot_FileDescriptor(void) { + // This is called by +initialize so there is no need to worry + // about thread safety of the singleton. + static GPBFileDescriptor *descriptor = NULL; + if (!descriptor) { + GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); + descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf" + objcPrefix:@"GPB" + syntax:GPBFileSyntaxProto3]; + } + return descriptor; +} + +#pragma mark - Enum GPBNullValue + +GPBEnumDescriptor *GPBNullValue_EnumDescriptor(void) { + static GPBEnumDescriptor *descriptor = NULL; + if (!descriptor) { + static const char *valueNames = + "NullValue\000"; + static const int32_t values[] = { + GPBNullValue_NullValue, + }; + GPBEnumDescriptor *worker = + [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBNullValue) + valueNames:valueNames + values:values + count:(uint32_t)(sizeof(values) / sizeof(int32_t)) + enumVerifier:GPBNullValue_IsValidValue]; + if (!OSAtomicCompareAndSwapPtrBarrier(nil, worker, (void * volatile *)&descriptor)) { + [worker release]; + } + } + return descriptor; +} + +BOOL GPBNullValue_IsValidValue(int32_t value__) { + switch (value__) { + case GPBNullValue_NullValue: + return YES; + default: + return NO; + } +} + +#pragma mark - GPBStruct + +@implementation GPBStruct + +@dynamic fields, fields_Count; + +typedef struct GPBStruct__storage_ { + uint32_t _has_storage_[1]; + NSMutableDictionary *fields; +} GPBStruct__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "fields", + .dataTypeSpecific.className = GPBStringifySymbol(GPBValue), + .number = GPBStruct_FieldNumber_Fields, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBStruct__storage_, fields), + .flags = GPBFieldMapKeyString, + .dataType = GPBDataTypeMessage, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBStruct class] + rootClass:[GPBStructRoot class] + file:GPBStructRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBStruct__storage_) + flags:GPBDescriptorInitializationFlag_None]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - GPBValue + +@implementation GPBValue + +@dynamic kindOneOfCase; +@dynamic nullValue; +@dynamic numberValue; +@dynamic stringValue; +@dynamic boolValue; +@dynamic structValue; +@dynamic listValue; + +typedef struct GPBValue__storage_ { + uint32_t _has_storage_[2]; + GPBNullValue nullValue; + NSString *stringValue; + GPBStruct *structValue; + GPBListValue *listValue; + double numberValue; +} GPBValue__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "nullValue", + .dataTypeSpecific.enumDescFunc = GPBNullValue_EnumDescriptor, + .number = GPBValue_FieldNumber_NullValue, + .hasIndex = -1, + .offset = (uint32_t)offsetof(GPBValue__storage_, nullValue), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor), + .dataType = GPBDataTypeEnum, + }, + { + .name = "numberValue", + .dataTypeSpecific.className = NULL, + .number = GPBValue_FieldNumber_NumberValue, + .hasIndex = -1, + .offset = (uint32_t)offsetof(GPBValue__storage_, numberValue), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeDouble, + }, + { + .name = "stringValue", + .dataTypeSpecific.className = NULL, + .number = GPBValue_FieldNumber_StringValue, + .hasIndex = -1, + .offset = (uint32_t)offsetof(GPBValue__storage_, stringValue), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeString, + }, + { + .name = "boolValue", + .dataTypeSpecific.className = NULL, + .number = GPBValue_FieldNumber_BoolValue, + .hasIndex = -1, + .offset = 0, // Stored in _has_storage_ to save space. + .flags = GPBFieldOptional, + .dataType = GPBDataTypeBool, + }, + { + .name = "structValue", + .dataTypeSpecific.className = GPBStringifySymbol(GPBStruct), + .number = GPBValue_FieldNumber_StructValue, + .hasIndex = -1, + .offset = (uint32_t)offsetof(GPBValue__storage_, structValue), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + { + .name = "listValue", + .dataTypeSpecific.className = GPBStringifySymbol(GPBListValue), + .number = GPBValue_FieldNumber_ListValue, + .hasIndex = -1, + .offset = (uint32_t)offsetof(GPBValue__storage_, listValue), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBValue class] + rootClass:[GPBStructRoot class] + file:GPBStructRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBValue__storage_) + flags:GPBDescriptorInitializationFlag_None]; + static const char *oneofs[] = { + "kind", + }; + [localDescriptor setupOneofs:oneofs + count:(uint32_t)(sizeof(oneofs) / sizeof(char*)) + firstHasIndex:-1]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +int32_t GPBValue_NullValue_RawValue(GPBValue *message) { + GPBDescriptor *descriptor = [GPBValue descriptor]; + GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBValue_FieldNumber_NullValue]; + return GPBGetMessageInt32Field(message, field); +} + +void SetGPBValue_NullValue_RawValue(GPBValue *message, int32_t value) { + GPBDescriptor *descriptor = [GPBValue descriptor]; + GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBValue_FieldNumber_NullValue]; + GPBSetInt32IvarWithFieldInternal(message, field, value, descriptor.file.syntax); +} + +void GPBValue_ClearKindOneOfCase(GPBValue *message) { + GPBDescriptor *descriptor = [message descriptor]; + GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:0]; + GPBMaybeClearOneof(message, oneof, -1, 0); +} +#pragma mark - GPBListValue + +@implementation GPBListValue + +@dynamic valuesArray, valuesArray_Count; + +typedef struct GPBListValue__storage_ { + uint32_t _has_storage_[1]; + NSMutableArray *valuesArray; +} GPBListValue__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "valuesArray", + .dataTypeSpecific.className = GPBStringifySymbol(GPBValue), + .number = GPBListValue_FieldNumber_ValuesArray, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBListValue__storage_, valuesArray), + .flags = GPBFieldRepeated, + .dataType = GPBDataTypeMessage, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBListValue class] + rootClass:[GPBStructRoot class] + file:GPBStructRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBListValue__storage_) + flags:GPBDescriptorInitializationFlag_None]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) diff --git a/Pods/Protobuf/objectivec/google/protobuf/Timestamp.pbobjc.h b/Pods/Protobuf/objectivec/google/protobuf/Timestamp.pbobjc.h new file mode 100644 index 0000000..0b670c3 --- /dev/null +++ b/Pods/Protobuf/objectivec/google/protobuf/Timestamp.pbobjc.h @@ -0,0 +1,157 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/timestamp.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers.h" +#endif + +#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002 +#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. +#endif +#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION +#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. +#endif + +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +CF_EXTERN_C_BEGIN + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - GPBTimestampRoot + +/** + * Exposes the extension registry for this file. + * + * The base class provides: + * @code + * + (GPBExtensionRegistry *)extensionRegistry; + * @endcode + * which is a @c GPBExtensionRegistry that includes all the extensions defined by + * this file and all files that it depends on. + **/ +@interface GPBTimestampRoot : GPBRootObject +@end + +#pragma mark - GPBTimestamp + +typedef GPB_ENUM(GPBTimestamp_FieldNumber) { + GPBTimestamp_FieldNumber_Seconds = 1, + GPBTimestamp_FieldNumber_Nanos = 2, +}; + +/** + * A Timestamp represents a point in time independent of any time zone + * or calendar, represented as seconds and fractions of seconds at + * nanosecond resolution in UTC Epoch time. It is encoded using the + * Proleptic Gregorian Calendar which extends the Gregorian calendar + * backwards to year one. It is encoded assuming all minutes are 60 + * seconds long, i.e. leap seconds are "smeared" so that no leap second + * table is needed for interpretation. Range is from + * 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. + * By restricting to that range, we ensure that we can convert to + * and from RFC 3339 date strings. + * See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). + * + * # Examples + * + * Example 1: Compute Timestamp from POSIX `time()`. + * + * Timestamp timestamp; + * timestamp.set_seconds(time(NULL)); + * timestamp.set_nanos(0); + * + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. + * + * struct timeval tv; + * gettimeofday(&tv, NULL); + * + * Timestamp timestamp; + * timestamp.set_seconds(tv.tv_sec); + * timestamp.set_nanos(tv.tv_usec * 1000); + * + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + * + * FILETIME ft; + * GetSystemTimeAsFileTime(&ft); + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + * + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + * Timestamp timestamp; + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + * + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + * + * long millis = System.currentTimeMillis(); + * + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + * .setNanos((int) ((millis % 1000) * 1000000)).build(); + * + * + * Example 5: Compute Timestamp from current time in Python. + * + * timestamp = Timestamp() + * timestamp.GetCurrentTime() + * + * # JSON Mapping + * + * In JSON format, the Timestamp type is encoded as a string in the + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + * where {year} is always expressed using four digits while {month}, {day}, + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + * is required, though only UTC (as indicated by "Z") is presently supported. + * + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + * 01:30 UTC on January 15, 2017. + * + * In JavaScript, one can convert a Date object to this format using the + * standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString] + * method. In Python, a standard `datetime.datetime` object can be converted + * to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) + * with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one + * can use the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--) + * to obtain a formatter capable of generating timestamps in this format. + **/ +@interface GPBTimestamp : GPBMessage + +/** + * Represents seconds of UTC time since Unix epoch + * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + * 9999-12-31T23:59:59Z inclusive. + **/ +@property(nonatomic, readwrite) int64_t seconds; + +/** + * Non-negative fractions of a second at nanosecond resolution. Negative + * second values with fractions must still have non-negative nanos values + * that count forward in time. Must be from 0 to 999,999,999 + * inclusive. + **/ +@property(nonatomic, readwrite) int32_t nanos; + +@end + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) diff --git a/Pods/Protobuf/objectivec/google/protobuf/Timestamp.pbobjc.m b/Pods/Protobuf/objectivec/google/protobuf/Timestamp.pbobjc.m new file mode 100644 index 0000000..4ab159f --- /dev/null +++ b/Pods/Protobuf/objectivec/google/protobuf/Timestamp.pbobjc.m @@ -0,0 +1,107 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/timestamp.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers_RuntimeSupport.h" +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "google/protobuf/Timestamp.pbobjc.h" +#endif +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +#pragma mark - GPBTimestampRoot + +@implementation GPBTimestampRoot + +// No extensions in the file and no imports, so no need to generate +// +extensionRegistry. + +@end + +#pragma mark - GPBTimestampRoot_FileDescriptor + +static GPBFileDescriptor *GPBTimestampRoot_FileDescriptor(void) { + // This is called by +initialize so there is no need to worry + // about thread safety of the singleton. + static GPBFileDescriptor *descriptor = NULL; + if (!descriptor) { + GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); + descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf" + objcPrefix:@"GPB" + syntax:GPBFileSyntaxProto3]; + } + return descriptor; +} + +#pragma mark - GPBTimestamp + +@implementation GPBTimestamp + +@dynamic seconds; +@dynamic nanos; + +typedef struct GPBTimestamp__storage_ { + uint32_t _has_storage_[1]; + int32_t nanos; + int64_t seconds; +} GPBTimestamp__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "seconds", + .dataTypeSpecific.className = NULL, + .number = GPBTimestamp_FieldNumber_Seconds, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBTimestamp__storage_, seconds), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeInt64, + }, + { + .name = "nanos", + .dataTypeSpecific.className = NULL, + .number = GPBTimestamp_FieldNumber_Nanos, + .hasIndex = 1, + .offset = (uint32_t)offsetof(GPBTimestamp__storage_, nanos), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeInt32, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBTimestamp class] + rootClass:[GPBTimestampRoot class] + file:GPBTimestampRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBTimestamp__storage_) + flags:GPBDescriptorInitializationFlag_None]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) diff --git a/Pods/Protobuf/objectivec/google/protobuf/Type.pbobjc.h b/Pods/Protobuf/objectivec/google/protobuf/Type.pbobjc.h new file mode 100644 index 0000000..1798697 --- /dev/null +++ b/Pods/Protobuf/objectivec/google/protobuf/Type.pbobjc.h @@ -0,0 +1,440 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/type.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers.h" +#endif + +#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002 +#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. +#endif +#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION +#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. +#endif + +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +CF_EXTERN_C_BEGIN + +@class GPBAny; +@class GPBEnumValue; +@class GPBField; +@class GPBOption; +@class GPBSourceContext; + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - Enum GPBSyntax + +/** The syntax in which a protocol buffer element is defined. */ +typedef GPB_ENUM(GPBSyntax) { + /** + * Value used if any message's field encounters a value that is not defined + * by this enum. The message will also have C functions to get/set the rawValue + * of the field. + **/ + GPBSyntax_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue, + /** Syntax `proto2`. */ + GPBSyntax_SyntaxProto2 = 0, + + /** Syntax `proto3`. */ + GPBSyntax_SyntaxProto3 = 1, +}; + +GPBEnumDescriptor *GPBSyntax_EnumDescriptor(void); + +/** + * Checks to see if the given value is defined by the enum or was not known at + * the time this source was generated. + **/ +BOOL GPBSyntax_IsValidValue(int32_t value); + +#pragma mark - Enum GPBField_Kind + +/** Basic field types. */ +typedef GPB_ENUM(GPBField_Kind) { + /** + * Value used if any message's field encounters a value that is not defined + * by this enum. The message will also have C functions to get/set the rawValue + * of the field. + **/ + GPBField_Kind_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue, + /** Field type unknown. */ + GPBField_Kind_TypeUnknown = 0, + + /** Field type double. */ + GPBField_Kind_TypeDouble = 1, + + /** Field type float. */ + GPBField_Kind_TypeFloat = 2, + + /** Field type int64. */ + GPBField_Kind_TypeInt64 = 3, + + /** Field type uint64. */ + GPBField_Kind_TypeUint64 = 4, + + /** Field type int32. */ + GPBField_Kind_TypeInt32 = 5, + + /** Field type fixed64. */ + GPBField_Kind_TypeFixed64 = 6, + + /** Field type fixed32. */ + GPBField_Kind_TypeFixed32 = 7, + + /** Field type bool. */ + GPBField_Kind_TypeBool = 8, + + /** Field type string. */ + GPBField_Kind_TypeString = 9, + + /** Field type group. Proto2 syntax only, and deprecated. */ + GPBField_Kind_TypeGroup = 10, + + /** Field type message. */ + GPBField_Kind_TypeMessage = 11, + + /** Field type bytes. */ + GPBField_Kind_TypeBytes = 12, + + /** Field type uint32. */ + GPBField_Kind_TypeUint32 = 13, + + /** Field type enum. */ + GPBField_Kind_TypeEnum = 14, + + /** Field type sfixed32. */ + GPBField_Kind_TypeSfixed32 = 15, + + /** Field type sfixed64. */ + GPBField_Kind_TypeSfixed64 = 16, + + /** Field type sint32. */ + GPBField_Kind_TypeSint32 = 17, + + /** Field type sint64. */ + GPBField_Kind_TypeSint64 = 18, +}; + +GPBEnumDescriptor *GPBField_Kind_EnumDescriptor(void); + +/** + * Checks to see if the given value is defined by the enum or was not known at + * the time this source was generated. + **/ +BOOL GPBField_Kind_IsValidValue(int32_t value); + +#pragma mark - Enum GPBField_Cardinality + +/** Whether a field is optional, required, or repeated. */ +typedef GPB_ENUM(GPBField_Cardinality) { + /** + * Value used if any message's field encounters a value that is not defined + * by this enum. The message will also have C functions to get/set the rawValue + * of the field. + **/ + GPBField_Cardinality_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue, + /** For fields with unknown cardinality. */ + GPBField_Cardinality_CardinalityUnknown = 0, + + /** For optional fields. */ + GPBField_Cardinality_CardinalityOptional = 1, + + /** For required fields. Proto2 syntax only. */ + GPBField_Cardinality_CardinalityRequired = 2, + + /** For repeated fields. */ + GPBField_Cardinality_CardinalityRepeated = 3, +}; + +GPBEnumDescriptor *GPBField_Cardinality_EnumDescriptor(void); + +/** + * Checks to see if the given value is defined by the enum or was not known at + * the time this source was generated. + **/ +BOOL GPBField_Cardinality_IsValidValue(int32_t value); + +#pragma mark - GPBTypeRoot + +/** + * Exposes the extension registry for this file. + * + * The base class provides: + * @code + * + (GPBExtensionRegistry *)extensionRegistry; + * @endcode + * which is a @c GPBExtensionRegistry that includes all the extensions defined by + * this file and all files that it depends on. + **/ +@interface GPBTypeRoot : GPBRootObject +@end + +#pragma mark - GPBType + +typedef GPB_ENUM(GPBType_FieldNumber) { + GPBType_FieldNumber_Name = 1, + GPBType_FieldNumber_FieldsArray = 2, + GPBType_FieldNumber_OneofsArray = 3, + GPBType_FieldNumber_OptionsArray = 4, + GPBType_FieldNumber_SourceContext = 5, + GPBType_FieldNumber_Syntax = 6, +}; + +/** + * A protocol buffer message type. + **/ +@interface GPBType : GPBMessage + +/** The fully qualified message name. */ +@property(nonatomic, readwrite, copy, null_resettable) NSString *name; + +/** The list of fields. */ +@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *fieldsArray; +/** The number of items in @c fieldsArray without causing the array to be created. */ +@property(nonatomic, readonly) NSUInteger fieldsArray_Count; + +/** The list of types appearing in `oneof` definitions in this type. */ +@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *oneofsArray; +/** The number of items in @c oneofsArray without causing the array to be created. */ +@property(nonatomic, readonly) NSUInteger oneofsArray_Count; + +/** The protocol buffer options. */ +@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray; +/** The number of items in @c optionsArray without causing the array to be created. */ +@property(nonatomic, readonly) NSUInteger optionsArray_Count; + +/** The source context. */ +@property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext; +/** Test to see if @c sourceContext has been set. */ +@property(nonatomic, readwrite) BOOL hasSourceContext; + +/** The source syntax. */ +@property(nonatomic, readwrite) GPBSyntax syntax; + +@end + +/** + * Fetches the raw value of a @c GPBType's @c syntax property, even + * if the value was not defined by the enum at the time the code was generated. + **/ +int32_t GPBType_Syntax_RawValue(GPBType *message); +/** + * Sets the raw value of an @c GPBType's @c syntax property, allowing + * it to be set to a value that was not defined by the enum at the time the code + * was generated. + **/ +void SetGPBType_Syntax_RawValue(GPBType *message, int32_t value); + +#pragma mark - GPBField + +typedef GPB_ENUM(GPBField_FieldNumber) { + GPBField_FieldNumber_Kind = 1, + GPBField_FieldNumber_Cardinality = 2, + GPBField_FieldNumber_Number = 3, + GPBField_FieldNumber_Name = 4, + GPBField_FieldNumber_TypeURL = 6, + GPBField_FieldNumber_OneofIndex = 7, + GPBField_FieldNumber_Packed = 8, + GPBField_FieldNumber_OptionsArray = 9, + GPBField_FieldNumber_JsonName = 10, + GPBField_FieldNumber_DefaultValue = 11, +}; + +/** + * A single field of a message type. + **/ +@interface GPBField : GPBMessage + +/** The field type. */ +@property(nonatomic, readwrite) GPBField_Kind kind; + +/** The field cardinality. */ +@property(nonatomic, readwrite) GPBField_Cardinality cardinality; + +/** The field number. */ +@property(nonatomic, readwrite) int32_t number; + +/** The field name. */ +@property(nonatomic, readwrite, copy, null_resettable) NSString *name; + +/** + * The field type URL, without the scheme, for message or enumeration + * types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`. + **/ +@property(nonatomic, readwrite, copy, null_resettable) NSString *typeURL; + +/** + * The index of the field type in `Type.oneofs`, for message or enumeration + * types. The first type has index 1; zero means the type is not in the list. + **/ +@property(nonatomic, readwrite) int32_t oneofIndex; + +/** Whether to use alternative packed wire representation. */ +@property(nonatomic, readwrite) BOOL packed; + +/** The protocol buffer options. */ +@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray; +/** The number of items in @c optionsArray without causing the array to be created. */ +@property(nonatomic, readonly) NSUInteger optionsArray_Count; + +/** The field JSON name. */ +@property(nonatomic, readwrite, copy, null_resettable) NSString *jsonName; + +/** The string value of the default value of this field. Proto2 syntax only. */ +@property(nonatomic, readwrite, copy, null_resettable) NSString *defaultValue; + +@end + +/** + * Fetches the raw value of a @c GPBField's @c kind property, even + * if the value was not defined by the enum at the time the code was generated. + **/ +int32_t GPBField_Kind_RawValue(GPBField *message); +/** + * Sets the raw value of an @c GPBField's @c kind property, allowing + * it to be set to a value that was not defined by the enum at the time the code + * was generated. + **/ +void SetGPBField_Kind_RawValue(GPBField *message, int32_t value); + +/** + * Fetches the raw value of a @c GPBField's @c cardinality property, even + * if the value was not defined by the enum at the time the code was generated. + **/ +int32_t GPBField_Cardinality_RawValue(GPBField *message); +/** + * Sets the raw value of an @c GPBField's @c cardinality property, allowing + * it to be set to a value that was not defined by the enum at the time the code + * was generated. + **/ +void SetGPBField_Cardinality_RawValue(GPBField *message, int32_t value); + +#pragma mark - GPBEnum + +typedef GPB_ENUM(GPBEnum_FieldNumber) { + GPBEnum_FieldNumber_Name = 1, + GPBEnum_FieldNumber_EnumvalueArray = 2, + GPBEnum_FieldNumber_OptionsArray = 3, + GPBEnum_FieldNumber_SourceContext = 4, + GPBEnum_FieldNumber_Syntax = 5, +}; + +/** + * Enum type definition. + **/ +@interface GPBEnum : GPBMessage + +/** Enum type name. */ +@property(nonatomic, readwrite, copy, null_resettable) NSString *name; + +/** Enum value definitions. */ +@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *enumvalueArray; +/** The number of items in @c enumvalueArray without causing the array to be created. */ +@property(nonatomic, readonly) NSUInteger enumvalueArray_Count; + +/** Protocol buffer options. */ +@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray; +/** The number of items in @c optionsArray without causing the array to be created. */ +@property(nonatomic, readonly) NSUInteger optionsArray_Count; + +/** The source context. */ +@property(nonatomic, readwrite, strong, null_resettable) GPBSourceContext *sourceContext; +/** Test to see if @c sourceContext has been set. */ +@property(nonatomic, readwrite) BOOL hasSourceContext; + +/** The source syntax. */ +@property(nonatomic, readwrite) GPBSyntax syntax; + +@end + +/** + * Fetches the raw value of a @c GPBEnum's @c syntax property, even + * if the value was not defined by the enum at the time the code was generated. + **/ +int32_t GPBEnum_Syntax_RawValue(GPBEnum *message); +/** + * Sets the raw value of an @c GPBEnum's @c syntax property, allowing + * it to be set to a value that was not defined by the enum at the time the code + * was generated. + **/ +void SetGPBEnum_Syntax_RawValue(GPBEnum *message, int32_t value); + +#pragma mark - GPBEnumValue + +typedef GPB_ENUM(GPBEnumValue_FieldNumber) { + GPBEnumValue_FieldNumber_Name = 1, + GPBEnumValue_FieldNumber_Number = 2, + GPBEnumValue_FieldNumber_OptionsArray = 3, +}; + +/** + * Enum value definition. + **/ +@interface GPBEnumValue : GPBMessage + +/** Enum value name. */ +@property(nonatomic, readwrite, copy, null_resettable) NSString *name; + +/** Enum value number. */ +@property(nonatomic, readwrite) int32_t number; + +/** Protocol buffer options. */ +@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *optionsArray; +/** The number of items in @c optionsArray without causing the array to be created. */ +@property(nonatomic, readonly) NSUInteger optionsArray_Count; + +@end + +#pragma mark - GPBOption + +typedef GPB_ENUM(GPBOption_FieldNumber) { + GPBOption_FieldNumber_Name = 1, + GPBOption_FieldNumber_Value = 2, +}; + +/** + * A protocol buffer option, which can be attached to a message, field, + * enumeration, etc. + **/ +@interface GPBOption : GPBMessage + +/** + * The option's name. For protobuf built-in options (options defined in + * descriptor.proto), this is the short name. For example, `"map_entry"`. + * For custom options, it should be the fully-qualified name. For example, + * `"google.api.http"`. + **/ +@property(nonatomic, readwrite, copy, null_resettable) NSString *name; + +/** + * The option's value packed in an Any message. If the value is a primitive, + * the corresponding wrapper type defined in google/protobuf/wrappers.proto + * should be used. If the value is an enum, it should be stored as an int32 + * value using the google.protobuf.Int32Value type. + **/ +@property(nonatomic, readwrite, strong, null_resettable) GPBAny *value; +/** Test to see if @c value has been set. */ +@property(nonatomic, readwrite) BOOL hasValue; + +@end + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) diff --git a/Pods/Protobuf/objectivec/google/protobuf/Type.pbobjc.m b/Pods/Protobuf/objectivec/google/protobuf/Type.pbobjc.m new file mode 100644 index 0000000..7a94938 --- /dev/null +++ b/Pods/Protobuf/objectivec/google/protobuf/Type.pbobjc.m @@ -0,0 +1,701 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/type.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers_RuntimeSupport.h" +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import + #import + #import +#else + #import "google/protobuf/Type.pbobjc.h" + #import "google/protobuf/Any.pbobjc.h" + #import "google/protobuf/SourceContext.pbobjc.h" +#endif +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +#pragma mark - GPBTypeRoot + +@implementation GPBTypeRoot + +// No extensions in the file and none of the imports (direct or indirect) +// defined extensions, so no need to generate +extensionRegistry. + +@end + +#pragma mark - GPBTypeRoot_FileDescriptor + +static GPBFileDescriptor *GPBTypeRoot_FileDescriptor(void) { + // This is called by +initialize so there is no need to worry + // about thread safety of the singleton. + static GPBFileDescriptor *descriptor = NULL; + if (!descriptor) { + GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); + descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf" + objcPrefix:@"GPB" + syntax:GPBFileSyntaxProto3]; + } + return descriptor; +} + +#pragma mark - Enum GPBSyntax + +GPBEnumDescriptor *GPBSyntax_EnumDescriptor(void) { + static GPBEnumDescriptor *descriptor = NULL; + if (!descriptor) { + static const char *valueNames = + "SyntaxProto2\000SyntaxProto3\000"; + static const int32_t values[] = { + GPBSyntax_SyntaxProto2, + GPBSyntax_SyntaxProto3, + }; + GPBEnumDescriptor *worker = + [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBSyntax) + valueNames:valueNames + values:values + count:(uint32_t)(sizeof(values) / sizeof(int32_t)) + enumVerifier:GPBSyntax_IsValidValue]; + if (!OSAtomicCompareAndSwapPtrBarrier(nil, worker, (void * volatile *)&descriptor)) { + [worker release]; + } + } + return descriptor; +} + +BOOL GPBSyntax_IsValidValue(int32_t value__) { + switch (value__) { + case GPBSyntax_SyntaxProto2: + case GPBSyntax_SyntaxProto3: + return YES; + default: + return NO; + } +} + +#pragma mark - GPBType + +@implementation GPBType + +@dynamic name; +@dynamic fieldsArray, fieldsArray_Count; +@dynamic oneofsArray, oneofsArray_Count; +@dynamic optionsArray, optionsArray_Count; +@dynamic hasSourceContext, sourceContext; +@dynamic syntax; + +typedef struct GPBType__storage_ { + uint32_t _has_storage_[1]; + GPBSyntax syntax; + NSString *name; + NSMutableArray *fieldsArray; + NSMutableArray *oneofsArray; + NSMutableArray *optionsArray; + GPBSourceContext *sourceContext; +} GPBType__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "name", + .dataTypeSpecific.className = NULL, + .number = GPBType_FieldNumber_Name, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBType__storage_, name), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeString, + }, + { + .name = "fieldsArray", + .dataTypeSpecific.className = GPBStringifySymbol(GPBField), + .number = GPBType_FieldNumber_FieldsArray, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBType__storage_, fieldsArray), + .flags = GPBFieldRepeated, + .dataType = GPBDataTypeMessage, + }, + { + .name = "oneofsArray", + .dataTypeSpecific.className = NULL, + .number = GPBType_FieldNumber_OneofsArray, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBType__storage_, oneofsArray), + .flags = GPBFieldRepeated, + .dataType = GPBDataTypeString, + }, + { + .name = "optionsArray", + .dataTypeSpecific.className = GPBStringifySymbol(GPBOption), + .number = GPBType_FieldNumber_OptionsArray, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBType__storage_, optionsArray), + .flags = GPBFieldRepeated, + .dataType = GPBDataTypeMessage, + }, + { + .name = "sourceContext", + .dataTypeSpecific.className = GPBStringifySymbol(GPBSourceContext), + .number = GPBType_FieldNumber_SourceContext, + .hasIndex = 1, + .offset = (uint32_t)offsetof(GPBType__storage_, sourceContext), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + { + .name = "syntax", + .dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor, + .number = GPBType_FieldNumber_Syntax, + .hasIndex = 2, + .offset = (uint32_t)offsetof(GPBType__storage_, syntax), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor), + .dataType = GPBDataTypeEnum, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBType class] + rootClass:[GPBTypeRoot class] + file:GPBTypeRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBType__storage_) + flags:GPBDescriptorInitializationFlag_None]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +int32_t GPBType_Syntax_RawValue(GPBType *message) { + GPBDescriptor *descriptor = [GPBType descriptor]; + GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBType_FieldNumber_Syntax]; + return GPBGetMessageInt32Field(message, field); +} + +void SetGPBType_Syntax_RawValue(GPBType *message, int32_t value) { + GPBDescriptor *descriptor = [GPBType descriptor]; + GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBType_FieldNumber_Syntax]; + GPBSetInt32IvarWithFieldInternal(message, field, value, descriptor.file.syntax); +} + +#pragma mark - GPBField + +@implementation GPBField + +@dynamic kind; +@dynamic cardinality; +@dynamic number; +@dynamic name; +@dynamic typeURL; +@dynamic oneofIndex; +@dynamic packed; +@dynamic optionsArray, optionsArray_Count; +@dynamic jsonName; +@dynamic defaultValue; + +typedef struct GPBField__storage_ { + uint32_t _has_storage_[1]; + GPBField_Kind kind; + GPBField_Cardinality cardinality; + int32_t number; + int32_t oneofIndex; + NSString *name; + NSString *typeURL; + NSMutableArray *optionsArray; + NSString *jsonName; + NSString *defaultValue; +} GPBField__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "kind", + .dataTypeSpecific.enumDescFunc = GPBField_Kind_EnumDescriptor, + .number = GPBField_FieldNumber_Kind, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBField__storage_, kind), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor), + .dataType = GPBDataTypeEnum, + }, + { + .name = "cardinality", + .dataTypeSpecific.enumDescFunc = GPBField_Cardinality_EnumDescriptor, + .number = GPBField_FieldNumber_Cardinality, + .hasIndex = 1, + .offset = (uint32_t)offsetof(GPBField__storage_, cardinality), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor), + .dataType = GPBDataTypeEnum, + }, + { + .name = "number", + .dataTypeSpecific.className = NULL, + .number = GPBField_FieldNumber_Number, + .hasIndex = 2, + .offset = (uint32_t)offsetof(GPBField__storage_, number), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeInt32, + }, + { + .name = "name", + .dataTypeSpecific.className = NULL, + .number = GPBField_FieldNumber_Name, + .hasIndex = 3, + .offset = (uint32_t)offsetof(GPBField__storage_, name), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeString, + }, + { + .name = "typeURL", + .dataTypeSpecific.className = NULL, + .number = GPBField_FieldNumber_TypeURL, + .hasIndex = 4, + .offset = (uint32_t)offsetof(GPBField__storage_, typeURL), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldTextFormatNameCustom), + .dataType = GPBDataTypeString, + }, + { + .name = "oneofIndex", + .dataTypeSpecific.className = NULL, + .number = GPBField_FieldNumber_OneofIndex, + .hasIndex = 5, + .offset = (uint32_t)offsetof(GPBField__storage_, oneofIndex), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeInt32, + }, + { + .name = "packed", + .dataTypeSpecific.className = NULL, + .number = GPBField_FieldNumber_Packed, + .hasIndex = 6, + .offset = 7, // Stored in _has_storage_ to save space. + .flags = GPBFieldOptional, + .dataType = GPBDataTypeBool, + }, + { + .name = "optionsArray", + .dataTypeSpecific.className = GPBStringifySymbol(GPBOption), + .number = GPBField_FieldNumber_OptionsArray, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBField__storage_, optionsArray), + .flags = GPBFieldRepeated, + .dataType = GPBDataTypeMessage, + }, + { + .name = "jsonName", + .dataTypeSpecific.className = NULL, + .number = GPBField_FieldNumber_JsonName, + .hasIndex = 8, + .offset = (uint32_t)offsetof(GPBField__storage_, jsonName), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeString, + }, + { + .name = "defaultValue", + .dataTypeSpecific.className = NULL, + .number = GPBField_FieldNumber_DefaultValue, + .hasIndex = 9, + .offset = (uint32_t)offsetof(GPBField__storage_, defaultValue), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeString, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBField class] + rootClass:[GPBTypeRoot class] + file:GPBTypeRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBField__storage_) + flags:GPBDescriptorInitializationFlag_None]; +#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + static const char *extraTextFormatInfo = + "\001\006\004\241!!\000"; + [localDescriptor setupExtraTextInfo:extraTextFormatInfo]; +#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +int32_t GPBField_Kind_RawValue(GPBField *message) { + GPBDescriptor *descriptor = [GPBField descriptor]; + GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBField_FieldNumber_Kind]; + return GPBGetMessageInt32Field(message, field); +} + +void SetGPBField_Kind_RawValue(GPBField *message, int32_t value) { + GPBDescriptor *descriptor = [GPBField descriptor]; + GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBField_FieldNumber_Kind]; + GPBSetInt32IvarWithFieldInternal(message, field, value, descriptor.file.syntax); +} + +int32_t GPBField_Cardinality_RawValue(GPBField *message) { + GPBDescriptor *descriptor = [GPBField descriptor]; + GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBField_FieldNumber_Cardinality]; + return GPBGetMessageInt32Field(message, field); +} + +void SetGPBField_Cardinality_RawValue(GPBField *message, int32_t value) { + GPBDescriptor *descriptor = [GPBField descriptor]; + GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBField_FieldNumber_Cardinality]; + GPBSetInt32IvarWithFieldInternal(message, field, value, descriptor.file.syntax); +} + +#pragma mark - Enum GPBField_Kind + +GPBEnumDescriptor *GPBField_Kind_EnumDescriptor(void) { + static GPBEnumDescriptor *descriptor = NULL; + if (!descriptor) { + static const char *valueNames = + "TypeUnknown\000TypeDouble\000TypeFloat\000TypeInt" + "64\000TypeUint64\000TypeInt32\000TypeFixed64\000Type" + "Fixed32\000TypeBool\000TypeString\000TypeGroup\000Ty" + "peMessage\000TypeBytes\000TypeUint32\000TypeEnum\000" + "TypeSfixed32\000TypeSfixed64\000TypeSint32\000Typ" + "eSint64\000"; + static const int32_t values[] = { + GPBField_Kind_TypeUnknown, + GPBField_Kind_TypeDouble, + GPBField_Kind_TypeFloat, + GPBField_Kind_TypeInt64, + GPBField_Kind_TypeUint64, + GPBField_Kind_TypeInt32, + GPBField_Kind_TypeFixed64, + GPBField_Kind_TypeFixed32, + GPBField_Kind_TypeBool, + GPBField_Kind_TypeString, + GPBField_Kind_TypeGroup, + GPBField_Kind_TypeMessage, + GPBField_Kind_TypeBytes, + GPBField_Kind_TypeUint32, + GPBField_Kind_TypeEnum, + GPBField_Kind_TypeSfixed32, + GPBField_Kind_TypeSfixed64, + GPBField_Kind_TypeSint32, + GPBField_Kind_TypeSint64, + }; + GPBEnumDescriptor *worker = + [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBField_Kind) + valueNames:valueNames + values:values + count:(uint32_t)(sizeof(values) / sizeof(int32_t)) + enumVerifier:GPBField_Kind_IsValidValue]; + if (!OSAtomicCompareAndSwapPtrBarrier(nil, worker, (void * volatile *)&descriptor)) { + [worker release]; + } + } + return descriptor; +} + +BOOL GPBField_Kind_IsValidValue(int32_t value__) { + switch (value__) { + case GPBField_Kind_TypeUnknown: + case GPBField_Kind_TypeDouble: + case GPBField_Kind_TypeFloat: + case GPBField_Kind_TypeInt64: + case GPBField_Kind_TypeUint64: + case GPBField_Kind_TypeInt32: + case GPBField_Kind_TypeFixed64: + case GPBField_Kind_TypeFixed32: + case GPBField_Kind_TypeBool: + case GPBField_Kind_TypeString: + case GPBField_Kind_TypeGroup: + case GPBField_Kind_TypeMessage: + case GPBField_Kind_TypeBytes: + case GPBField_Kind_TypeUint32: + case GPBField_Kind_TypeEnum: + case GPBField_Kind_TypeSfixed32: + case GPBField_Kind_TypeSfixed64: + case GPBField_Kind_TypeSint32: + case GPBField_Kind_TypeSint64: + return YES; + default: + return NO; + } +} + +#pragma mark - Enum GPBField_Cardinality + +GPBEnumDescriptor *GPBField_Cardinality_EnumDescriptor(void) { + static GPBEnumDescriptor *descriptor = NULL; + if (!descriptor) { + static const char *valueNames = + "CardinalityUnknown\000CardinalityOptional\000C" + "ardinalityRequired\000CardinalityRepeated\000"; + static const int32_t values[] = { + GPBField_Cardinality_CardinalityUnknown, + GPBField_Cardinality_CardinalityOptional, + GPBField_Cardinality_CardinalityRequired, + GPBField_Cardinality_CardinalityRepeated, + }; + GPBEnumDescriptor *worker = + [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBField_Cardinality) + valueNames:valueNames + values:values + count:(uint32_t)(sizeof(values) / sizeof(int32_t)) + enumVerifier:GPBField_Cardinality_IsValidValue]; + if (!OSAtomicCompareAndSwapPtrBarrier(nil, worker, (void * volatile *)&descriptor)) { + [worker release]; + } + } + return descriptor; +} + +BOOL GPBField_Cardinality_IsValidValue(int32_t value__) { + switch (value__) { + case GPBField_Cardinality_CardinalityUnknown: + case GPBField_Cardinality_CardinalityOptional: + case GPBField_Cardinality_CardinalityRequired: + case GPBField_Cardinality_CardinalityRepeated: + return YES; + default: + return NO; + } +} + +#pragma mark - GPBEnum + +@implementation GPBEnum + +@dynamic name; +@dynamic enumvalueArray, enumvalueArray_Count; +@dynamic optionsArray, optionsArray_Count; +@dynamic hasSourceContext, sourceContext; +@dynamic syntax; + +typedef struct GPBEnum__storage_ { + uint32_t _has_storage_[1]; + GPBSyntax syntax; + NSString *name; + NSMutableArray *enumvalueArray; + NSMutableArray *optionsArray; + GPBSourceContext *sourceContext; +} GPBEnum__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "name", + .dataTypeSpecific.className = NULL, + .number = GPBEnum_FieldNumber_Name, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBEnum__storage_, name), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeString, + }, + { + .name = "enumvalueArray", + .dataTypeSpecific.className = GPBStringifySymbol(GPBEnumValue), + .number = GPBEnum_FieldNumber_EnumvalueArray, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBEnum__storage_, enumvalueArray), + .flags = GPBFieldRepeated, + .dataType = GPBDataTypeMessage, + }, + { + .name = "optionsArray", + .dataTypeSpecific.className = GPBStringifySymbol(GPBOption), + .number = GPBEnum_FieldNumber_OptionsArray, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBEnum__storage_, optionsArray), + .flags = GPBFieldRepeated, + .dataType = GPBDataTypeMessage, + }, + { + .name = "sourceContext", + .dataTypeSpecific.className = GPBStringifySymbol(GPBSourceContext), + .number = GPBEnum_FieldNumber_SourceContext, + .hasIndex = 1, + .offset = (uint32_t)offsetof(GPBEnum__storage_, sourceContext), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + { + .name = "syntax", + .dataTypeSpecific.enumDescFunc = GPBSyntax_EnumDescriptor, + .number = GPBEnum_FieldNumber_Syntax, + .hasIndex = 2, + .offset = (uint32_t)offsetof(GPBEnum__storage_, syntax), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor), + .dataType = GPBDataTypeEnum, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBEnum class] + rootClass:[GPBTypeRoot class] + file:GPBTypeRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBEnum__storage_) + flags:GPBDescriptorInitializationFlag_None]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +int32_t GPBEnum_Syntax_RawValue(GPBEnum *message) { + GPBDescriptor *descriptor = [GPBEnum descriptor]; + GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBEnum_FieldNumber_Syntax]; + return GPBGetMessageInt32Field(message, field); +} + +void SetGPBEnum_Syntax_RawValue(GPBEnum *message, int32_t value) { + GPBDescriptor *descriptor = [GPBEnum descriptor]; + GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBEnum_FieldNumber_Syntax]; + GPBSetInt32IvarWithFieldInternal(message, field, value, descriptor.file.syntax); +} + +#pragma mark - GPBEnumValue + +@implementation GPBEnumValue + +@dynamic name; +@dynamic number; +@dynamic optionsArray, optionsArray_Count; + +typedef struct GPBEnumValue__storage_ { + uint32_t _has_storage_[1]; + int32_t number; + NSString *name; + NSMutableArray *optionsArray; +} GPBEnumValue__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "name", + .dataTypeSpecific.className = NULL, + .number = GPBEnumValue_FieldNumber_Name, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBEnumValue__storage_, name), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeString, + }, + { + .name = "number", + .dataTypeSpecific.className = NULL, + .number = GPBEnumValue_FieldNumber_Number, + .hasIndex = 1, + .offset = (uint32_t)offsetof(GPBEnumValue__storage_, number), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeInt32, + }, + { + .name = "optionsArray", + .dataTypeSpecific.className = GPBStringifySymbol(GPBOption), + .number = GPBEnumValue_FieldNumber_OptionsArray, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GPBEnumValue__storage_, optionsArray), + .flags = GPBFieldRepeated, + .dataType = GPBDataTypeMessage, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBEnumValue class] + rootClass:[GPBTypeRoot class] + file:GPBTypeRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBEnumValue__storage_) + flags:GPBDescriptorInitializationFlag_None]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - GPBOption + +@implementation GPBOption + +@dynamic name; +@dynamic hasValue, value; + +typedef struct GPBOption__storage_ { + uint32_t _has_storage_[1]; + NSString *name; + GPBAny *value; +} GPBOption__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "name", + .dataTypeSpecific.className = NULL, + .number = GPBOption_FieldNumber_Name, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBOption__storage_, name), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeString, + }, + { + .name = "value", + .dataTypeSpecific.className = GPBStringifySymbol(GPBAny), + .number = GPBOption_FieldNumber_Value, + .hasIndex = 1, + .offset = (uint32_t)offsetof(GPBOption__storage_, value), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBOption class] + rootClass:[GPBTypeRoot class] + file:GPBTypeRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBOption__storage_) + flags:GPBDescriptorInitializationFlag_None]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) diff --git a/Pods/Protobuf/objectivec/google/protobuf/Wrappers.pbobjc.h b/Pods/Protobuf/objectivec/google/protobuf/Wrappers.pbobjc.h new file mode 100644 index 0000000..3cb9fe7 --- /dev/null +++ b/Pods/Protobuf/objectivec/google/protobuf/Wrappers.pbobjc.h @@ -0,0 +1,215 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/wrappers.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers.h" +#endif + +#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002 +#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources. +#endif +#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION +#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources. +#endif + +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +CF_EXTERN_C_BEGIN + +NS_ASSUME_NONNULL_BEGIN + +#pragma mark - GPBWrappersRoot + +/** + * Exposes the extension registry for this file. + * + * The base class provides: + * @code + * + (GPBExtensionRegistry *)extensionRegistry; + * @endcode + * which is a @c GPBExtensionRegistry that includes all the extensions defined by + * this file and all files that it depends on. + **/ +@interface GPBWrappersRoot : GPBRootObject +@end + +#pragma mark - GPBDoubleValue + +typedef GPB_ENUM(GPBDoubleValue_FieldNumber) { + GPBDoubleValue_FieldNumber_Value = 1, +}; + +/** + * Wrapper message for `double`. + * + * The JSON representation for `DoubleValue` is JSON number. + **/ +@interface GPBDoubleValue : GPBMessage + +/** The double value. */ +@property(nonatomic, readwrite) double value; + +@end + +#pragma mark - GPBFloatValue + +typedef GPB_ENUM(GPBFloatValue_FieldNumber) { + GPBFloatValue_FieldNumber_Value = 1, +}; + +/** + * Wrapper message for `float`. + * + * The JSON representation for `FloatValue` is JSON number. + **/ +@interface GPBFloatValue : GPBMessage + +/** The float value. */ +@property(nonatomic, readwrite) float value; + +@end + +#pragma mark - GPBInt64Value + +typedef GPB_ENUM(GPBInt64Value_FieldNumber) { + GPBInt64Value_FieldNumber_Value = 1, +}; + +/** + * Wrapper message for `int64`. + * + * The JSON representation for `Int64Value` is JSON string. + **/ +@interface GPBInt64Value : GPBMessage + +/** The int64 value. */ +@property(nonatomic, readwrite) int64_t value; + +@end + +#pragma mark - GPBUInt64Value + +typedef GPB_ENUM(GPBUInt64Value_FieldNumber) { + GPBUInt64Value_FieldNumber_Value = 1, +}; + +/** + * Wrapper message for `uint64`. + * + * The JSON representation for `UInt64Value` is JSON string. + **/ +@interface GPBUInt64Value : GPBMessage + +/** The uint64 value. */ +@property(nonatomic, readwrite) uint64_t value; + +@end + +#pragma mark - GPBInt32Value + +typedef GPB_ENUM(GPBInt32Value_FieldNumber) { + GPBInt32Value_FieldNumber_Value = 1, +}; + +/** + * Wrapper message for `int32`. + * + * The JSON representation for `Int32Value` is JSON number. + **/ +@interface GPBInt32Value : GPBMessage + +/** The int32 value. */ +@property(nonatomic, readwrite) int32_t value; + +@end + +#pragma mark - GPBUInt32Value + +typedef GPB_ENUM(GPBUInt32Value_FieldNumber) { + GPBUInt32Value_FieldNumber_Value = 1, +}; + +/** + * Wrapper message for `uint32`. + * + * The JSON representation for `UInt32Value` is JSON number. + **/ +@interface GPBUInt32Value : GPBMessage + +/** The uint32 value. */ +@property(nonatomic, readwrite) uint32_t value; + +@end + +#pragma mark - GPBBoolValue + +typedef GPB_ENUM(GPBBoolValue_FieldNumber) { + GPBBoolValue_FieldNumber_Value = 1, +}; + +/** + * Wrapper message for `bool`. + * + * The JSON representation for `BoolValue` is JSON `true` and `false`. + **/ +@interface GPBBoolValue : GPBMessage + +/** The bool value. */ +@property(nonatomic, readwrite) BOOL value; + +@end + +#pragma mark - GPBStringValue + +typedef GPB_ENUM(GPBStringValue_FieldNumber) { + GPBStringValue_FieldNumber_Value = 1, +}; + +/** + * Wrapper message for `string`. + * + * The JSON representation for `StringValue` is JSON string. + **/ +@interface GPBStringValue : GPBMessage + +/** The string value. */ +@property(nonatomic, readwrite, copy, null_resettable) NSString *value; + +@end + +#pragma mark - GPBBytesValue + +typedef GPB_ENUM(GPBBytesValue_FieldNumber) { + GPBBytesValue_FieldNumber_Value = 1, +}; + +/** + * Wrapper message for `bytes`. + * + * The JSON representation for `BytesValue` is JSON string. + **/ +@interface GPBBytesValue : GPBMessage + +/** The bytes value. */ +@property(nonatomic, readwrite, copy, null_resettable) NSData *value; + +@end + +NS_ASSUME_NONNULL_END + +CF_EXTERN_C_END + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) diff --git a/Pods/Protobuf/objectivec/google/protobuf/Wrappers.pbobjc.m b/Pods/Protobuf/objectivec/google/protobuf/Wrappers.pbobjc.m new file mode 100644 index 0000000..5479eb1 --- /dev/null +++ b/Pods/Protobuf/objectivec/google/protobuf/Wrappers.pbobjc.m @@ -0,0 +1,439 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/wrappers.proto + +// This CPP symbol can be defined to use imports that match up to the framework +// imports needed when using CocoaPods. +#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) + #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0 +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "GPBProtocolBuffers_RuntimeSupport.h" +#endif + +#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS + #import +#else + #import "google/protobuf/Wrappers.pbobjc.h" +#endif +// @@protoc_insertion_point(imports) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +#pragma mark - GPBWrappersRoot + +@implementation GPBWrappersRoot + +// No extensions in the file and no imports, so no need to generate +// +extensionRegistry. + +@end + +#pragma mark - GPBWrappersRoot_FileDescriptor + +static GPBFileDescriptor *GPBWrappersRoot_FileDescriptor(void) { + // This is called by +initialize so there is no need to worry + // about thread safety of the singleton. + static GPBFileDescriptor *descriptor = NULL; + if (!descriptor) { + GPB_DEBUG_CHECK_RUNTIME_VERSIONS(); + descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf" + objcPrefix:@"GPB" + syntax:GPBFileSyntaxProto3]; + } + return descriptor; +} + +#pragma mark - GPBDoubleValue + +@implementation GPBDoubleValue + +@dynamic value; + +typedef struct GPBDoubleValue__storage_ { + uint32_t _has_storage_[1]; + double value; +} GPBDoubleValue__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "value", + .dataTypeSpecific.className = NULL, + .number = GPBDoubleValue_FieldNumber_Value, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBDoubleValue__storage_, value), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeDouble, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBDoubleValue class] + rootClass:[GPBWrappersRoot class] + file:GPBWrappersRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBDoubleValue__storage_) + flags:GPBDescriptorInitializationFlag_None]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - GPBFloatValue + +@implementation GPBFloatValue + +@dynamic value; + +typedef struct GPBFloatValue__storage_ { + uint32_t _has_storage_[1]; + float value; +} GPBFloatValue__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "value", + .dataTypeSpecific.className = NULL, + .number = GPBFloatValue_FieldNumber_Value, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBFloatValue__storage_, value), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeFloat, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBFloatValue class] + rootClass:[GPBWrappersRoot class] + file:GPBWrappersRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBFloatValue__storage_) + flags:GPBDescriptorInitializationFlag_None]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - GPBInt64Value + +@implementation GPBInt64Value + +@dynamic value; + +typedef struct GPBInt64Value__storage_ { + uint32_t _has_storage_[1]; + int64_t value; +} GPBInt64Value__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "value", + .dataTypeSpecific.className = NULL, + .number = GPBInt64Value_FieldNumber_Value, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBInt64Value__storage_, value), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeInt64, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBInt64Value class] + rootClass:[GPBWrappersRoot class] + file:GPBWrappersRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBInt64Value__storage_) + flags:GPBDescriptorInitializationFlag_None]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - GPBUInt64Value + +@implementation GPBUInt64Value + +@dynamic value; + +typedef struct GPBUInt64Value__storage_ { + uint32_t _has_storage_[1]; + uint64_t value; +} GPBUInt64Value__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "value", + .dataTypeSpecific.className = NULL, + .number = GPBUInt64Value_FieldNumber_Value, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBUInt64Value__storage_, value), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeUInt64, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBUInt64Value class] + rootClass:[GPBWrappersRoot class] + file:GPBWrappersRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBUInt64Value__storage_) + flags:GPBDescriptorInitializationFlag_None]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - GPBInt32Value + +@implementation GPBInt32Value + +@dynamic value; + +typedef struct GPBInt32Value__storage_ { + uint32_t _has_storage_[1]; + int32_t value; +} GPBInt32Value__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "value", + .dataTypeSpecific.className = NULL, + .number = GPBInt32Value_FieldNumber_Value, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBInt32Value__storage_, value), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeInt32, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBInt32Value class] + rootClass:[GPBWrappersRoot class] + file:GPBWrappersRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBInt32Value__storage_) + flags:GPBDescriptorInitializationFlag_None]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - GPBUInt32Value + +@implementation GPBUInt32Value + +@dynamic value; + +typedef struct GPBUInt32Value__storage_ { + uint32_t _has_storage_[1]; + uint32_t value; +} GPBUInt32Value__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "value", + .dataTypeSpecific.className = NULL, + .number = GPBUInt32Value_FieldNumber_Value, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBUInt32Value__storage_, value), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeUInt32, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBUInt32Value class] + rootClass:[GPBWrappersRoot class] + file:GPBWrappersRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBUInt32Value__storage_) + flags:GPBDescriptorInitializationFlag_None]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - GPBBoolValue + +@implementation GPBBoolValue + +@dynamic value; + +typedef struct GPBBoolValue__storage_ { + uint32_t _has_storage_[1]; +} GPBBoolValue__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "value", + .dataTypeSpecific.className = NULL, + .number = GPBBoolValue_FieldNumber_Value, + .hasIndex = 0, + .offset = 1, // Stored in _has_storage_ to save space. + .flags = GPBFieldOptional, + .dataType = GPBDataTypeBool, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBBoolValue class] + rootClass:[GPBWrappersRoot class] + file:GPBWrappersRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBBoolValue__storage_) + flags:GPBDescriptorInitializationFlag_None]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - GPBStringValue + +@implementation GPBStringValue + +@dynamic value; + +typedef struct GPBStringValue__storage_ { + uint32_t _has_storage_[1]; + NSString *value; +} GPBStringValue__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "value", + .dataTypeSpecific.className = NULL, + .number = GPBStringValue_FieldNumber_Value, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBStringValue__storage_, value), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeString, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBStringValue class] + rootClass:[GPBWrappersRoot class] + file:GPBWrappersRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBStringValue__storage_) + flags:GPBDescriptorInitializationFlag_None]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - GPBBytesValue + +@implementation GPBBytesValue + +@dynamic value; + +typedef struct GPBBytesValue__storage_ { + uint32_t _has_storage_[1]; + NSData *value; +} GPBBytesValue__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "value", + .dataTypeSpecific.className = NULL, + .number = GPBBytesValue_FieldNumber_Value, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GPBBytesValue__storage_, value), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeBytes, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GPBBytesValue class] + rootClass:[GPBWrappersRoot class] + file:GPBWrappersRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GPBBytesValue__storage_) + flags:GPBDescriptorInitializationFlag_None]; + NSAssert(descriptor == nil, @"Startup recursed!"); + descriptor = localDescriptor; + } + return descriptor; +} + +@end + + +#pragma clang diagnostic pop + +// @@protoc_insertion_point(global_scope) diff --git a/Pods/Target Support Files/GoogleToolboxForMac/GoogleToolboxForMac-dummy.m b/Pods/Target Support Files/GoogleToolboxForMac/GoogleToolboxForMac-dummy.m new file mode 100644 index 0000000..9e35ec0 --- /dev/null +++ b/Pods/Target Support Files/GoogleToolboxForMac/GoogleToolboxForMac-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_GoogleToolboxForMac : NSObject +@end +@implementation PodsDummy_GoogleToolboxForMac +@end diff --git a/Pods/Target Support Files/GoogleToolboxForMac/GoogleToolboxForMac-prefix.pch b/Pods/Target Support Files/GoogleToolboxForMac/GoogleToolboxForMac-prefix.pch new file mode 100644 index 0000000..beb2a24 --- /dev/null +++ b/Pods/Target Support Files/GoogleToolboxForMac/GoogleToolboxForMac-prefix.pch @@ -0,0 +1,12 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + diff --git a/Pods/Target Support Files/GoogleToolboxForMac/GoogleToolboxForMac-umbrella.h b/Pods/Target Support Files/GoogleToolboxForMac/GoogleToolboxForMac-umbrella.h new file mode 100644 index 0000000..d61dc0e --- /dev/null +++ b/Pods/Target Support Files/GoogleToolboxForMac/GoogleToolboxForMac-umbrella.h @@ -0,0 +1,19 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + +#import "GTMDefines.h" +#import "GTMLogger.h" +#import "GTMNSData+zlib.h" + +FOUNDATION_EXPORT double GoogleToolboxForMacVersionNumber; +FOUNDATION_EXPORT const unsigned char GoogleToolboxForMacVersionString[]; + diff --git a/Pods/Target Support Files/GoogleToolboxForMac/GoogleToolboxForMac.modulemap b/Pods/Target Support Files/GoogleToolboxForMac/GoogleToolboxForMac.modulemap new file mode 100644 index 0000000..3245b6d --- /dev/null +++ b/Pods/Target Support Files/GoogleToolboxForMac/GoogleToolboxForMac.modulemap @@ -0,0 +1,6 @@ +framework module GoogleToolboxForMac { + umbrella header "GoogleToolboxForMac-umbrella.h" + + export * + module * { export * } +} diff --git a/Pods/Target Support Files/GoogleToolboxForMac/GoogleToolboxForMac.xcconfig b/Pods/Target Support Files/GoogleToolboxForMac/GoogleToolboxForMac.xcconfig new file mode 100644 index 0000000..26bd4ff --- /dev/null +++ b/Pods/Target Support Files/GoogleToolboxForMac/GoogleToolboxForMac.xcconfig @@ -0,0 +1,10 @@ +CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/GoogleToolboxForMac +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Firebase" "${PODS_ROOT}/Headers/Public/FirebaseAnalytics" "${PODS_ROOT}/Headers/Public/FirebaseCore" "${PODS_ROOT}/Headers/Public/FirebaseInstanceID" "${PODS_ROOT}/Headers/Public/FirebaseMessaging" +OTHER_LDFLAGS = -l"z" +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT} +PODS_TARGET_SRCROOT = ${PODS_ROOT}/GoogleToolboxForMac +PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} +SKIP_INSTALL = YES diff --git a/Pods/Target Support Files/GoogleToolboxForMac/Info.plist b/Pods/Target Support Files/GoogleToolboxForMac/Info.plist new file mode 100644 index 0000000..d6204c0 --- /dev/null +++ b/Pods/Target Support Files/GoogleToolboxForMac/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 2.1.3 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/Pods/Target Support Files/Pods-blista/Info.plist b/Pods/Target Support Files/Pods-blista/Info.plist new file mode 100644 index 0000000..2243fe6 --- /dev/null +++ b/Pods/Target Support Files/Pods-blista/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0.0 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/Pods/Target Support Files/Pods-blista/Pods-blista-acknowledgements.markdown b/Pods/Target Support Files/Pods-blista/Pods-blista-acknowledgements.markdown new file mode 100644 index 0000000..715df27 --- /dev/null +++ b/Pods/Target Support Files/Pods-blista/Pods-blista-acknowledgements.markdown @@ -0,0 +1,299 @@ +# Acknowledgements +This application makes use of the following third party libraries: + +## Firebase + +Copyright 2018 Google + +## FirebaseAnalytics + +Copyright 2018 Google + +## FirebaseCore + +Copyright 2018 Google + +## FirebaseInstanceID + +Copyright 2018 Google + +## FirebaseMessaging + +Copyright 2018 Google + +## GoogleToolboxForMac + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +## Protobuf + +This license applies to all parts of Protocol Buffers except the following: + + - Atomicops support for generic gcc, located in + src/google/protobuf/stubs/atomicops_internals_generic_gcc.h. + This file is copyrighted by Red Hat Inc. + + - Atomicops support for AIX/POWER, located in + src/google/protobuf/stubs/atomicops_internals_power.h. + This file is copyrighted by Bloomberg Finance LP. + +Copyright 2014, Google Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Code generated by the Protocol Buffer compiler is owned by the owner +of the input file used when generating it. This code is not +standalone and requires a support library to be linked with it. This +support library is itself covered by the above license. + + +## nanopb + +Copyright (c) 2011 Petteri Aimonen + +This software is provided 'as-is', without any express or +implied warranty. In no event will the authors be held liable +for any damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you + must not claim that you wrote the original software. If you use + this software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and + must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source + distribution. + +Generated by CocoaPods - https://cocoapods.org diff --git a/Pods/Target Support Files/Pods-blista/Pods-blista-acknowledgements.plist b/Pods/Target Support Files/Pods-blista/Pods-blista-acknowledgements.plist new file mode 100644 index 0000000..e395d59 --- /dev/null +++ b/Pods/Target Support Files/Pods-blista/Pods-blista-acknowledgements.plist @@ -0,0 +1,373 @@ + + + + + PreferenceSpecifiers + + + FooterText + This application makes use of the following third party libraries: + Title + Acknowledgements + Type + PSGroupSpecifier + + + FooterText + Copyright 2018 Google + License + Copyright + Title + Firebase + Type + PSGroupSpecifier + + + FooterText + Copyright 2018 Google + License + Copyright + Title + FirebaseAnalytics + Type + PSGroupSpecifier + + + FooterText + Copyright 2018 Google + License + Copyright + Title + FirebaseCore + Type + PSGroupSpecifier + + + FooterText + Copyright 2018 Google + License + Copyright + Title + FirebaseInstanceID + Type + PSGroupSpecifier + + + FooterText + Copyright 2018 Google + License + Copyright + Title + FirebaseMessaging + Type + PSGroupSpecifier + + + FooterText + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + License + Apache + Title + GoogleToolboxForMac + Type + PSGroupSpecifier + + + FooterText + This license applies to all parts of Protocol Buffers except the following: + + - Atomicops support for generic gcc, located in + src/google/protobuf/stubs/atomicops_internals_generic_gcc.h. + This file is copyrighted by Red Hat Inc. + + - Atomicops support for AIX/POWER, located in + src/google/protobuf/stubs/atomicops_internals_power.h. + This file is copyrighted by Bloomberg Finance LP. + +Copyright 2014, Google Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Code generated by the Protocol Buffer compiler is owned by the owner +of the input file used when generating it. This code is not +standalone and requires a support library to be linked with it. This +support library is itself covered by the above license. + + License + 3-Clause BSD License + Title + Protobuf + Type + PSGroupSpecifier + + + FooterText + Copyright (c) 2011 Petteri Aimonen <jpa at nanopb.mail.kapsi.fi> + +This software is provided 'as-is', without any express or +implied warranty. In no event will the authors be held liable +for any damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you + must not claim that you wrote the original software. If you use + this software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and + must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source + distribution. + + License + zlib + Title + nanopb + Type + PSGroupSpecifier + + + FooterText + Generated by CocoaPods - https://cocoapods.org + Title + + Type + PSGroupSpecifier + + + StringsTable + Acknowledgements + Title + Acknowledgements + + diff --git a/Pods/Target Support Files/Pods-blista/Pods-blista-dummy.m b/Pods/Target Support Files/Pods-blista/Pods-blista-dummy.m new file mode 100644 index 0000000..6a82fa8 --- /dev/null +++ b/Pods/Target Support Files/Pods-blista/Pods-blista-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Pods_blista : NSObject +@end +@implementation PodsDummy_Pods_blista +@end diff --git a/Pods/Target Support Files/Pods-blista/Pods-blista-frameworks.sh b/Pods/Target Support Files/Pods-blista/Pods-blista-frameworks.sh new file mode 100755 index 0000000..886b2bf --- /dev/null +++ b/Pods/Target Support Files/Pods-blista/Pods-blista-frameworks.sh @@ -0,0 +1,148 @@ +#!/bin/sh +set -e + +echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" +mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + +SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" + +# Used as a return value for each invocation of `strip_invalid_archs` function. +STRIP_BINARY_RETVAL=0 + +# This protects against multiple targets copying the same framework dependency at the same time. The solution +# was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html +RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") + +# Copies and strips a vendored framework +install_framework() +{ + if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then + local source="${BUILT_PRODUCTS_DIR}/$1" + elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then + local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" + elif [ -r "$1" ]; then + local source="$1" + fi + + local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + + if [ -L "${source}" ]; then + echo "Symlinked..." + source="$(readlink "${source}")" + fi + + # Use filter instead of exclude so missing patterns don't throw errors. + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" + + local basename + basename="$(basename -s .framework "$1")" + binary="${destination}/${basename}.framework/${basename}" + if ! [ -r "$binary" ]; then + binary="${destination}/${basename}" + fi + + # Strip invalid architectures so "fat" simulator / device frameworks work on device + if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then + strip_invalid_archs "$binary" + fi + + # Resign the code if required by the build settings to avoid unstable apps + code_sign_if_enabled "${destination}/$(basename "$1")" + + # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. + if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then + local swift_runtime_libs + swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) + for lib in $swift_runtime_libs; do + echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" + rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" + code_sign_if_enabled "${destination}/${lib}" + done + fi +} + +# Copies and strips a vendored dSYM +install_dsym() { + local source="$1" + if [ -r "$source" ]; then + # Copy the dSYM into a the targets temp dir. + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DERIVED_FILES_DIR}\"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DERIVED_FILES_DIR}" + + local basename + basename="$(basename -s .framework.dSYM "$source")" + binary="${DERIVED_FILES_DIR}/${basename}.framework.dSYM/Contents/Resources/DWARF/${basename}" + + # Strip invalid architectures so "fat" simulator / device frameworks work on device + if [[ "$(file "$binary")" == *"Mach-O dSYM companion"* ]]; then + strip_invalid_archs "$binary" + fi + + if [[ $STRIP_BINARY_RETVAL == 1 ]]; then + # Move the stripped file into its final destination. + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\" \"${DWARF_DSYM_FOLDER_PATH}\"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.framework.dSYM" "${DWARF_DSYM_FOLDER_PATH}" + else + # The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing. + touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.framework.dSYM" + fi + fi +} + +# Signs a framework with the provided identity +code_sign_if_enabled() { + if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then + # Use the current code_sign_identitiy + echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" + local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'" + + if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then + code_sign_cmd="$code_sign_cmd &" + fi + echo "$code_sign_cmd" + eval "$code_sign_cmd" + fi +} + +# Strip invalid architectures +strip_invalid_archs() { + binary="$1" + # Get architectures for current target binary + binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)" + # Intersect them with the architectures we are building for + intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)" + # If there are no archs supported by this binary then warn the user + if [[ -z "$intersected_archs" ]]; then + echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)." + STRIP_BINARY_RETVAL=0 + return + fi + stripped="" + for arch in $binary_archs; do + if ! [[ "${ARCHS}" == *"$arch"* ]]; then + # Strip non-valid architectures in-place + lipo -remove "$arch" -output "$binary" "$binary" || exit 1 + stripped="$stripped $arch" + fi + done + if [[ "$stripped" ]]; then + echo "Stripped $binary of architectures:$stripped" + fi + STRIP_BINARY_RETVAL=1 +} + + +if [[ "$CONFIGURATION" == "Debug" ]]; then + install_framework "${BUILT_PRODUCTS_DIR}/GoogleToolboxForMac/GoogleToolboxForMac.framework" + install_framework "${BUILT_PRODUCTS_DIR}/Protobuf/Protobuf.framework" + install_framework "${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework" +fi +if [[ "$CONFIGURATION" == "Release" ]]; then + install_framework "${BUILT_PRODUCTS_DIR}/GoogleToolboxForMac/GoogleToolboxForMac.framework" + install_framework "${BUILT_PRODUCTS_DIR}/Protobuf/Protobuf.framework" + install_framework "${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework" +fi +if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then + wait +fi diff --git a/Pods/Target Support Files/Pods-blista/Pods-blista-resources.sh b/Pods/Target Support Files/Pods-blista/Pods-blista-resources.sh new file mode 100755 index 0000000..a7df440 --- /dev/null +++ b/Pods/Target Support Files/Pods-blista/Pods-blista-resources.sh @@ -0,0 +1,106 @@ +#!/bin/sh +set -e + +mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + +RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt +> "$RESOURCES_TO_COPY" + +XCASSET_FILES=() + +# This protects against multiple targets copying the same framework dependency at the same time. The solution +# was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html +RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") + +case "${TARGETED_DEVICE_FAMILY}" in + 1,2) + TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" + ;; + 1) + TARGET_DEVICE_ARGS="--target-device iphone" + ;; + 2) + TARGET_DEVICE_ARGS="--target-device ipad" + ;; + 3) + TARGET_DEVICE_ARGS="--target-device tv" + ;; + 4) + TARGET_DEVICE_ARGS="--target-device watch" + ;; + *) + TARGET_DEVICE_ARGS="--target-device mac" + ;; +esac + +install_resource() +{ + if [[ "$1" = /* ]] ; then + RESOURCE_PATH="$1" + else + RESOURCE_PATH="${PODS_ROOT}/$1" + fi + if [[ ! -e "$RESOURCE_PATH" ]] ; then + cat << EOM +error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. +EOM + exit 1 + fi + case $RESOURCE_PATH in + *.storyboard) + echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true + ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} + ;; + *.xib) + echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true + ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} + ;; + *.framework) + echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true + mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + ;; + *.xcdatamodel) + echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" || true + xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" + ;; + *.xcdatamodeld) + echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" || true + xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" + ;; + *.xcmappingmodel) + echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" || true + xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" + ;; + *.xcassets) + ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" + XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") + ;; + *) + echo "$RESOURCE_PATH" || true + echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" + ;; + esac +} + +mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then + mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +fi +rm -f "$RESOURCES_TO_COPY" + +if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] +then + # Find all other xcassets (this unfortunately includes those of path pods and other targets). + OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) + while read line; do + if [[ $line != "${PODS_ROOT}*" ]]; then + XCASSET_FILES+=("$line") + fi + done <<<"$OTHER_XCASSETS" + + printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +fi diff --git a/Pods/Target Support Files/Pods-blista/Pods-blista-umbrella.h b/Pods/Target Support Files/Pods-blista/Pods-blista-umbrella.h new file mode 100644 index 0000000..7a55111 --- /dev/null +++ b/Pods/Target Support Files/Pods-blista/Pods-blista-umbrella.h @@ -0,0 +1,16 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + + +FOUNDATION_EXPORT double Pods_blistaVersionNumber; +FOUNDATION_EXPORT const unsigned char Pods_blistaVersionString[]; + diff --git a/Pods/Target Support Files/Pods-blista/Pods-blista.debug.xcconfig b/Pods/Target Support Files/Pods-blista/Pods-blista.debug.xcconfig new file mode 100644 index 0000000..f7434bd --- /dev/null +++ b/Pods/Target Support Files/Pods-blista/Pods-blista.debug.xcconfig @@ -0,0 +1,10 @@ +FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/GoogleToolboxForMac" "${PODS_CONFIGURATION_BUILD_DIR}/Protobuf" "${PODS_CONFIGURATION_BUILD_DIR}/nanopb" "${PODS_ROOT}/FirebaseAnalytics/Frameworks" "${PODS_ROOT}/FirebaseCore/Frameworks" "${PODS_ROOT}/FirebaseInstanceID/Frameworks" "${PODS_ROOT}/FirebaseMessaging/Frameworks" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 $(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1 $(inherited) PB_FIELD_32BIT=1 PB_NO_PACKED_STRUCTS=1 +HEADER_SEARCH_PATHS = $(inherited) ${PODS_ROOT}/Firebase/Core/Sources $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Firebase" "${PODS_ROOT}/Headers/Public/FirebaseAnalytics" "${PODS_ROOT}/Headers/Public/FirebaseCore" "${PODS_ROOT}/Headers/Public/FirebaseInstanceID" "${PODS_ROOT}/Headers/Public/FirebaseMessaging" +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/GoogleToolboxForMac/GoogleToolboxForMac.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Protobuf/Protobuf.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/nanopb/nanopb.framework/Headers" -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/Firebase" -isystem "${PODS_ROOT}/Headers/Public/FirebaseAnalytics" -isystem "${PODS_ROOT}/Headers/Public/FirebaseCore" -isystem "${PODS_ROOT}/Headers/Public/FirebaseInstanceID" -isystem "${PODS_ROOT}/Headers/Public/FirebaseMessaging" +OTHER_LDFLAGS = $(inherited) -ObjC -l"c++" -l"sqlite3" -l"z" -framework "AddressBook" -framework "FirebaseAnalytics" -framework "FirebaseCore" -framework "FirebaseCoreDiagnostics" -framework "FirebaseInstanceID" -framework "FirebaseMessaging" -framework "FirebaseNanoPB" -framework "GoogleToolboxForMac" -framework "Protobuf" -framework "StoreKit" -framework "SystemConfiguration" -framework "nanopb" +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_PODFILE_DIR_PATH = ${SRCROOT}/. +PODS_ROOT = ${SRCROOT}/Pods diff --git a/Pods/Target Support Files/Pods-blista/Pods-blista.modulemap b/Pods/Target Support Files/Pods-blista/Pods-blista.modulemap new file mode 100644 index 0000000..40a3487 --- /dev/null +++ b/Pods/Target Support Files/Pods-blista/Pods-blista.modulemap @@ -0,0 +1,6 @@ +framework module Pods_blista { + umbrella header "Pods-blista-umbrella.h" + + export * + module * { export * } +} diff --git a/Pods/Target Support Files/Pods-blista/Pods-blista.release.xcconfig b/Pods/Target Support Files/Pods-blista/Pods-blista.release.xcconfig new file mode 100644 index 0000000..f7434bd --- /dev/null +++ b/Pods/Target Support Files/Pods-blista/Pods-blista.release.xcconfig @@ -0,0 +1,10 @@ +FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/GoogleToolboxForMac" "${PODS_CONFIGURATION_BUILD_DIR}/Protobuf" "${PODS_CONFIGURATION_BUILD_DIR}/nanopb" "${PODS_ROOT}/FirebaseAnalytics/Frameworks" "${PODS_ROOT}/FirebaseCore/Frameworks" "${PODS_ROOT}/FirebaseInstanceID/Frameworks" "${PODS_ROOT}/FirebaseMessaging/Frameworks" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 $(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1 $(inherited) PB_FIELD_32BIT=1 PB_NO_PACKED_STRUCTS=1 +HEADER_SEARCH_PATHS = $(inherited) ${PODS_ROOT}/Firebase/Core/Sources $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Firebase" "${PODS_ROOT}/Headers/Public/FirebaseAnalytics" "${PODS_ROOT}/Headers/Public/FirebaseCore" "${PODS_ROOT}/Headers/Public/FirebaseInstanceID" "${PODS_ROOT}/Headers/Public/FirebaseMessaging" +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/GoogleToolboxForMac/GoogleToolboxForMac.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Protobuf/Protobuf.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/nanopb/nanopb.framework/Headers" -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/Firebase" -isystem "${PODS_ROOT}/Headers/Public/FirebaseAnalytics" -isystem "${PODS_ROOT}/Headers/Public/FirebaseCore" -isystem "${PODS_ROOT}/Headers/Public/FirebaseInstanceID" -isystem "${PODS_ROOT}/Headers/Public/FirebaseMessaging" +OTHER_LDFLAGS = $(inherited) -ObjC -l"c++" -l"sqlite3" -l"z" -framework "AddressBook" -framework "FirebaseAnalytics" -framework "FirebaseCore" -framework "FirebaseCoreDiagnostics" -framework "FirebaseInstanceID" -framework "FirebaseMessaging" -framework "FirebaseNanoPB" -framework "GoogleToolboxForMac" -framework "Protobuf" -framework "StoreKit" -framework "SystemConfiguration" -framework "nanopb" +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_PODFILE_DIR_PATH = ${SRCROOT}/. +PODS_ROOT = ${SRCROOT}/Pods diff --git a/Pods/Target Support Files/Protobuf/Info.plist b/Pods/Target Support Files/Protobuf/Info.plist new file mode 100644 index 0000000..078bbf3 --- /dev/null +++ b/Pods/Target Support Files/Protobuf/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 3.5.0 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/Pods/Target Support Files/Protobuf/Protobuf-dummy.m b/Pods/Target Support Files/Protobuf/Protobuf-dummy.m new file mode 100644 index 0000000..e0f0a33 --- /dev/null +++ b/Pods/Target Support Files/Protobuf/Protobuf-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Protobuf : NSObject +@end +@implementation PodsDummy_Protobuf +@end diff --git a/Pods/Target Support Files/Protobuf/Protobuf-prefix.pch b/Pods/Target Support Files/Protobuf/Protobuf-prefix.pch new file mode 100644 index 0000000..beb2a24 --- /dev/null +++ b/Pods/Target Support Files/Protobuf/Protobuf-prefix.pch @@ -0,0 +1,12 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + diff --git a/Pods/Target Support Files/Protobuf/Protobuf-umbrella.h b/Pods/Target Support Files/Protobuf/Protobuf-umbrella.h new file mode 100644 index 0000000..9242d72 --- /dev/null +++ b/Pods/Target Support Files/Protobuf/Protobuf-umbrella.h @@ -0,0 +1,54 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + +#import "GPBArray.h" +#import "GPBArray_PackagePrivate.h" +#import "GPBBootstrap.h" +#import "GPBCodedInputStream.h" +#import "GPBCodedInputStream_PackagePrivate.h" +#import "GPBCodedOutputStream.h" +#import "GPBCodedOutputStream_PackagePrivate.h" +#import "GPBDescriptor.h" +#import "GPBDescriptor_PackagePrivate.h" +#import "GPBDictionary.h" +#import "GPBDictionary_PackagePrivate.h" +#import "GPBExtensionInternals.h" +#import "GPBExtensionRegistry.h" +#import "GPBMessage.h" +#import "GPBMessage_PackagePrivate.h" +#import "GPBProtocolBuffers.h" +#import "GPBProtocolBuffers_RuntimeSupport.h" +#import "GPBRootObject.h" +#import "GPBRootObject_PackagePrivate.h" +#import "GPBRuntimeTypes.h" +#import "GPBUnknownField.h" +#import "GPBUnknownFieldSet.h" +#import "GPBUnknownFieldSet_PackagePrivate.h" +#import "GPBUnknownField_PackagePrivate.h" +#import "GPBUtilities.h" +#import "GPBUtilities_PackagePrivate.h" +#import "GPBWellKnownTypes.h" +#import "GPBWireFormat.h" +#import "Any.pbobjc.h" +#import "Api.pbobjc.h" +#import "Duration.pbobjc.h" +#import "Empty.pbobjc.h" +#import "FieldMask.pbobjc.h" +#import "SourceContext.pbobjc.h" +#import "Struct.pbobjc.h" +#import "Timestamp.pbobjc.h" +#import "Type.pbobjc.h" +#import "Wrappers.pbobjc.h" + +FOUNDATION_EXPORT double ProtobufVersionNumber; +FOUNDATION_EXPORT const unsigned char ProtobufVersionString[]; + diff --git a/Pods/Target Support Files/Protobuf/Protobuf.modulemap b/Pods/Target Support Files/Protobuf/Protobuf.modulemap new file mode 100644 index 0000000..57d3b39 --- /dev/null +++ b/Pods/Target Support Files/Protobuf/Protobuf.modulemap @@ -0,0 +1,6 @@ +framework module Protobuf { + umbrella header "Protobuf-umbrella.h" + + export * + module * { export * } +} diff --git a/Pods/Target Support Files/Protobuf/Protobuf.xcconfig b/Pods/Target Support Files/Protobuf/Protobuf.xcconfig new file mode 100644 index 0000000..b653bb1 --- /dev/null +++ b/Pods/Target Support Files/Protobuf/Protobuf.xcconfig @@ -0,0 +1,9 @@ +CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/Protobuf +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 $(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Firebase" "${PODS_ROOT}/Headers/Public/FirebaseAnalytics" "${PODS_ROOT}/Headers/Public/FirebaseCore" "${PODS_ROOT}/Headers/Public/FirebaseInstanceID" "${PODS_ROOT}/Headers/Public/FirebaseMessaging" +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT} +PODS_TARGET_SRCROOT = ${PODS_ROOT}/Protobuf +PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} +SKIP_INSTALL = YES diff --git a/Pods/Target Support Files/nanopb/Info.plist b/Pods/Target Support Files/nanopb/Info.plist new file mode 100644 index 0000000..2cb2374 --- /dev/null +++ b/Pods/Target Support Files/nanopb/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 0.3.8 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/Pods/Target Support Files/nanopb/nanopb-dummy.m b/Pods/Target Support Files/nanopb/nanopb-dummy.m new file mode 100644 index 0000000..b3fa595 --- /dev/null +++ b/Pods/Target Support Files/nanopb/nanopb-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_nanopb : NSObject +@end +@implementation PodsDummy_nanopb +@end diff --git a/Pods/Target Support Files/nanopb/nanopb-prefix.pch b/Pods/Target Support Files/nanopb/nanopb-prefix.pch new file mode 100644 index 0000000..beb2a24 --- /dev/null +++ b/Pods/Target Support Files/nanopb/nanopb-prefix.pch @@ -0,0 +1,12 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + diff --git a/Pods/Target Support Files/nanopb/nanopb-umbrella.h b/Pods/Target Support Files/nanopb/nanopb-umbrella.h new file mode 100644 index 0000000..07e77b3 --- /dev/null +++ b/Pods/Target Support Files/nanopb/nanopb-umbrella.h @@ -0,0 +1,26 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + +#import "pb.h" +#import "pb_common.h" +#import "pb_decode.h" +#import "pb_encode.h" +#import "pb.h" +#import "pb_decode.h" +#import "pb_common.h" +#import "pb.h" +#import "pb_encode.h" +#import "pb_common.h" + +FOUNDATION_EXPORT double nanopbVersionNumber; +FOUNDATION_EXPORT const unsigned char nanopbVersionString[]; + diff --git a/Pods/Target Support Files/nanopb/nanopb.modulemap b/Pods/Target Support Files/nanopb/nanopb.modulemap new file mode 100644 index 0000000..e8d4b53 --- /dev/null +++ b/Pods/Target Support Files/nanopb/nanopb.modulemap @@ -0,0 +1,6 @@ +framework module nanopb { + umbrella header "nanopb-umbrella.h" + + export * + module * { export * } +} diff --git a/Pods/Target Support Files/nanopb/nanopb.xcconfig b/Pods/Target Support Files/nanopb/nanopb.xcconfig new file mode 100644 index 0000000..a5557d5 --- /dev/null +++ b/Pods/Target Support Files/nanopb/nanopb.xcconfig @@ -0,0 +1,9 @@ +CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/nanopb +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 $(inherited) PB_FIELD_32BIT=1 PB_NO_PACKED_STRUCTS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Firebase" "${PODS_ROOT}/Headers/Public/FirebaseAnalytics" "${PODS_ROOT}/Headers/Public/FirebaseCore" "${PODS_ROOT}/Headers/Public/FirebaseInstanceID" "${PODS_ROOT}/Headers/Public/FirebaseMessaging" +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT} +PODS_TARGET_SRCROOT = ${PODS_ROOT}/nanopb +PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} +SKIP_INSTALL = YES diff --git a/Pods/nanopb/LICENSE.txt b/Pods/nanopb/LICENSE.txt new file mode 100644 index 0000000..d11c9af --- /dev/null +++ b/Pods/nanopb/LICENSE.txt @@ -0,0 +1,20 @@ +Copyright (c) 2011 Petteri Aimonen + +This software is provided 'as-is', without any express or +implied warranty. In no event will the authors be held liable +for any damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you + must not claim that you wrote the original software. If you use + this software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and + must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source + distribution. diff --git a/Pods/nanopb/README.md b/Pods/nanopb/README.md new file mode 100644 index 0000000..07860f0 --- /dev/null +++ b/Pods/nanopb/README.md @@ -0,0 +1,71 @@ +Nanopb - Protocol Buffers for Embedded Systems +============================================== + +[![Build Status](https://travis-ci.org/nanopb/nanopb.svg?branch=master)](https://travis-ci.org/nanopb/nanopb) + +Nanopb is a small code-size Protocol Buffers implementation in ansi C. It is +especially suitable for use in microcontrollers, but fits any memory +restricted system. + +* **Homepage:** https://jpa.kapsi.fi/nanopb/ +* **Documentation:** https://jpa.kapsi.fi/nanopb/docs/ +* **Downloads:** https://jpa.kapsi.fi/nanopb/download/ +* **Forum:** https://groups.google.com/forum/#!forum/nanopb + + + +Using the nanopb library +------------------------ +To use the nanopb library, you need to do two things: + +1. Compile your .proto files for nanopb, using protoc. +2. Include pb_encode.c, pb_decode.c and pb_common.c in your project. + +The easiest way to get started is to study the project in "examples/simple". +It contains a Makefile, which should work directly under most Linux systems. +However, for any other kind of build system, see the manual steps in +README.txt in that folder. + + + +Using the Protocol Buffers compiler (protoc) +-------------------------------------------- +The nanopb generator is implemented as a plugin for the Google's own protoc +compiler. This has the advantage that there is no need to reimplement the +basic parsing of .proto files. However, it does mean that you need the +Google's protobuf library in order to run the generator. + +If you have downloaded a binary package for nanopb (either Windows, Linux or +Mac OS X version), the 'protoc' binary is included in the 'generator-bin' +folder. In this case, you are ready to go. Simply run this command: + + generator-bin/protoc --nanopb_out=. myprotocol.proto + +However, if you are using a git checkout or a plain source distribution, you +need to provide your own version of protoc and the Google's protobuf library. +On Linux, the necessary packages are protobuf-compiler and python-protobuf. +On Windows, you can either build Google's protobuf library from source or use +one of the binary distributions of it. In either case, if you use a separate +protoc, you need to manually give the path to nanopb generator: + + protoc --plugin=protoc-gen-nanopb=nanopb/generator/protoc-gen-nanopb ... + + + +Running the tests +----------------- +If you want to perform further development of the nanopb core, or to verify +its functionality using your compiler and platform, you'll want to run the +test suite. The build rules for the test suite are implemented using Scons, +so you need to have that installed. To run the tests: + + cd tests + scons + +This will show the progress of various test cases. If the output does not +end in an error, the test cases were successful. + +Note: Mac OS X by default aliases 'clang' as 'gcc', while not actually +supporting the same command line options as gcc does. To run tests on +Mac OS X, use: "scons CC=clang CXX=clang". Same way can be used to run +tests with different compilers on any platform. diff --git a/Pods/nanopb/pb.h b/Pods/nanopb/pb.h new file mode 100644 index 0000000..bf05a63 --- /dev/null +++ b/Pods/nanopb/pb.h @@ -0,0 +1,583 @@ +/* Common parts of the nanopb library. Most of these are quite low-level + * stuff. For the high-level interface, see pb_encode.h and pb_decode.h. + */ + +#ifndef PB_H_INCLUDED +#define PB_H_INCLUDED + +/***************************************************************** + * Nanopb compilation time options. You can change these here by * + * uncommenting the lines, or on the compiler command line. * + *****************************************************************/ + +/* Enable support for dynamically allocated fields */ +/* #define PB_ENABLE_MALLOC 1 */ + +/* Define this if your CPU / compiler combination does not support + * unaligned memory access to packed structures. */ +/* #define PB_NO_PACKED_STRUCTS 1 */ + +/* Increase the number of required fields that are tracked. + * A compiler warning will tell if you need this. */ +/* #define PB_MAX_REQUIRED_FIELDS 256 */ + +/* Add support for tag numbers > 255 and fields larger than 255 bytes. */ +/* #define PB_FIELD_16BIT 1 */ + +/* Add support for tag numbers > 65536 and fields larger than 65536 bytes. */ +/* #define PB_FIELD_32BIT 1 */ + +/* Disable support for error messages in order to save some code space. */ +/* #define PB_NO_ERRMSG 1 */ + +/* Disable support for custom streams (support only memory buffers). */ +/* #define PB_BUFFER_ONLY 1 */ + +/* Switch back to the old-style callback function signature. + * This was the default until nanopb-0.2.1. */ +/* #define PB_OLD_CALLBACK_STYLE */ + + +/****************************************************************** + * You usually don't need to change anything below this line. * + * Feel free to look around and use the defined macros, though. * + ******************************************************************/ + + +/* Version of the nanopb library. Just in case you want to check it in + * your own program. */ +#define NANOPB_VERSION nanopb-0.3.8 + +/* Include all the system headers needed by nanopb. You will need the + * definitions of the following: + * - strlen, memcpy, memset functions + * - [u]int_least8_t, uint_fast8_t, [u]int_least16_t, [u]int32_t, [u]int64_t + * - size_t + * - bool + * + * If you don't have the standard header files, you can instead provide + * a custom header that defines or includes all this. In that case, + * define PB_SYSTEM_HEADER to the path of this file. + */ +#ifdef PB_SYSTEM_HEADER +#include PB_SYSTEM_HEADER +#else +#include +#include +#include +#include + +#ifdef PB_ENABLE_MALLOC +#include +#endif +#endif + +/* Macro for defining packed structures (compiler dependent). + * This just reduces memory requirements, but is not required. + */ +#if defined(PB_NO_PACKED_STRUCTS) + /* Disable struct packing */ +# define PB_PACKED_STRUCT_START +# define PB_PACKED_STRUCT_END +# define pb_packed +#elif defined(__GNUC__) || defined(__clang__) + /* For GCC and clang */ +# define PB_PACKED_STRUCT_START +# define PB_PACKED_STRUCT_END +# define pb_packed __attribute__((packed)) +#elif defined(__ICCARM__) || defined(__CC_ARM) + /* For IAR ARM and Keil MDK-ARM compilers */ +# define PB_PACKED_STRUCT_START _Pragma("pack(push, 1)") +# define PB_PACKED_STRUCT_END _Pragma("pack(pop)") +# define pb_packed +#elif defined(_MSC_VER) && (_MSC_VER >= 1500) + /* For Microsoft Visual C++ */ +# define PB_PACKED_STRUCT_START __pragma(pack(push, 1)) +# define PB_PACKED_STRUCT_END __pragma(pack(pop)) +# define pb_packed +#else + /* Unknown compiler */ +# define PB_PACKED_STRUCT_START +# define PB_PACKED_STRUCT_END +# define pb_packed +#endif + +/* Handly macro for suppressing unreferenced-parameter compiler warnings. */ +#ifndef PB_UNUSED +#define PB_UNUSED(x) (void)(x) +#endif + +/* Compile-time assertion, used for checking compatible compilation options. + * If this does not work properly on your compiler, use + * #define PB_NO_STATIC_ASSERT to disable it. + * + * But before doing that, check carefully the error message / place where it + * comes from to see if the error has a real cause. Unfortunately the error + * message is not always very clear to read, but you can see the reason better + * in the place where the PB_STATIC_ASSERT macro was called. + */ +#ifndef PB_NO_STATIC_ASSERT +#ifndef PB_STATIC_ASSERT +#define PB_STATIC_ASSERT(COND,MSG) typedef char PB_STATIC_ASSERT_MSG(MSG, __LINE__, __COUNTER__)[(COND)?1:-1]; +#define PB_STATIC_ASSERT_MSG(MSG, LINE, COUNTER) PB_STATIC_ASSERT_MSG_(MSG, LINE, COUNTER) +#define PB_STATIC_ASSERT_MSG_(MSG, LINE, COUNTER) pb_static_assertion_##MSG##LINE##COUNTER +#endif +#else +#define PB_STATIC_ASSERT(COND,MSG) +#endif + +/* Number of required fields to keep track of. */ +#ifndef PB_MAX_REQUIRED_FIELDS +#define PB_MAX_REQUIRED_FIELDS 64 +#endif + +#if PB_MAX_REQUIRED_FIELDS < 64 +#error You should not lower PB_MAX_REQUIRED_FIELDS from the default value (64). +#endif + +/* List of possible field types. These are used in the autogenerated code. + * Least-significant 4 bits tell the scalar type + * Most-significant 4 bits specify repeated/required/packed etc. + */ + +typedef uint_least8_t pb_type_t; + +/**** Field data types ****/ + +/* Numeric types */ +#define PB_LTYPE_VARINT 0x00 /* int32, int64, enum, bool */ +#define PB_LTYPE_UVARINT 0x01 /* uint32, uint64 */ +#define PB_LTYPE_SVARINT 0x02 /* sint32, sint64 */ +#define PB_LTYPE_FIXED32 0x03 /* fixed32, sfixed32, float */ +#define PB_LTYPE_FIXED64 0x04 /* fixed64, sfixed64, double */ + +/* Marker for last packable field type. */ +#define PB_LTYPE_LAST_PACKABLE 0x04 + +/* Byte array with pre-allocated buffer. + * data_size is the length of the allocated PB_BYTES_ARRAY structure. */ +#define PB_LTYPE_BYTES 0x05 + +/* String with pre-allocated buffer. + * data_size is the maximum length. */ +#define PB_LTYPE_STRING 0x06 + +/* Submessage + * submsg_fields is pointer to field descriptions */ +#define PB_LTYPE_SUBMESSAGE 0x07 + +/* Extension pseudo-field + * The field contains a pointer to pb_extension_t */ +#define PB_LTYPE_EXTENSION 0x08 + +/* Byte array with inline, pre-allocated byffer. + * data_size is the length of the inline, allocated buffer. + * This differs from PB_LTYPE_BYTES by defining the element as + * pb_byte_t[data_size] rather than pb_bytes_array_t. */ +#define PB_LTYPE_FIXED_LENGTH_BYTES 0x09 + +/* Number of declared LTYPES */ +#define PB_LTYPES_COUNT 0x0A +#define PB_LTYPE_MASK 0x0F + +/**** Field repetition rules ****/ + +#define PB_HTYPE_REQUIRED 0x00 +#define PB_HTYPE_OPTIONAL 0x10 +#define PB_HTYPE_REPEATED 0x20 +#define PB_HTYPE_ONEOF 0x30 +#define PB_HTYPE_MASK 0x30 + +/**** Field allocation types ****/ + +#define PB_ATYPE_STATIC 0x00 +#define PB_ATYPE_POINTER 0x80 +#define PB_ATYPE_CALLBACK 0x40 +#define PB_ATYPE_MASK 0xC0 + +#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK) +#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK) +#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK) + +/* Data type used for storing sizes of struct fields + * and array counts. + */ +#if defined(PB_FIELD_32BIT) + typedef uint32_t pb_size_t; + typedef int32_t pb_ssize_t; +#elif defined(PB_FIELD_16BIT) + typedef uint_least16_t pb_size_t; + typedef int_least16_t pb_ssize_t; +#else + typedef uint_least8_t pb_size_t; + typedef int_least8_t pb_ssize_t; +#endif +#define PB_SIZE_MAX ((pb_size_t)-1) + +/* Data type for storing encoded data and other byte streams. + * This typedef exists to support platforms where uint8_t does not exist. + * You can regard it as equivalent on uint8_t on other platforms. + */ +typedef uint_least8_t pb_byte_t; + +/* This structure is used in auto-generated constants + * to specify struct fields. + * You can change field sizes if you need structures + * larger than 256 bytes or field tags larger than 256. + * The compiler should complain if your .proto has such + * structures. Fix that by defining PB_FIELD_16BIT or + * PB_FIELD_32BIT. + */ +PB_PACKED_STRUCT_START +typedef struct pb_field_s pb_field_t; +struct pb_field_s { + pb_size_t tag; + pb_type_t type; + pb_size_t data_offset; /* Offset of field data, relative to previous field. */ + pb_ssize_t size_offset; /* Offset of array size or has-boolean, relative to data */ + pb_size_t data_size; /* Data size in bytes for a single item */ + pb_size_t array_size; /* Maximum number of entries in array */ + + /* Field definitions for submessage + * OR default value for all other non-array, non-callback types + * If null, then field will zeroed. */ + const void *ptr; +} pb_packed; +PB_PACKED_STRUCT_END + +/* Make sure that the standard integer types are of the expected sizes. + * Otherwise fixed32/fixed64 fields can break. + * + * If you get errors here, it probably means that your stdint.h is not + * correct for your platform. + */ +PB_STATIC_ASSERT(sizeof(int64_t) == 2 * sizeof(int32_t), INT64_T_WRONG_SIZE) +PB_STATIC_ASSERT(sizeof(uint64_t) == 2 * sizeof(uint32_t), UINT64_T_WRONG_SIZE) + +/* This structure is used for 'bytes' arrays. + * It has the number of bytes in the beginning, and after that an array. + * Note that actual structs used will have a different length of bytes array. + */ +#define PB_BYTES_ARRAY_T(n) struct { pb_size_t size; pb_byte_t bytes[n]; } +#define PB_BYTES_ARRAY_T_ALLOCSIZE(n) ((size_t)n + offsetof(pb_bytes_array_t, bytes)) + +struct pb_bytes_array_s { + pb_size_t size; + pb_byte_t bytes[1]; +}; +typedef struct pb_bytes_array_s pb_bytes_array_t; + +/* This structure is used for giving the callback function. + * It is stored in the message structure and filled in by the method that + * calls pb_decode. + * + * The decoding callback will be given a limited-length stream + * If the wire type was string, the length is the length of the string. + * If the wire type was a varint/fixed32/fixed64, the length is the length + * of the actual value. + * The function may be called multiple times (especially for repeated types, + * but also otherwise if the message happens to contain the field multiple + * times.) + * + * The encoding callback will receive the actual output stream. + * It should write all the data in one call, including the field tag and + * wire type. It can write multiple fields. + * + * The callback can be null if you want to skip a field. + */ +typedef struct pb_istream_s pb_istream_t; +typedef struct pb_ostream_s pb_ostream_t; +typedef struct pb_callback_s pb_callback_t; +struct pb_callback_s { +#ifdef PB_OLD_CALLBACK_STYLE + /* Deprecated since nanopb-0.2.1 */ + union { + bool (*decode)(pb_istream_t *stream, const pb_field_t *field, void *arg); + bool (*encode)(pb_ostream_t *stream, const pb_field_t *field, const void *arg); + } funcs; +#else + /* New function signature, which allows modifying arg contents in callback. */ + union { + bool (*decode)(pb_istream_t *stream, const pb_field_t *field, void **arg); + bool (*encode)(pb_ostream_t *stream, const pb_field_t *field, void * const *arg); + } funcs; +#endif + + /* Free arg for use by callback */ + void *arg; +}; + +/* Wire types. Library user needs these only in encoder callbacks. */ +typedef enum { + PB_WT_VARINT = 0, + PB_WT_64BIT = 1, + PB_WT_STRING = 2, + PB_WT_32BIT = 5 +} pb_wire_type_t; + +/* Structure for defining the handling of unknown/extension fields. + * Usually the pb_extension_type_t structure is automatically generated, + * while the pb_extension_t structure is created by the user. However, + * if you want to catch all unknown fields, you can also create a custom + * pb_extension_type_t with your own callback. + */ +typedef struct pb_extension_type_s pb_extension_type_t; +typedef struct pb_extension_s pb_extension_t; +struct pb_extension_type_s { + /* Called for each unknown field in the message. + * If you handle the field, read off all of its data and return true. + * If you do not handle the field, do not read anything and return true. + * If you run into an error, return false. + * Set to NULL for default handler. + */ + bool (*decode)(pb_istream_t *stream, pb_extension_t *extension, + uint32_t tag, pb_wire_type_t wire_type); + + /* Called once after all regular fields have been encoded. + * If you have something to write, do so and return true. + * If you do not have anything to write, just return true. + * If you run into an error, return false. + * Set to NULL for default handler. + */ + bool (*encode)(pb_ostream_t *stream, const pb_extension_t *extension); + + /* Free field for use by the callback. */ + const void *arg; +}; + +struct pb_extension_s { + /* Type describing the extension field. Usually you'll initialize + * this to a pointer to the automatically generated structure. */ + const pb_extension_type_t *type; + + /* Destination for the decoded data. This must match the datatype + * of the extension field. */ + void *dest; + + /* Pointer to the next extension handler, or NULL. + * If this extension does not match a field, the next handler is + * automatically called. */ + pb_extension_t *next; + + /* The decoder sets this to true if the extension was found. + * Ignored for encoding. */ + bool found; +}; + +/* Memory allocation functions to use. You can define pb_realloc and + * pb_free to custom functions if you want. */ +#ifdef PB_ENABLE_MALLOC +# ifndef pb_realloc +# define pb_realloc(ptr, size) realloc(ptr, size) +# endif +# ifndef pb_free +# define pb_free(ptr) free(ptr) +# endif +#endif + +/* This is used to inform about need to regenerate .pb.h/.pb.c files. */ +#define PB_PROTO_HEADER_VERSION 30 + +/* These macros are used to declare pb_field_t's in the constant array. */ +/* Size of a structure member, in bytes. */ +#define pb_membersize(st, m) (sizeof ((st*)0)->m) +/* Number of entries in an array. */ +#define pb_arraysize(st, m) (pb_membersize(st, m) / pb_membersize(st, m[0])) +/* Delta from start of one member to the start of another member. */ +#define pb_delta(st, m1, m2) ((int)offsetof(st, m1) - (int)offsetof(st, m2)) +/* Marks the end of the field list */ +#define PB_LAST_FIELD {0,(pb_type_t) 0,0,0,0,0,0} + +/* Macros for filling in the data_offset field */ +/* data_offset for first field in a message */ +#define PB_DATAOFFSET_FIRST(st, m1, m2) (offsetof(st, m1)) +/* data_offset for subsequent fields */ +#define PB_DATAOFFSET_OTHER(st, m1, m2) (offsetof(st, m1) - offsetof(st, m2) - pb_membersize(st, m2)) +/* data offset for subsequent fields inside an union (oneof) */ +#define PB_DATAOFFSET_UNION(st, m1, m2) (PB_SIZE_MAX) +/* Choose first/other based on m1 == m2 (deprecated, remains for backwards compatibility) */ +#define PB_DATAOFFSET_CHOOSE(st, m1, m2) (int)(offsetof(st, m1) == offsetof(st, m2) \ + ? PB_DATAOFFSET_FIRST(st, m1, m2) \ + : PB_DATAOFFSET_OTHER(st, m1, m2)) + +/* Required fields are the simplest. They just have delta (padding) from + * previous field end, and the size of the field. Pointer is used for + * submessages and default values. + */ +#define PB_REQUIRED_STATIC(tag, st, m, fd, ltype, ptr) \ + {tag, PB_ATYPE_STATIC | PB_HTYPE_REQUIRED | ltype, \ + fd, 0, pb_membersize(st, m), 0, ptr} + +/* Optional fields add the delta to the has_ variable. */ +#define PB_OPTIONAL_STATIC(tag, st, m, fd, ltype, ptr) \ + {tag, PB_ATYPE_STATIC | PB_HTYPE_OPTIONAL | ltype, \ + fd, \ + pb_delta(st, has_ ## m, m), \ + pb_membersize(st, m), 0, ptr} + +#define PB_SINGULAR_STATIC(tag, st, m, fd, ltype, ptr) \ + {tag, PB_ATYPE_STATIC | PB_HTYPE_OPTIONAL | ltype, \ + fd, 0, pb_membersize(st, m), 0, ptr} + +/* Repeated fields have a _count field and also the maximum number of entries. */ +#define PB_REPEATED_STATIC(tag, st, m, fd, ltype, ptr) \ + {tag, PB_ATYPE_STATIC | PB_HTYPE_REPEATED | ltype, \ + fd, \ + pb_delta(st, m ## _count, m), \ + pb_membersize(st, m[0]), \ + pb_arraysize(st, m), ptr} + +/* Allocated fields carry the size of the actual data, not the pointer */ +#define PB_REQUIRED_POINTER(tag, st, m, fd, ltype, ptr) \ + {tag, PB_ATYPE_POINTER | PB_HTYPE_REQUIRED | ltype, \ + fd, 0, pb_membersize(st, m[0]), 0, ptr} + +/* Optional fields don't need a has_ variable, as information would be redundant */ +#define PB_OPTIONAL_POINTER(tag, st, m, fd, ltype, ptr) \ + {tag, PB_ATYPE_POINTER | PB_HTYPE_OPTIONAL | ltype, \ + fd, 0, pb_membersize(st, m[0]), 0, ptr} + +/* Same as optional fields*/ +#define PB_SINGULAR_POINTER(tag, st, m, fd, ltype, ptr) \ + {tag, PB_ATYPE_POINTER | PB_HTYPE_OPTIONAL | ltype, \ + fd, 0, pb_membersize(st, m[0]), 0, ptr} + +/* Repeated fields have a _count field and a pointer to array of pointers */ +#define PB_REPEATED_POINTER(tag, st, m, fd, ltype, ptr) \ + {tag, PB_ATYPE_POINTER | PB_HTYPE_REPEATED | ltype, \ + fd, pb_delta(st, m ## _count, m), \ + pb_membersize(st, m[0]), 0, ptr} + +/* Callbacks are much like required fields except with special datatype. */ +#define PB_REQUIRED_CALLBACK(tag, st, m, fd, ltype, ptr) \ + {tag, PB_ATYPE_CALLBACK | PB_HTYPE_REQUIRED | ltype, \ + fd, 0, pb_membersize(st, m), 0, ptr} + +#define PB_OPTIONAL_CALLBACK(tag, st, m, fd, ltype, ptr) \ + {tag, PB_ATYPE_CALLBACK | PB_HTYPE_OPTIONAL | ltype, \ + fd, 0, pb_membersize(st, m), 0, ptr} + +#define PB_SINGULAR_CALLBACK(tag, st, m, fd, ltype, ptr) \ + {tag, PB_ATYPE_CALLBACK | PB_HTYPE_OPTIONAL | ltype, \ + fd, 0, pb_membersize(st, m), 0, ptr} + +#define PB_REPEATED_CALLBACK(tag, st, m, fd, ltype, ptr) \ + {tag, PB_ATYPE_CALLBACK | PB_HTYPE_REPEATED | ltype, \ + fd, 0, pb_membersize(st, m), 0, ptr} + +/* Optional extensions don't have the has_ field, as that would be redundant. + * Furthermore, the combination of OPTIONAL without has_ field is used + * for indicating proto3 style fields. Extensions exist in proto2 mode only, + * so they should be encoded according to proto2 rules. To avoid the conflict, + * extensions are marked as REQUIRED instead. + */ +#define PB_OPTEXT_STATIC(tag, st, m, fd, ltype, ptr) \ + {tag, PB_ATYPE_STATIC | PB_HTYPE_REQUIRED | ltype, \ + 0, \ + 0, \ + pb_membersize(st, m), 0, ptr} + +#define PB_OPTEXT_POINTER(tag, st, m, fd, ltype, ptr) \ + PB_OPTIONAL_POINTER(tag, st, m, fd, ltype, ptr) + +#define PB_OPTEXT_CALLBACK(tag, st, m, fd, ltype, ptr) \ + PB_OPTIONAL_CALLBACK(tag, st, m, fd, ltype, ptr) + +/* The mapping from protobuf types to LTYPEs is done using these macros. */ +#define PB_LTYPE_MAP_BOOL PB_LTYPE_VARINT +#define PB_LTYPE_MAP_BYTES PB_LTYPE_BYTES +#define PB_LTYPE_MAP_DOUBLE PB_LTYPE_FIXED64 +#define PB_LTYPE_MAP_ENUM PB_LTYPE_VARINT +#define PB_LTYPE_MAP_UENUM PB_LTYPE_UVARINT +#define PB_LTYPE_MAP_FIXED32 PB_LTYPE_FIXED32 +#define PB_LTYPE_MAP_FIXED64 PB_LTYPE_FIXED64 +#define PB_LTYPE_MAP_FLOAT PB_LTYPE_FIXED32 +#define PB_LTYPE_MAP_INT32 PB_LTYPE_VARINT +#define PB_LTYPE_MAP_INT64 PB_LTYPE_VARINT +#define PB_LTYPE_MAP_MESSAGE PB_LTYPE_SUBMESSAGE +#define PB_LTYPE_MAP_SFIXED32 PB_LTYPE_FIXED32 +#define PB_LTYPE_MAP_SFIXED64 PB_LTYPE_FIXED64 +#define PB_LTYPE_MAP_SINT32 PB_LTYPE_SVARINT +#define PB_LTYPE_MAP_SINT64 PB_LTYPE_SVARINT +#define PB_LTYPE_MAP_STRING PB_LTYPE_STRING +#define PB_LTYPE_MAP_UINT32 PB_LTYPE_UVARINT +#define PB_LTYPE_MAP_UINT64 PB_LTYPE_UVARINT +#define PB_LTYPE_MAP_EXTENSION PB_LTYPE_EXTENSION +#define PB_LTYPE_MAP_FIXED_LENGTH_BYTES PB_LTYPE_FIXED_LENGTH_BYTES + +/* This is the actual macro used in field descriptions. + * It takes these arguments: + * - Field tag number + * - Field type: BOOL, BYTES, DOUBLE, ENUM, UENUM, FIXED32, FIXED64, + * FLOAT, INT32, INT64, MESSAGE, SFIXED32, SFIXED64 + * SINT32, SINT64, STRING, UINT32, UINT64 or EXTENSION + * - Field rules: REQUIRED, OPTIONAL or REPEATED + * - Allocation: STATIC, CALLBACK or POINTER + * - Placement: FIRST or OTHER, depending on if this is the first field in structure. + * - Message name + * - Field name + * - Previous field name (or field name again for first field) + * - Pointer to default value or submsg fields. + */ + +#define PB_FIELD(tag, type, rules, allocation, placement, message, field, prevfield, ptr) \ + PB_ ## rules ## _ ## allocation(tag, message, field, \ + PB_DATAOFFSET_ ## placement(message, field, prevfield), \ + PB_LTYPE_MAP_ ## type, ptr) + +/* Field description for oneof fields. This requires taking into account the + * union name also, that's why a separate set of macros is needed. + */ +#define PB_ONEOF_STATIC(u, tag, st, m, fd, ltype, ptr) \ + {tag, PB_ATYPE_STATIC | PB_HTYPE_ONEOF | ltype, \ + fd, pb_delta(st, which_ ## u, u.m), \ + pb_membersize(st, u.m), 0, ptr} + +#define PB_ONEOF_POINTER(u, tag, st, m, fd, ltype, ptr) \ + {tag, PB_ATYPE_POINTER | PB_HTYPE_ONEOF | ltype, \ + fd, pb_delta(st, which_ ## u, u.m), \ + pb_membersize(st, u.m[0]), 0, ptr} + +#define PB_ONEOF_FIELD(union_name, tag, type, rules, allocation, placement, message, field, prevfield, ptr) \ + PB_ONEOF_ ## allocation(union_name, tag, message, field, \ + PB_DATAOFFSET_ ## placement(message, union_name.field, prevfield), \ + PB_LTYPE_MAP_ ## type, ptr) + +#define PB_ANONYMOUS_ONEOF_STATIC(u, tag, st, m, fd, ltype, ptr) \ + {tag, PB_ATYPE_STATIC | PB_HTYPE_ONEOF | ltype, \ + fd, pb_delta(st, which_ ## u, m), \ + pb_membersize(st, m), 0, ptr} + +#define PB_ANONYMOUS_ONEOF_POINTER(u, tag, st, m, fd, ltype, ptr) \ + {tag, PB_ATYPE_POINTER | PB_HTYPE_ONEOF | ltype, \ + fd, pb_delta(st, which_ ## u, m), \ + pb_membersize(st, m[0]), 0, ptr} + +#define PB_ANONYMOUS_ONEOF_FIELD(union_name, tag, type, rules, allocation, placement, message, field, prevfield, ptr) \ + PB_ANONYMOUS_ONEOF_ ## allocation(union_name, tag, message, field, \ + PB_DATAOFFSET_ ## placement(message, field, prevfield), \ + PB_LTYPE_MAP_ ## type, ptr) + +/* These macros are used for giving out error messages. + * They are mostly a debugging aid; the main error information + * is the true/false return value from functions. + * Some code space can be saved by disabling the error + * messages if not used. + * + * PB_SET_ERROR() sets the error message if none has been set yet. + * msg must be a constant string literal. + * PB_GET_ERROR() always returns a pointer to a string. + * PB_RETURN_ERROR() sets the error and returns false from current + * function. + */ +#ifdef PB_NO_ERRMSG +#define PB_SET_ERROR(stream, msg) PB_UNUSED(stream) +#define PB_GET_ERROR(stream) "(errmsg disabled)" +#else +#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg)) +#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)") +#endif + +#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false + +#endif diff --git a/Pods/nanopb/pb_common.c b/Pods/nanopb/pb_common.c new file mode 100644 index 0000000..4fb7186 --- /dev/null +++ b/Pods/nanopb/pb_common.c @@ -0,0 +1,97 @@ +/* pb_common.c: Common support functions for pb_encode.c and pb_decode.c. + * + * 2014 Petteri Aimonen + */ + +#include "pb_common.h" + +bool pb_field_iter_begin(pb_field_iter_t *iter, const pb_field_t *fields, void *dest_struct) +{ + iter->start = fields; + iter->pos = fields; + iter->required_field_index = 0; + iter->dest_struct = dest_struct; + iter->pData = (char*)dest_struct + iter->pos->data_offset; + iter->pSize = (char*)iter->pData + iter->pos->size_offset; + + return (iter->pos->tag != 0); +} + +bool pb_field_iter_next(pb_field_iter_t *iter) +{ + const pb_field_t *prev_field = iter->pos; + + if (prev_field->tag == 0) + { + /* Handle empty message types, where the first field is already the terminator. + * In other cases, the iter->pos never points to the terminator. */ + return false; + } + + iter->pos++; + + if (iter->pos->tag == 0) + { + /* Wrapped back to beginning, reinitialize */ + (void)pb_field_iter_begin(iter, iter->start, iter->dest_struct); + return false; + } + else + { + /* Increment the pointers based on previous field size */ + size_t prev_size = prev_field->data_size; + + if (PB_HTYPE(prev_field->type) == PB_HTYPE_ONEOF && + PB_HTYPE(iter->pos->type) == PB_HTYPE_ONEOF && + iter->pos->data_offset == PB_SIZE_MAX) + { + /* Don't advance pointers inside unions */ + return true; + } + else if (PB_ATYPE(prev_field->type) == PB_ATYPE_STATIC && + PB_HTYPE(prev_field->type) == PB_HTYPE_REPEATED) + { + /* In static arrays, the data_size tells the size of a single entry and + * array_size is the number of entries */ + prev_size *= prev_field->array_size; + } + else if (PB_ATYPE(prev_field->type) == PB_ATYPE_POINTER) + { + /* Pointer fields always have a constant size in the main structure. + * The data_size only applies to the dynamically allocated area. */ + prev_size = sizeof(void*); + } + + if (PB_HTYPE(prev_field->type) == PB_HTYPE_REQUIRED) + { + /* Count the required fields, in order to check their presence in the + * decoder. */ + iter->required_field_index++; + } + + iter->pData = (char*)iter->pData + prev_size + iter->pos->data_offset; + iter->pSize = (char*)iter->pData + iter->pos->size_offset; + return true; + } +} + +bool pb_field_iter_find(pb_field_iter_t *iter, uint32_t tag) +{ + const pb_field_t *start = iter->pos; + + do { + if (iter->pos->tag == tag && + PB_LTYPE(iter->pos->type) != PB_LTYPE_EXTENSION) + { + /* Found the wanted field */ + return true; + } + + (void)pb_field_iter_next(iter); + } while (iter->pos != start); + + /* Searched all the way back to start, and found nothing. */ + return false; +} + + diff --git a/Pods/nanopb/pb_common.h b/Pods/nanopb/pb_common.h new file mode 100644 index 0000000..60b3d37 --- /dev/null +++ b/Pods/nanopb/pb_common.h @@ -0,0 +1,42 @@ +/* pb_common.h: Common support functions for pb_encode.c and pb_decode.c. + * These functions are rarely needed by applications directly. + */ + +#ifndef PB_COMMON_H_INCLUDED +#define PB_COMMON_H_INCLUDED + +#include "pb.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Iterator for pb_field_t list */ +struct pb_field_iter_s { + const pb_field_t *start; /* Start of the pb_field_t array */ + const pb_field_t *pos; /* Current position of the iterator */ + unsigned required_field_index; /* Zero-based index that counts only the required fields */ + void *dest_struct; /* Pointer to start of the structure */ + void *pData; /* Pointer to current field value */ + void *pSize; /* Pointer to count/has field */ +}; +typedef struct pb_field_iter_s pb_field_iter_t; + +/* Initialize the field iterator structure to beginning. + * Returns false if the message type is empty. */ +bool pb_field_iter_begin(pb_field_iter_t *iter, const pb_field_t *fields, void *dest_struct); + +/* Advance the iterator to the next field. + * Returns false when the iterator wraps back to the first field. */ +bool pb_field_iter_next(pb_field_iter_t *iter); + +/* Advance the iterator until it points at a field with the given tag. + * Returns false if no such field exists. */ +bool pb_field_iter_find(pb_field_iter_t *iter, uint32_t tag); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif + diff --git a/Pods/nanopb/pb_decode.c b/Pods/nanopb/pb_decode.c new file mode 100644 index 0000000..e2e90ca --- /dev/null +++ b/Pods/nanopb/pb_decode.c @@ -0,0 +1,1379 @@ +/* pb_decode.c -- decode a protobuf using minimal resources + * + * 2011 Petteri Aimonen + */ + +/* Use the GCC warn_unused_result attribute to check that all return values + * are propagated correctly. On other compilers and gcc before 3.4.0 just + * ignore the annotation. + */ +#if !defined(__GNUC__) || ( __GNUC__ < 3) || (__GNUC__ == 3 && __GNUC_MINOR__ < 4) + #define checkreturn +#else + #define checkreturn __attribute__((warn_unused_result)) +#endif + +#include "pb.h" +#include "pb_decode.h" +#include "pb_common.h" + +/************************************** + * Declarations internal to this file * + **************************************/ + +typedef bool (*pb_decoder_t)(pb_istream_t *stream, const pb_field_t *field, void *dest) checkreturn; + +static bool checkreturn buf_read(pb_istream_t *stream, pb_byte_t *buf, size_t count); +static bool checkreturn read_raw_value(pb_istream_t *stream, pb_wire_type_t wire_type, pb_byte_t *buf, size_t *size); +static bool checkreturn decode_static_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter); +static bool checkreturn decode_callback_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter); +static bool checkreturn decode_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter); +static void iter_from_extension(pb_field_iter_t *iter, pb_extension_t *extension); +static bool checkreturn default_extension_decoder(pb_istream_t *stream, pb_extension_t *extension, uint32_t tag, pb_wire_type_t wire_type); +static bool checkreturn decode_extension(pb_istream_t *stream, uint32_t tag, pb_wire_type_t wire_type, pb_field_iter_t *iter); +static bool checkreturn find_extension_field(pb_field_iter_t *iter); +static void pb_field_set_to_default(pb_field_iter_t *iter); +static void pb_message_set_to_defaults(const pb_field_t fields[], void *dest_struct); +static bool checkreturn pb_dec_varint(pb_istream_t *stream, const pb_field_t *field, void *dest); +static bool checkreturn pb_dec_uvarint(pb_istream_t *stream, const pb_field_t *field, void *dest); +static bool checkreturn pb_dec_svarint(pb_istream_t *stream, const pb_field_t *field, void *dest); +static bool checkreturn pb_dec_fixed32(pb_istream_t *stream, const pb_field_t *field, void *dest); +static bool checkreturn pb_dec_fixed64(pb_istream_t *stream, const pb_field_t *field, void *dest); +static bool checkreturn pb_dec_bytes(pb_istream_t *stream, const pb_field_t *field, void *dest); +static bool checkreturn pb_dec_string(pb_istream_t *stream, const pb_field_t *field, void *dest); +static bool checkreturn pb_dec_submessage(pb_istream_t *stream, const pb_field_t *field, void *dest); +static bool checkreturn pb_dec_fixed_length_bytes(pb_istream_t *stream, const pb_field_t *field, void *dest); +static bool checkreturn pb_skip_varint(pb_istream_t *stream); +static bool checkreturn pb_skip_string(pb_istream_t *stream); + +#ifdef PB_ENABLE_MALLOC +static bool checkreturn allocate_field(pb_istream_t *stream, void *pData, size_t data_size, size_t array_size); +static bool checkreturn pb_release_union_field(pb_istream_t *stream, pb_field_iter_t *iter); +static void pb_release_single_field(const pb_field_iter_t *iter); +#endif + +/* --- Function pointers to field decoders --- + * Order in the array must match pb_action_t LTYPE numbering. + */ +static const pb_decoder_t PB_DECODERS[PB_LTYPES_COUNT] = { + &pb_dec_varint, + &pb_dec_uvarint, + &pb_dec_svarint, + &pb_dec_fixed32, + &pb_dec_fixed64, + + &pb_dec_bytes, + &pb_dec_string, + &pb_dec_submessage, + NULL, /* extensions */ + &pb_dec_fixed_length_bytes +}; + +/******************************* + * pb_istream_t implementation * + *******************************/ + +static bool checkreturn buf_read(pb_istream_t *stream, pb_byte_t *buf, size_t count) +{ + size_t i; + const pb_byte_t *source = (const pb_byte_t*)stream->state; + stream->state = (pb_byte_t*)stream->state + count; + + if (buf != NULL) + { + for (i = 0; i < count; i++) + buf[i] = source[i]; + } + + return true; +} + +bool checkreturn pb_read(pb_istream_t *stream, pb_byte_t *buf, size_t count) +{ +#ifndef PB_BUFFER_ONLY + if (buf == NULL && stream->callback != buf_read) + { + /* Skip input bytes */ + pb_byte_t tmp[16]; + while (count > 16) + { + if (!pb_read(stream, tmp, 16)) + return false; + + count -= 16; + } + + return pb_read(stream, tmp, count); + } +#endif + + if (stream->bytes_left < count) + PB_RETURN_ERROR(stream, "end-of-stream"); + +#ifndef PB_BUFFER_ONLY + if (!stream->callback(stream, buf, count)) + PB_RETURN_ERROR(stream, "io error"); +#else + if (!buf_read(stream, buf, count)) + return false; +#endif + + stream->bytes_left -= count; + return true; +} + +/* Read a single byte from input stream. buf may not be NULL. + * This is an optimization for the varint decoding. */ +static bool checkreturn pb_readbyte(pb_istream_t *stream, pb_byte_t *buf) +{ + if (stream->bytes_left == 0) + PB_RETURN_ERROR(stream, "end-of-stream"); + +#ifndef PB_BUFFER_ONLY + if (!stream->callback(stream, buf, 1)) + PB_RETURN_ERROR(stream, "io error"); +#else + *buf = *(const pb_byte_t*)stream->state; + stream->state = (pb_byte_t*)stream->state + 1; +#endif + + stream->bytes_left--; + + return true; +} + +pb_istream_t pb_istream_from_buffer(const pb_byte_t *buf, size_t bufsize) +{ + pb_istream_t stream; + /* Cast away the const from buf without a compiler error. We are + * careful to use it only in a const manner in the callbacks. + */ + union { + void *state; + const void *c_state; + } state; +#ifdef PB_BUFFER_ONLY + stream.callback = NULL; +#else + stream.callback = &buf_read; +#endif + state.c_state = buf; + stream.state = state.state; + stream.bytes_left = bufsize; +#ifndef PB_NO_ERRMSG + stream.errmsg = NULL; +#endif + return stream; +} + +/******************** + * Helper functions * + ********************/ + +bool checkreturn pb_decode_varint32(pb_istream_t *stream, uint32_t *dest) +{ + pb_byte_t byte; + uint32_t result; + + if (!pb_readbyte(stream, &byte)) + return false; + + if ((byte & 0x80) == 0) + { + /* Quick case, 1 byte value */ + result = byte; + } + else + { + /* Multibyte case */ + uint_fast8_t bitpos = 7; + result = byte & 0x7F; + + do + { + if (bitpos >= 32) + PB_RETURN_ERROR(stream, "varint overflow"); + + if (!pb_readbyte(stream, &byte)) + return false; + + result |= (uint32_t)(byte & 0x7F) << bitpos; + bitpos = (uint_fast8_t)(bitpos + 7); + } while (byte & 0x80); + } + + *dest = result; + return true; +} + +bool checkreturn pb_decode_varint(pb_istream_t *stream, uint64_t *dest) +{ + pb_byte_t byte; + uint_fast8_t bitpos = 0; + uint64_t result = 0; + + do + { + if (bitpos >= 64) + PB_RETURN_ERROR(stream, "varint overflow"); + + if (!pb_readbyte(stream, &byte)) + return false; + + result |= (uint64_t)(byte & 0x7F) << bitpos; + bitpos = (uint_fast8_t)(bitpos + 7); + } while (byte & 0x80); + + *dest = result; + return true; +} + +bool checkreturn pb_skip_varint(pb_istream_t *stream) +{ + pb_byte_t byte; + do + { + if (!pb_read(stream, &byte, 1)) + return false; + } while (byte & 0x80); + return true; +} + +bool checkreturn pb_skip_string(pb_istream_t *stream) +{ + uint32_t length; + if (!pb_decode_varint32(stream, &length)) + return false; + + return pb_read(stream, NULL, length); +} + +bool checkreturn pb_decode_tag(pb_istream_t *stream, pb_wire_type_t *wire_type, uint32_t *tag, bool *eof) +{ + uint32_t temp; + *eof = false; + *wire_type = (pb_wire_type_t) 0; + *tag = 0; + + if (!pb_decode_varint32(stream, &temp)) + { + if (stream->bytes_left == 0) + *eof = true; + + return false; + } + + if (temp == 0) + { + *eof = true; /* Special feature: allow 0-terminated messages. */ + return false; + } + + *tag = temp >> 3; + *wire_type = (pb_wire_type_t)(temp & 7); + return true; +} + +bool checkreturn pb_skip_field(pb_istream_t *stream, pb_wire_type_t wire_type) +{ + switch (wire_type) + { + case PB_WT_VARINT: return pb_skip_varint(stream); + case PB_WT_64BIT: return pb_read(stream, NULL, 8); + case PB_WT_STRING: return pb_skip_string(stream); + case PB_WT_32BIT: return pb_read(stream, NULL, 4); + default: PB_RETURN_ERROR(stream, "invalid wire_type"); + } +} + +/* Read a raw value to buffer, for the purpose of passing it to callback as + * a substream. Size is maximum size on call, and actual size on return. + */ +static bool checkreturn read_raw_value(pb_istream_t *stream, pb_wire_type_t wire_type, pb_byte_t *buf, size_t *size) +{ + size_t max_size = *size; + switch (wire_type) + { + case PB_WT_VARINT: + *size = 0; + do + { + (*size)++; + if (*size > max_size) return false; + if (!pb_read(stream, buf, 1)) return false; + } while (*buf++ & 0x80); + return true; + + case PB_WT_64BIT: + *size = 8; + return pb_read(stream, buf, 8); + + case PB_WT_32BIT: + *size = 4; + return pb_read(stream, buf, 4); + + default: PB_RETURN_ERROR(stream, "invalid wire_type"); + } +} + +/* Decode string length from stream and return a substream with limited length. + * Remember to close the substream using pb_close_string_substream(). + */ +bool checkreturn pb_make_string_substream(pb_istream_t *stream, pb_istream_t *substream) +{ + uint32_t size; + if (!pb_decode_varint32(stream, &size)) + return false; + + *substream = *stream; + if (substream->bytes_left < size) + PB_RETURN_ERROR(stream, "parent stream too short"); + + substream->bytes_left = size; + stream->bytes_left -= size; + return true; +} + +bool checkreturn pb_close_string_substream(pb_istream_t *stream, pb_istream_t *substream) +{ + if (substream->bytes_left) { + if (!pb_read(substream, NULL, substream->bytes_left)) + return false; + } + + stream->state = substream->state; + +#ifndef PB_NO_ERRMSG + stream->errmsg = substream->errmsg; +#endif + return true; +} + +/************************* + * Decode a single field * + *************************/ + +static bool checkreturn decode_static_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter) +{ + pb_type_t type; + pb_decoder_t func; + + type = iter->pos->type; + func = PB_DECODERS[PB_LTYPE(type)]; + + switch (PB_HTYPE(type)) + { + case PB_HTYPE_REQUIRED: + return func(stream, iter->pos, iter->pData); + + case PB_HTYPE_OPTIONAL: + if (iter->pSize != iter->pData) + *(bool*)iter->pSize = true; + return func(stream, iter->pos, iter->pData); + + case PB_HTYPE_REPEATED: + if (wire_type == PB_WT_STRING + && PB_LTYPE(type) <= PB_LTYPE_LAST_PACKABLE) + { + /* Packed array */ + bool status = true; + pb_size_t *size = (pb_size_t*)iter->pSize; + pb_istream_t substream; + if (!pb_make_string_substream(stream, &substream)) + return false; + + while (substream.bytes_left > 0 && *size < iter->pos->array_size) + { + void *pItem = (char*)iter->pData + iter->pos->data_size * (*size); + if (!func(&substream, iter->pos, pItem)) + { + status = false; + break; + } + (*size)++; + } + + if (substream.bytes_left != 0) + PB_RETURN_ERROR(stream, "array overflow"); + if (!pb_close_string_substream(stream, &substream)) + return false; + + return status; + } + else + { + /* Repeated field */ + pb_size_t *size = (pb_size_t*)iter->pSize; + void *pItem = (char*)iter->pData + iter->pos->data_size * (*size); + if (*size >= iter->pos->array_size) + PB_RETURN_ERROR(stream, "array overflow"); + + (*size)++; + return func(stream, iter->pos, pItem); + } + + case PB_HTYPE_ONEOF: + *(pb_size_t*)iter->pSize = iter->pos->tag; + if (PB_LTYPE(type) == PB_LTYPE_SUBMESSAGE) + { + /* We memset to zero so that any callbacks are set to NULL. + * Then set any default values. */ + memset(iter->pData, 0, iter->pos->data_size); + pb_message_set_to_defaults((const pb_field_t*)iter->pos->ptr, iter->pData); + } + return func(stream, iter->pos, iter->pData); + + default: + PB_RETURN_ERROR(stream, "invalid field type"); + } +} + +#ifdef PB_ENABLE_MALLOC +/* Allocate storage for the field and store the pointer at iter->pData. + * array_size is the number of entries to reserve in an array. + * Zero size is not allowed, use pb_free() for releasing. + */ +static bool checkreturn allocate_field(pb_istream_t *stream, void *pData, size_t data_size, size_t array_size) +{ + void *ptr = *(void**)pData; + + if (data_size == 0 || array_size == 0) + PB_RETURN_ERROR(stream, "invalid size"); + + /* Check for multiplication overflows. + * This code avoids the costly division if the sizes are small enough. + * Multiplication is safe as long as only half of bits are set + * in either multiplicand. + */ + { + const size_t check_limit = (size_t)1 << (sizeof(size_t) * 4); + if (data_size >= check_limit || array_size >= check_limit) + { + const size_t size_max = (size_t)-1; + if (size_max / array_size < data_size) + { + PB_RETURN_ERROR(stream, "size too large"); + } + } + } + + /* Allocate new or expand previous allocation */ + /* Note: on failure the old pointer will remain in the structure, + * the message must be freed by caller also on error return. */ + ptr = pb_realloc(ptr, array_size * data_size); + if (ptr == NULL) + PB_RETURN_ERROR(stream, "realloc failed"); + + *(void**)pData = ptr; + return true; +} + +/* Clear a newly allocated item in case it contains a pointer, or is a submessage. */ +static void initialize_pointer_field(void *pItem, pb_field_iter_t *iter) +{ + if (PB_LTYPE(iter->pos->type) == PB_LTYPE_STRING || + PB_LTYPE(iter->pos->type) == PB_LTYPE_BYTES) + { + *(void**)pItem = NULL; + } + else if (PB_LTYPE(iter->pos->type) == PB_LTYPE_SUBMESSAGE) + { + pb_message_set_to_defaults((const pb_field_t *) iter->pos->ptr, pItem); + } +} +#endif + +static bool checkreturn decode_pointer_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter) +{ +#ifndef PB_ENABLE_MALLOC + PB_UNUSED(wire_type); + PB_UNUSED(iter); + PB_RETURN_ERROR(stream, "no malloc support"); +#else + pb_type_t type; + pb_decoder_t func; + + type = iter->pos->type; + func = PB_DECODERS[PB_LTYPE(type)]; + + switch (PB_HTYPE(type)) + { + case PB_HTYPE_REQUIRED: + case PB_HTYPE_OPTIONAL: + case PB_HTYPE_ONEOF: + if (PB_LTYPE(type) == PB_LTYPE_SUBMESSAGE && + *(void**)iter->pData != NULL) + { + /* Duplicate field, have to release the old allocation first. */ + pb_release_single_field(iter); + } + + if (PB_HTYPE(type) == PB_HTYPE_ONEOF) + { + *(pb_size_t*)iter->pSize = iter->pos->tag; + } + + if (PB_LTYPE(type) == PB_LTYPE_STRING || + PB_LTYPE(type) == PB_LTYPE_BYTES) + { + return func(stream, iter->pos, iter->pData); + } + else + { + if (!allocate_field(stream, iter->pData, iter->pos->data_size, 1)) + return false; + + initialize_pointer_field(*(void**)iter->pData, iter); + return func(stream, iter->pos, *(void**)iter->pData); + } + + case PB_HTYPE_REPEATED: + if (wire_type == PB_WT_STRING + && PB_LTYPE(type) <= PB_LTYPE_LAST_PACKABLE) + { + /* Packed array, multiple items come in at once. */ + bool status = true; + pb_size_t *size = (pb_size_t*)iter->pSize; + size_t allocated_size = *size; + void *pItem; + pb_istream_t substream; + + if (!pb_make_string_substream(stream, &substream)) + return false; + + while (substream.bytes_left) + { + if ((size_t)*size + 1 > allocated_size) + { + /* Allocate more storage. This tries to guess the + * number of remaining entries. Round the division + * upwards. */ + allocated_size += (substream.bytes_left - 1) / iter->pos->data_size + 1; + + if (!allocate_field(&substream, iter->pData, iter->pos->data_size, allocated_size)) + { + status = false; + break; + } + } + + /* Decode the array entry */ + pItem = *(char**)iter->pData + iter->pos->data_size * (*size); + initialize_pointer_field(pItem, iter); + if (!func(&substream, iter->pos, pItem)) + { + status = false; + break; + } + + if (*size == PB_SIZE_MAX) + { +#ifndef PB_NO_ERRMSG + stream->errmsg = "too many array entries"; +#endif + status = false; + break; + } + + (*size)++; + } + if (!pb_close_string_substream(stream, &substream)) + return false; + + return status; + } + else + { + /* Normal repeated field, i.e. only one item at a time. */ + pb_size_t *size = (pb_size_t*)iter->pSize; + void *pItem; + + if (*size == PB_SIZE_MAX) + PB_RETURN_ERROR(stream, "too many array entries"); + + (*size)++; + if (!allocate_field(stream, iter->pData, iter->pos->data_size, *size)) + return false; + + pItem = *(char**)iter->pData + iter->pos->data_size * (*size - 1); + initialize_pointer_field(pItem, iter); + return func(stream, iter->pos, pItem); + } + + default: + PB_RETURN_ERROR(stream, "invalid field type"); + } +#endif +} + +static bool checkreturn decode_callback_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter) +{ + pb_callback_t *pCallback = (pb_callback_t*)iter->pData; + +#ifdef PB_OLD_CALLBACK_STYLE + void *arg = pCallback->arg; +#else + void **arg = &(pCallback->arg); +#endif + + if (pCallback->funcs.decode == NULL) + return pb_skip_field(stream, wire_type); + + if (wire_type == PB_WT_STRING) + { + pb_istream_t substream; + + if (!pb_make_string_substream(stream, &substream)) + return false; + + do + { + if (!pCallback->funcs.decode(&substream, iter->pos, arg)) + PB_RETURN_ERROR(stream, "callback failed"); + } while (substream.bytes_left); + + if (!pb_close_string_substream(stream, &substream)) + return false; + + return true; + } + else + { + /* Copy the single scalar value to stack. + * This is required so that we can limit the stream length, + * which in turn allows to use same callback for packed and + * not-packed fields. */ + pb_istream_t substream; + pb_byte_t buffer[10]; + size_t size = sizeof(buffer); + + if (!read_raw_value(stream, wire_type, buffer, &size)) + return false; + substream = pb_istream_from_buffer(buffer, size); + + return pCallback->funcs.decode(&substream, iter->pos, arg); + } +} + +static bool checkreturn decode_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iter_t *iter) +{ +#ifdef PB_ENABLE_MALLOC + /* When decoding an oneof field, check if there is old data that must be + * released first. */ + if (PB_HTYPE(iter->pos->type) == PB_HTYPE_ONEOF) + { + if (!pb_release_union_field(stream, iter)) + return false; + } +#endif + + switch (PB_ATYPE(iter->pos->type)) + { + case PB_ATYPE_STATIC: + return decode_static_field(stream, wire_type, iter); + + case PB_ATYPE_POINTER: + return decode_pointer_field(stream, wire_type, iter); + + case PB_ATYPE_CALLBACK: + return decode_callback_field(stream, wire_type, iter); + + default: + PB_RETURN_ERROR(stream, "invalid field type"); + } +} + +static void iter_from_extension(pb_field_iter_t *iter, pb_extension_t *extension) +{ + /* Fake a field iterator for the extension field. + * It is not actually safe to advance this iterator, but decode_field + * will not even try to. */ + const pb_field_t *field = (const pb_field_t*)extension->type->arg; + (void)pb_field_iter_begin(iter, field, extension->dest); + iter->pData = extension->dest; + iter->pSize = &extension->found; + + if (PB_ATYPE(field->type) == PB_ATYPE_POINTER) + { + /* For pointer extensions, the pointer is stored directly + * in the extension structure. This avoids having an extra + * indirection. */ + iter->pData = &extension->dest; + } +} + +/* Default handler for extension fields. Expects a pb_field_t structure + * in extension->type->arg. */ +static bool checkreturn default_extension_decoder(pb_istream_t *stream, + pb_extension_t *extension, uint32_t tag, pb_wire_type_t wire_type) +{ + const pb_field_t *field = (const pb_field_t*)extension->type->arg; + pb_field_iter_t iter; + + if (field->tag != tag) + return true; + + iter_from_extension(&iter, extension); + extension->found = true; + return decode_field(stream, wire_type, &iter); +} + +/* Try to decode an unknown field as an extension field. Tries each extension + * decoder in turn, until one of them handles the field or loop ends. */ +static bool checkreturn decode_extension(pb_istream_t *stream, + uint32_t tag, pb_wire_type_t wire_type, pb_field_iter_t *iter) +{ + pb_extension_t *extension = *(pb_extension_t* const *)iter->pData; + size_t pos = stream->bytes_left; + + while (extension != NULL && pos == stream->bytes_left) + { + bool status; + if (extension->type->decode) + status = extension->type->decode(stream, extension, tag, wire_type); + else + status = default_extension_decoder(stream, extension, tag, wire_type); + + if (!status) + return false; + + extension = extension->next; + } + + return true; +} + +/* Step through the iterator until an extension field is found or until all + * entries have been checked. There can be only one extension field per + * message. Returns false if no extension field is found. */ +static bool checkreturn find_extension_field(pb_field_iter_t *iter) +{ + const pb_field_t *start = iter->pos; + + do { + if (PB_LTYPE(iter->pos->type) == PB_LTYPE_EXTENSION) + return true; + (void)pb_field_iter_next(iter); + } while (iter->pos != start); + + return false; +} + +/* Initialize message fields to default values, recursively */ +static void pb_field_set_to_default(pb_field_iter_t *iter) +{ + pb_type_t type; + type = iter->pos->type; + + if (PB_LTYPE(type) == PB_LTYPE_EXTENSION) + { + pb_extension_t *ext = *(pb_extension_t* const *)iter->pData; + while (ext != NULL) + { + pb_field_iter_t ext_iter; + ext->found = false; + iter_from_extension(&ext_iter, ext); + pb_field_set_to_default(&ext_iter); + ext = ext->next; + } + } + else if (PB_ATYPE(type) == PB_ATYPE_STATIC) + { + bool init_data = true; + if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && iter->pSize != iter->pData) + { + /* Set has_field to false. Still initialize the optional field + * itself also. */ + *(bool*)iter->pSize = false; + } + else if (PB_HTYPE(type) == PB_HTYPE_REPEATED || + PB_HTYPE(type) == PB_HTYPE_ONEOF) + { + /* REPEATED: Set array count to 0, no need to initialize contents. + ONEOF: Set which_field to 0. */ + *(pb_size_t*)iter->pSize = 0; + init_data = false; + } + + if (init_data) + { + if (PB_LTYPE(iter->pos->type) == PB_LTYPE_SUBMESSAGE) + { + /* Initialize submessage to defaults */ + pb_message_set_to_defaults((const pb_field_t *) iter->pos->ptr, iter->pData); + } + else if (iter->pos->ptr != NULL) + { + /* Initialize to default value */ + memcpy(iter->pData, iter->pos->ptr, iter->pos->data_size); + } + else + { + /* Initialize to zeros */ + memset(iter->pData, 0, iter->pos->data_size); + } + } + } + else if (PB_ATYPE(type) == PB_ATYPE_POINTER) + { + /* Initialize the pointer to NULL. */ + *(void**)iter->pData = NULL; + + /* Initialize array count to 0. */ + if (PB_HTYPE(type) == PB_HTYPE_REPEATED || + PB_HTYPE(type) == PB_HTYPE_ONEOF) + { + *(pb_size_t*)iter->pSize = 0; + } + } + else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK) + { + /* Don't overwrite callback */ + } +} + +static void pb_message_set_to_defaults(const pb_field_t fields[], void *dest_struct) +{ + pb_field_iter_t iter; + + if (!pb_field_iter_begin(&iter, fields, dest_struct)) + return; /* Empty message type */ + + do + { + pb_field_set_to_default(&iter); + } while (pb_field_iter_next(&iter)); +} + +/********************* + * Decode all fields * + *********************/ + +bool checkreturn pb_decode_noinit(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct) +{ + uint32_t fields_seen[(PB_MAX_REQUIRED_FIELDS + 31) / 32] = {0, 0}; + const uint32_t allbits = ~(uint32_t)0; + uint32_t extension_range_start = 0; + pb_field_iter_t iter; + + /* Return value ignored, as empty message types will be correctly handled by + * pb_field_iter_find() anyway. */ + (void)pb_field_iter_begin(&iter, fields, dest_struct); + + while (stream->bytes_left) + { + uint32_t tag; + pb_wire_type_t wire_type; + bool eof; + + if (!pb_decode_tag(stream, &wire_type, &tag, &eof)) + { + if (eof) + break; + else + return false; + } + + if (!pb_field_iter_find(&iter, tag)) + { + /* No match found, check if it matches an extension. */ + if (tag >= extension_range_start) + { + if (!find_extension_field(&iter)) + extension_range_start = (uint32_t)-1; + else + extension_range_start = iter.pos->tag; + + if (tag >= extension_range_start) + { + size_t pos = stream->bytes_left; + + if (!decode_extension(stream, tag, wire_type, &iter)) + return false; + + if (pos != stream->bytes_left) + { + /* The field was handled */ + continue; + } + } + } + + /* No match found, skip data */ + if (!pb_skip_field(stream, wire_type)) + return false; + continue; + } + + if (PB_HTYPE(iter.pos->type) == PB_HTYPE_REQUIRED + && iter.required_field_index < PB_MAX_REQUIRED_FIELDS) + { + uint32_t tmp = ((uint32_t)1 << (iter.required_field_index & 31)); + fields_seen[iter.required_field_index >> 5] |= tmp; + } + + if (!decode_field(stream, wire_type, &iter)) + return false; + } + + /* Check that all required fields were present. */ + { + /* First figure out the number of required fields by + * seeking to the end of the field array. Usually we + * are already close to end after decoding. + */ + unsigned req_field_count; + pb_type_t last_type; + unsigned i; + do { + req_field_count = iter.required_field_index; + last_type = iter.pos->type; + } while (pb_field_iter_next(&iter)); + + /* Fixup if last field was also required. */ + if (PB_HTYPE(last_type) == PB_HTYPE_REQUIRED && iter.pos->tag != 0) + req_field_count++; + + if (req_field_count > 0) + { + /* Check the whole words */ + for (i = 0; i < (req_field_count >> 5); i++) + { + if (fields_seen[i] != allbits) + PB_RETURN_ERROR(stream, "missing required field"); + } + + /* Check the remaining bits */ + if (fields_seen[req_field_count >> 5] != (allbits >> (32 - (req_field_count & 31)))) + PB_RETURN_ERROR(stream, "missing required field"); + } + } + + return true; +} + +bool checkreturn pb_decode(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct) +{ + bool status; + pb_message_set_to_defaults(fields, dest_struct); + status = pb_decode_noinit(stream, fields, dest_struct); + +#ifdef PB_ENABLE_MALLOC + if (!status) + pb_release(fields, dest_struct); +#endif + + return status; +} + +bool pb_decode_delimited(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct) +{ + pb_istream_t substream; + bool status; + + if (!pb_make_string_substream(stream, &substream)) + return false; + + status = pb_decode(&substream, fields, dest_struct); + + if (!pb_close_string_substream(stream, &substream)) + return false; + return status; +} + +#ifdef PB_ENABLE_MALLOC +/* Given an oneof field, if there has already been a field inside this oneof, + * release it before overwriting with a different one. */ +static bool pb_release_union_field(pb_istream_t *stream, pb_field_iter_t *iter) +{ + pb_size_t old_tag = *(pb_size_t*)iter->pSize; /* Previous which_ value */ + pb_size_t new_tag = iter->pos->tag; /* New which_ value */ + + if (old_tag == 0) + return true; /* Ok, no old data in union */ + + if (old_tag == new_tag) + return true; /* Ok, old data is of same type => merge */ + + /* Release old data. The find can fail if the message struct contains + * invalid data. */ + if (!pb_field_iter_find(iter, old_tag)) + PB_RETURN_ERROR(stream, "invalid union tag"); + + pb_release_single_field(iter); + + /* Restore iterator to where it should be. + * This shouldn't fail unless the pb_field_t structure is corrupted. */ + if (!pb_field_iter_find(iter, new_tag)) + PB_RETURN_ERROR(stream, "iterator error"); + + return true; +} + +static void pb_release_single_field(const pb_field_iter_t *iter) +{ + pb_type_t type; + type = iter->pos->type; + + if (PB_HTYPE(type) == PB_HTYPE_ONEOF) + { + if (*(pb_size_t*)iter->pSize != iter->pos->tag) + return; /* This is not the current field in the union */ + } + + /* Release anything contained inside an extension or submsg. + * This has to be done even if the submsg itself is statically + * allocated. */ + if (PB_LTYPE(type) == PB_LTYPE_EXTENSION) + { + /* Release fields from all extensions in the linked list */ + pb_extension_t *ext = *(pb_extension_t**)iter->pData; + while (ext != NULL) + { + pb_field_iter_t ext_iter; + iter_from_extension(&ext_iter, ext); + pb_release_single_field(&ext_iter); + ext = ext->next; + } + } + else if (PB_LTYPE(type) == PB_LTYPE_SUBMESSAGE) + { + /* Release fields in submessage or submsg array */ + void *pItem = iter->pData; + pb_size_t count = 1; + + if (PB_ATYPE(type) == PB_ATYPE_POINTER) + { + pItem = *(void**)iter->pData; + } + + if (PB_HTYPE(type) == PB_HTYPE_REPEATED) + { + count = *(pb_size_t*)iter->pSize; + + if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > iter->pos->array_size) + { + /* Protect against corrupted _count fields */ + count = iter->pos->array_size; + } + } + + if (pItem) + { + while (count--) + { + pb_release((const pb_field_t*)iter->pos->ptr, pItem); + pItem = (char*)pItem + iter->pos->data_size; + } + } + } + + if (PB_ATYPE(type) == PB_ATYPE_POINTER) + { + if (PB_HTYPE(type) == PB_HTYPE_REPEATED && + (PB_LTYPE(type) == PB_LTYPE_STRING || + PB_LTYPE(type) == PB_LTYPE_BYTES)) + { + /* Release entries in repeated string or bytes array */ + void **pItem = *(void***)iter->pData; + pb_size_t count = *(pb_size_t*)iter->pSize; + while (count--) + { + pb_free(*pItem); + *pItem++ = NULL; + } + } + + if (PB_HTYPE(type) == PB_HTYPE_REPEATED) + { + /* We are going to release the array, so set the size to 0 */ + *(pb_size_t*)iter->pSize = 0; + } + + /* Release main item */ + pb_free(*(void**)iter->pData); + *(void**)iter->pData = NULL; + } +} + +void pb_release(const pb_field_t fields[], void *dest_struct) +{ + pb_field_iter_t iter; + + if (!dest_struct) + return; /* Ignore NULL pointers, similar to free() */ + + if (!pb_field_iter_begin(&iter, fields, dest_struct)) + return; /* Empty message type */ + + do + { + pb_release_single_field(&iter); + } while (pb_field_iter_next(&iter)); +} +#endif + +/* Field decoders */ + +bool pb_decode_svarint(pb_istream_t *stream, int64_t *dest) +{ + uint64_t value; + if (!pb_decode_varint(stream, &value)) + return false; + + if (value & 1) + *dest = (int64_t)(~(value >> 1)); + else + *dest = (int64_t)(value >> 1); + + return true; +} + +bool pb_decode_fixed32(pb_istream_t *stream, void *dest) +{ + pb_byte_t bytes[4]; + + if (!pb_read(stream, bytes, 4)) + return false; + + *(uint32_t*)dest = ((uint32_t)bytes[0] << 0) | + ((uint32_t)bytes[1] << 8) | + ((uint32_t)bytes[2] << 16) | + ((uint32_t)bytes[3] << 24); + return true; +} + +bool pb_decode_fixed64(pb_istream_t *stream, void *dest) +{ + pb_byte_t bytes[8]; + + if (!pb_read(stream, bytes, 8)) + return false; + + *(uint64_t*)dest = ((uint64_t)bytes[0] << 0) | + ((uint64_t)bytes[1] << 8) | + ((uint64_t)bytes[2] << 16) | + ((uint64_t)bytes[3] << 24) | + ((uint64_t)bytes[4] << 32) | + ((uint64_t)bytes[5] << 40) | + ((uint64_t)bytes[6] << 48) | + ((uint64_t)bytes[7] << 56); + + return true; +} + +static bool checkreturn pb_dec_varint(pb_istream_t *stream, const pb_field_t *field, void *dest) +{ + uint64_t value; + int64_t svalue; + int64_t clamped; + if (!pb_decode_varint(stream, &value)) + return false; + + /* See issue 97: Google's C++ protobuf allows negative varint values to + * be cast as int32_t, instead of the int64_t that should be used when + * encoding. Previous nanopb versions had a bug in encoding. In order to + * not break decoding of such messages, we cast <=32 bit fields to + * int32_t first to get the sign correct. + */ + if (field->data_size == sizeof(int64_t)) + svalue = (int64_t)value; + else + svalue = (int32_t)value; + + /* Cast to the proper field size, while checking for overflows */ + if (field->data_size == sizeof(int64_t)) + clamped = *(int64_t*)dest = svalue; + else if (field->data_size == sizeof(int32_t)) + clamped = *(int32_t*)dest = (int32_t)svalue; + else if (field->data_size == sizeof(int_least16_t)) + clamped = *(int_least16_t*)dest = (int_least16_t)svalue; + else if (field->data_size == sizeof(int_least8_t)) + clamped = *(int_least8_t*)dest = (int_least8_t)svalue; + else + PB_RETURN_ERROR(stream, "invalid data_size"); + + if (clamped != svalue) + PB_RETURN_ERROR(stream, "integer too large"); + + return true; +} + +static bool checkreturn pb_dec_uvarint(pb_istream_t *stream, const pb_field_t *field, void *dest) +{ + uint64_t value, clamped; + if (!pb_decode_varint(stream, &value)) + return false; + + /* Cast to the proper field size, while checking for overflows */ + if (field->data_size == sizeof(uint64_t)) + clamped = *(uint64_t*)dest = value; + else if (field->data_size == sizeof(uint32_t)) + clamped = *(uint32_t*)dest = (uint32_t)value; + else if (field->data_size == sizeof(uint_least16_t)) + clamped = *(uint_least16_t*)dest = (uint_least16_t)value; + else if (field->data_size == sizeof(uint_least8_t)) + clamped = *(uint_least8_t*)dest = (uint_least8_t)value; + else + PB_RETURN_ERROR(stream, "invalid data_size"); + + if (clamped != value) + PB_RETURN_ERROR(stream, "integer too large"); + + return true; +} + +static bool checkreturn pb_dec_svarint(pb_istream_t *stream, const pb_field_t *field, void *dest) +{ + int64_t value, clamped; + if (!pb_decode_svarint(stream, &value)) + return false; + + /* Cast to the proper field size, while checking for overflows */ + if (field->data_size == sizeof(int64_t)) + clamped = *(int64_t*)dest = value; + else if (field->data_size == sizeof(int32_t)) + clamped = *(int32_t*)dest = (int32_t)value; + else if (field->data_size == sizeof(int_least16_t)) + clamped = *(int_least16_t*)dest = (int_least16_t)value; + else if (field->data_size == sizeof(int_least8_t)) + clamped = *(int_least8_t*)dest = (int_least8_t)value; + else + PB_RETURN_ERROR(stream, "invalid data_size"); + + if (clamped != value) + PB_RETURN_ERROR(stream, "integer too large"); + + return true; +} + +static bool checkreturn pb_dec_fixed32(pb_istream_t *stream, const pb_field_t *field, void *dest) +{ + PB_UNUSED(field); + return pb_decode_fixed32(stream, dest); +} + +static bool checkreturn pb_dec_fixed64(pb_istream_t *stream, const pb_field_t *field, void *dest) +{ + PB_UNUSED(field); + return pb_decode_fixed64(stream, dest); +} + +static bool checkreturn pb_dec_bytes(pb_istream_t *stream, const pb_field_t *field, void *dest) +{ + uint32_t size; + size_t alloc_size; + pb_bytes_array_t *bdest; + + if (!pb_decode_varint32(stream, &size)) + return false; + + if (size > PB_SIZE_MAX) + PB_RETURN_ERROR(stream, "bytes overflow"); + + alloc_size = PB_BYTES_ARRAY_T_ALLOCSIZE(size); + if (size > alloc_size) + PB_RETURN_ERROR(stream, "size too large"); + + if (PB_ATYPE(field->type) == PB_ATYPE_POINTER) + { +#ifndef PB_ENABLE_MALLOC + PB_RETURN_ERROR(stream, "no malloc support"); +#else + if (!allocate_field(stream, dest, alloc_size, 1)) + return false; + bdest = *(pb_bytes_array_t**)dest; +#endif + } + else + { + if (alloc_size > field->data_size) + PB_RETURN_ERROR(stream, "bytes overflow"); + bdest = (pb_bytes_array_t*)dest; + } + + bdest->size = (pb_size_t)size; + return pb_read(stream, bdest->bytes, size); +} + +static bool checkreturn pb_dec_string(pb_istream_t *stream, const pb_field_t *field, void *dest) +{ + uint32_t size; + size_t alloc_size; + bool status; + if (!pb_decode_varint32(stream, &size)) + return false; + + /* Space for null terminator */ + alloc_size = size + 1; + + if (alloc_size < size) + PB_RETURN_ERROR(stream, "size too large"); + + if (PB_ATYPE(field->type) == PB_ATYPE_POINTER) + { +#ifndef PB_ENABLE_MALLOC + PB_RETURN_ERROR(stream, "no malloc support"); +#else + if (!allocate_field(stream, dest, alloc_size, 1)) + return false; + dest = *(void**)dest; +#endif + } + else + { + if (alloc_size > field->data_size) + PB_RETURN_ERROR(stream, "string overflow"); + } + + status = pb_read(stream, (pb_byte_t*)dest, size); + *((pb_byte_t*)dest + size) = 0; + return status; +} + +static bool checkreturn pb_dec_submessage(pb_istream_t *stream, const pb_field_t *field, void *dest) +{ + bool status; + pb_istream_t substream; + const pb_field_t* submsg_fields = (const pb_field_t*)field->ptr; + + if (!pb_make_string_substream(stream, &substream)) + return false; + + if (field->ptr == NULL) + PB_RETURN_ERROR(stream, "invalid field descriptor"); + + /* New array entries need to be initialized, while required and optional + * submessages have already been initialized in the top-level pb_decode. */ + if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED) + status = pb_decode(&substream, submsg_fields, dest); + else + status = pb_decode_noinit(&substream, submsg_fields, dest); + + if (!pb_close_string_substream(stream, &substream)) + return false; + return status; +} + +static bool checkreturn pb_dec_fixed_length_bytes(pb_istream_t *stream, const pb_field_t *field, void *dest) +{ + uint32_t size; + + if (!pb_decode_varint32(stream, &size)) + return false; + + if (size > PB_SIZE_MAX) + PB_RETURN_ERROR(stream, "bytes overflow"); + + if (size == 0) + { + /* As a special case, treat empty bytes string as all zeros for fixed_length_bytes. */ + memset(dest, 0, field->data_size); + return true; + } + + if (size != field->data_size) + PB_RETURN_ERROR(stream, "incorrect fixed length bytes size"); + + return pb_read(stream, (pb_byte_t*)dest, field->data_size); +} diff --git a/Pods/nanopb/pb_decode.h b/Pods/nanopb/pb_decode.h new file mode 100644 index 0000000..a426bdd --- /dev/null +++ b/Pods/nanopb/pb_decode.h @@ -0,0 +1,153 @@ +/* pb_decode.h: Functions to decode protocol buffers. Depends on pb_decode.c. + * The main function is pb_decode. You also need an input stream, and the + * field descriptions created by nanopb_generator.py. + */ + +#ifndef PB_DECODE_H_INCLUDED +#define PB_DECODE_H_INCLUDED + +#include "pb.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Structure for defining custom input streams. You will need to provide + * a callback function to read the bytes from your storage, which can be + * for example a file or a network socket. + * + * The callback must conform to these rules: + * + * 1) Return false on IO errors. This will cause decoding to abort. + * 2) You can use state to store your own data (e.g. buffer pointer), + * and rely on pb_read to verify that no-body reads past bytes_left. + * 3) Your callback may be used with substreams, in which case bytes_left + * is different than from the main stream. Don't use bytes_left to compute + * any pointers. + */ +struct pb_istream_s +{ +#ifdef PB_BUFFER_ONLY + /* Callback pointer is not used in buffer-only configuration. + * Having an int pointer here allows binary compatibility but + * gives an error if someone tries to assign callback function. + */ + int *callback; +#else + bool (*callback)(pb_istream_t *stream, pb_byte_t *buf, size_t count); +#endif + + void *state; /* Free field for use by callback implementation */ + size_t bytes_left; + +#ifndef PB_NO_ERRMSG + const char *errmsg; +#endif +}; + +/*************************** + * Main decoding functions * + ***************************/ + +/* Decode a single protocol buffers message from input stream into a C structure. + * Returns true on success, false on any failure. + * The actual struct pointed to by dest must match the description in fields. + * Callback fields of the destination structure must be initialized by caller. + * All other fields will be initialized by this function. + * + * Example usage: + * MyMessage msg = {}; + * uint8_t buffer[64]; + * pb_istream_t stream; + * + * // ... read some data into buffer ... + * + * stream = pb_istream_from_buffer(buffer, count); + * pb_decode(&stream, MyMessage_fields, &msg); + */ +bool pb_decode(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct); + +/* Same as pb_decode, except does not initialize the destination structure + * to default values. This is slightly faster if you need no default values + * and just do memset(struct, 0, sizeof(struct)) yourself. + * + * This can also be used for 'merging' two messages, i.e. update only the + * fields that exist in the new message. + * + * Note: If this function returns with an error, it will not release any + * dynamically allocated fields. You will need to call pb_release() yourself. + */ +bool pb_decode_noinit(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct); + +/* Same as pb_decode, except expects the stream to start with the message size + * encoded as varint. Corresponds to parseDelimitedFrom() in Google's + * protobuf API. + */ +bool pb_decode_delimited(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct); + +#ifdef PB_ENABLE_MALLOC +/* Release any allocated pointer fields. If you use dynamic allocation, you should + * call this for any successfully decoded message when you are done with it. If + * pb_decode() returns with an error, the message is already released. + */ +void pb_release(const pb_field_t fields[], void *dest_struct); +#endif + + +/************************************** + * Functions for manipulating streams * + **************************************/ + +/* Create an input stream for reading from a memory buffer. + * + * Alternatively, you can use a custom stream that reads directly from e.g. + * a file or a network socket. + */ +pb_istream_t pb_istream_from_buffer(const pb_byte_t *buf, size_t bufsize); + +/* Function to read from a pb_istream_t. You can use this if you need to + * read some custom header data, or to read data in field callbacks. + */ +bool pb_read(pb_istream_t *stream, pb_byte_t *buf, size_t count); + + +/************************************************ + * Helper functions for writing field callbacks * + ************************************************/ + +/* Decode the tag for the next field in the stream. Gives the wire type and + * field tag. At end of the message, returns false and sets eof to true. */ +bool pb_decode_tag(pb_istream_t *stream, pb_wire_type_t *wire_type, uint32_t *tag, bool *eof); + +/* Skip the field payload data, given the wire type. */ +bool pb_skip_field(pb_istream_t *stream, pb_wire_type_t wire_type); + +/* Decode an integer in the varint format. This works for bool, enum, int32, + * int64, uint32 and uint64 field types. */ +bool pb_decode_varint(pb_istream_t *stream, uint64_t *dest); + +/* Decode an integer in the varint format. This works for bool, enum, int32, + * and uint32 field types. */ +bool pb_decode_varint32(pb_istream_t *stream, uint32_t *dest); + +/* Decode an integer in the zig-zagged svarint format. This works for sint32 + * and sint64. */ +bool pb_decode_svarint(pb_istream_t *stream, int64_t *dest); + +/* Decode a fixed32, sfixed32 or float value. You need to pass a pointer to + * a 4-byte wide C variable. */ +bool pb_decode_fixed32(pb_istream_t *stream, void *dest); + +/* Decode a fixed64, sfixed64 or double value. You need to pass a pointer to + * a 8-byte wide C variable. */ +bool pb_decode_fixed64(pb_istream_t *stream, void *dest); + +/* Make a limited-length substream for reading a PB_WT_STRING field. */ +bool pb_make_string_substream(pb_istream_t *stream, pb_istream_t *substream); +bool pb_close_string_substream(pb_istream_t *stream, pb_istream_t *substream); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/Pods/nanopb/pb_encode.c b/Pods/nanopb/pb_encode.c new file mode 100644 index 0000000..30f60d8 --- /dev/null +++ b/Pods/nanopb/pb_encode.c @@ -0,0 +1,777 @@ +/* pb_encode.c -- encode a protobuf using minimal resources + * + * 2011 Petteri Aimonen + */ + +#include "pb.h" +#include "pb_encode.h" +#include "pb_common.h" + +/* Use the GCC warn_unused_result attribute to check that all return values + * are propagated correctly. On other compilers and gcc before 3.4.0 just + * ignore the annotation. + */ +#if !defined(__GNUC__) || ( __GNUC__ < 3) || (__GNUC__ == 3 && __GNUC_MINOR__ < 4) + #define checkreturn +#else + #define checkreturn __attribute__((warn_unused_result)) +#endif + +/************************************** + * Declarations internal to this file * + **************************************/ +typedef bool (*pb_encoder_t)(pb_ostream_t *stream, const pb_field_t *field, const void *src) checkreturn; + +static bool checkreturn buf_write(pb_ostream_t *stream, const pb_byte_t *buf, size_t count); +static bool checkreturn encode_array(pb_ostream_t *stream, const pb_field_t *field, const void *pData, size_t count, pb_encoder_t func); +static bool checkreturn encode_field(pb_ostream_t *stream, const pb_field_t *field, const void *pData); +static bool checkreturn default_extension_encoder(pb_ostream_t *stream, const pb_extension_t *extension); +static bool checkreturn encode_extension_field(pb_ostream_t *stream, const pb_field_t *field, const void *pData); +static void *pb_const_cast(const void *p); +static bool checkreturn pb_enc_varint(pb_ostream_t *stream, const pb_field_t *field, const void *src); +static bool checkreturn pb_enc_uvarint(pb_ostream_t *stream, const pb_field_t *field, const void *src); +static bool checkreturn pb_enc_svarint(pb_ostream_t *stream, const pb_field_t *field, const void *src); +static bool checkreturn pb_enc_fixed32(pb_ostream_t *stream, const pb_field_t *field, const void *src); +static bool checkreturn pb_enc_fixed64(pb_ostream_t *stream, const pb_field_t *field, const void *src); +static bool checkreturn pb_enc_bytes(pb_ostream_t *stream, const pb_field_t *field, const void *src); +static bool checkreturn pb_enc_string(pb_ostream_t *stream, const pb_field_t *field, const void *src); +static bool checkreturn pb_enc_submessage(pb_ostream_t *stream, const pb_field_t *field, const void *src); +static bool checkreturn pb_enc_fixed_length_bytes(pb_ostream_t *stream, const pb_field_t *field, const void *src); + +/* --- Function pointers to field encoders --- + * Order in the array must match pb_action_t LTYPE numbering. + */ +static const pb_encoder_t PB_ENCODERS[PB_LTYPES_COUNT] = { + &pb_enc_varint, + &pb_enc_uvarint, + &pb_enc_svarint, + &pb_enc_fixed32, + &pb_enc_fixed64, + + &pb_enc_bytes, + &pb_enc_string, + &pb_enc_submessage, + NULL, /* extensions */ + &pb_enc_fixed_length_bytes +}; + +/******************************* + * pb_ostream_t implementation * + *******************************/ + +static bool checkreturn buf_write(pb_ostream_t *stream, const pb_byte_t *buf, size_t count) +{ + size_t i; + pb_byte_t *dest = (pb_byte_t*)stream->state; + stream->state = dest + count; + + for (i = 0; i < count; i++) + dest[i] = buf[i]; + + return true; +} + +pb_ostream_t pb_ostream_from_buffer(pb_byte_t *buf, size_t bufsize) +{ + pb_ostream_t stream; +#ifdef PB_BUFFER_ONLY + stream.callback = (void*)1; /* Just a marker value */ +#else + stream.callback = &buf_write; +#endif + stream.state = buf; + stream.max_size = bufsize; + stream.bytes_written = 0; +#ifndef PB_NO_ERRMSG + stream.errmsg = NULL; +#endif + return stream; +} + +bool checkreturn pb_write(pb_ostream_t *stream, const pb_byte_t *buf, size_t count) +{ + if (stream->callback != NULL) + { + if (stream->bytes_written + count > stream->max_size) + PB_RETURN_ERROR(stream, "stream full"); + +#ifdef PB_BUFFER_ONLY + if (!buf_write(stream, buf, count)) + PB_RETURN_ERROR(stream, "io error"); +#else + if (!stream->callback(stream, buf, count)) + PB_RETURN_ERROR(stream, "io error"); +#endif + } + + stream->bytes_written += count; + return true; +} + +/************************* + * Encode a single field * + *************************/ + +/* Encode a static array. Handles the size calculations and possible packing. */ +static bool checkreturn encode_array(pb_ostream_t *stream, const pb_field_t *field, + const void *pData, size_t count, pb_encoder_t func) +{ + size_t i; + const void *p; + size_t size; + + if (count == 0) + return true; + + if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size) + PB_RETURN_ERROR(stream, "array max size exceeded"); + + /* We always pack arrays if the datatype allows it. */ + if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE) + { + if (!pb_encode_tag(stream, PB_WT_STRING, field->tag)) + return false; + + /* Determine the total size of packed array. */ + if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32) + { + size = 4 * count; + } + else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64) + { + size = 8 * count; + } + else + { + pb_ostream_t sizestream = PB_OSTREAM_SIZING; + p = pData; + for (i = 0; i < count; i++) + { + if (!func(&sizestream, field, p)) + return false; + p = (const char*)p + field->data_size; + } + size = sizestream.bytes_written; + } + + if (!pb_encode_varint(stream, (uint64_t)size)) + return false; + + if (stream->callback == NULL) + return pb_write(stream, NULL, size); /* Just sizing.. */ + + /* Write the data */ + p = pData; + for (i = 0; i < count; i++) + { + if (!func(stream, field, p)) + return false; + p = (const char*)p + field->data_size; + } + } + else + { + p = pData; + for (i = 0; i < count; i++) + { + if (!pb_encode_tag_for_field(stream, field)) + return false; + + /* Normally the data is stored directly in the array entries, but + * for pointer-type string and bytes fields, the array entries are + * actually pointers themselves also. So we have to dereference once + * more to get to the actual data. */ + if (PB_ATYPE(field->type) == PB_ATYPE_POINTER && + (PB_LTYPE(field->type) == PB_LTYPE_STRING || + PB_LTYPE(field->type) == PB_LTYPE_BYTES)) + { + if (!func(stream, field, *(const void* const*)p)) + return false; + } + else + { + if (!func(stream, field, p)) + return false; + } + p = (const char*)p + field->data_size; + } + } + + return true; +} + +/* In proto3, all fields are optional and are only encoded if their value is "non-zero". + * This function implements the check for the zero value. */ +static bool pb_check_proto3_default_value(const pb_field_t *field, const void *pData) +{ + if (PB_ATYPE(field->type) == PB_ATYPE_STATIC) + { + if (PB_LTYPE(field->type) == PB_LTYPE_BYTES) + { + const pb_bytes_array_t *bytes = (const pb_bytes_array_t*)pData; + return bytes->size == 0; + } + else if (PB_LTYPE(field->type) == PB_LTYPE_STRING) + { + return *(const char*)pData == '\0'; + } + else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED_LENGTH_BYTES) + { + /* Fixed length bytes is only empty if its length is fixed + * as 0. Which would be pretty strange, but we can check + * it anyway. */ + return field->data_size == 0; + } + else if (PB_LTYPE(field->type) == PB_LTYPE_SUBMESSAGE) + { + /* Check all fields in the submessage to find if any of them + * are non-zero. The comparison cannot be done byte-per-byte + * because the C struct may contain padding bytes that must + * be skipped. + */ + pb_field_iter_t iter; + if (pb_field_iter_begin(&iter, (const pb_field_t*)field->ptr, pb_const_cast(pData))) + { + do + { + if (!pb_check_proto3_default_value(iter.pos, iter.pData)) + { + return false; + } + } while (pb_field_iter_next(&iter)); + } + return true; + } + } + + { + /* Catch-all branch that does byte-per-byte comparison for zero value. + * + * This is for all pointer fields, and for static PB_LTYPE_VARINT, + * UVARINT, SVARINT, FIXED32, FIXED64, EXTENSION fields, and also + * callback fields. These all have integer or pointer value which + * can be compared with 0. + */ + pb_size_t i; + const char *p = (const char*)pData; + for (i = 0; i < field->data_size; i++) + { + if (p[i] != 0) + { + return false; + } + } + + return true; + } +} + +/* Encode a field with static or pointer allocation, i.e. one whose data + * is available to the encoder directly. */ +static bool checkreturn encode_basic_field(pb_ostream_t *stream, + const pb_field_t *field, const void *pData) +{ + pb_encoder_t func; + bool implicit_has; + const void *pSize = &implicit_has; + + func = PB_ENCODERS[PB_LTYPE(field->type)]; + + if (field->size_offset) + { + /* Static optional, repeated or oneof field */ + pSize = (const char*)pData + field->size_offset; + } + else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL) + { + /* Proto3 style field, optional but without explicit has_ field. */ + implicit_has = !pb_check_proto3_default_value(field, pData); + } + else + { + /* Required field, always present */ + implicit_has = true; + } + + if (PB_ATYPE(field->type) == PB_ATYPE_POINTER) + { + /* pData is a pointer to the field, which contains pointer to + * the data. If the 2nd pointer is NULL, it is interpreted as if + * the has_field was false. + */ + pData = *(const void* const*)pData; + implicit_has = (pData != NULL); + } + + switch (PB_HTYPE(field->type)) + { + case PB_HTYPE_REQUIRED: + if (!pData) + PB_RETURN_ERROR(stream, "missing required field"); + if (!pb_encode_tag_for_field(stream, field)) + return false; + if (!func(stream, field, pData)) + return false; + break; + + case PB_HTYPE_OPTIONAL: + if (*(const bool*)pSize) + { + if (!pb_encode_tag_for_field(stream, field)) + return false; + + if (!func(stream, field, pData)) + return false; + } + break; + + case PB_HTYPE_REPEATED: + if (!encode_array(stream, field, pData, *(const pb_size_t*)pSize, func)) + return false; + break; + + case PB_HTYPE_ONEOF: + if (*(const pb_size_t*)pSize == field->tag) + { + if (!pb_encode_tag_for_field(stream, field)) + return false; + + if (!func(stream, field, pData)) + return false; + } + break; + + default: + PB_RETURN_ERROR(stream, "invalid field type"); + } + + return true; +} + +/* Encode a field with callback semantics. This means that a user function is + * called to provide and encode the actual data. */ +static bool checkreturn encode_callback_field(pb_ostream_t *stream, + const pb_field_t *field, const void *pData) +{ + const pb_callback_t *callback = (const pb_callback_t*)pData; + +#ifdef PB_OLD_CALLBACK_STYLE + const void *arg = callback->arg; +#else + void * const *arg = &(callback->arg); +#endif + + if (callback->funcs.encode != NULL) + { + if (!callback->funcs.encode(stream, field, arg)) + PB_RETURN_ERROR(stream, "callback error"); + } + return true; +} + +/* Encode a single field of any callback or static type. */ +static bool checkreturn encode_field(pb_ostream_t *stream, + const pb_field_t *field, const void *pData) +{ + switch (PB_ATYPE(field->type)) + { + case PB_ATYPE_STATIC: + case PB_ATYPE_POINTER: + return encode_basic_field(stream, field, pData); + + case PB_ATYPE_CALLBACK: + return encode_callback_field(stream, field, pData); + + default: + PB_RETURN_ERROR(stream, "invalid field type"); + } +} + +/* Default handler for extension fields. Expects to have a pb_field_t + * pointer in the extension->type->arg field. */ +static bool checkreturn default_extension_encoder(pb_ostream_t *stream, + const pb_extension_t *extension) +{ + const pb_field_t *field = (const pb_field_t*)extension->type->arg; + + if (PB_ATYPE(field->type) == PB_ATYPE_POINTER) + { + /* For pointer extensions, the pointer is stored directly + * in the extension structure. This avoids having an extra + * indirection. */ + return encode_field(stream, field, &extension->dest); + } + else + { + return encode_field(stream, field, extension->dest); + } +} + +/* Walk through all the registered extensions and give them a chance + * to encode themselves. */ +static bool checkreturn encode_extension_field(pb_ostream_t *stream, + const pb_field_t *field, const void *pData) +{ + const pb_extension_t *extension = *(const pb_extension_t* const *)pData; + PB_UNUSED(field); + + while (extension) + { + bool status; + if (extension->type->encode) + status = extension->type->encode(stream, extension); + else + status = default_extension_encoder(stream, extension); + + if (!status) + return false; + + extension = extension->next; + } + + return true; +} + +/********************* + * Encode all fields * + *********************/ + +static void *pb_const_cast(const void *p) +{ + /* Note: this casts away const, in order to use the common field iterator + * logic for both encoding and decoding. */ + union { + void *p1; + const void *p2; + } t; + t.p2 = p; + return t.p1; +} + +bool checkreturn pb_encode(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct) +{ + pb_field_iter_t iter; + if (!pb_field_iter_begin(&iter, fields, pb_const_cast(src_struct))) + return true; /* Empty message type */ + + do { + if (PB_LTYPE(iter.pos->type) == PB_LTYPE_EXTENSION) + { + /* Special case for the extension field placeholder */ + if (!encode_extension_field(stream, iter.pos, iter.pData)) + return false; + } + else + { + /* Regular field */ + if (!encode_field(stream, iter.pos, iter.pData)) + return false; + } + } while (pb_field_iter_next(&iter)); + + return true; +} + +bool pb_encode_delimited(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct) +{ + return pb_encode_submessage(stream, fields, src_struct); +} + +bool pb_get_encoded_size(size_t *size, const pb_field_t fields[], const void *src_struct) +{ + pb_ostream_t stream = PB_OSTREAM_SIZING; + + if (!pb_encode(&stream, fields, src_struct)) + return false; + + *size = stream.bytes_written; + return true; +} + +/******************** + * Helper functions * + ********************/ +bool checkreturn pb_encode_varint(pb_ostream_t *stream, uint64_t value) +{ + pb_byte_t buffer[10]; + size_t i = 0; + + if (value <= 0x7F) + { + pb_byte_t v = (pb_byte_t)value; + return pb_write(stream, &v, 1); + } + + while (value) + { + buffer[i] = (pb_byte_t)((value & 0x7F) | 0x80); + value >>= 7; + i++; + } + buffer[i-1] &= 0x7F; /* Unset top bit on last byte */ + + return pb_write(stream, buffer, i); +} + +bool checkreturn pb_encode_svarint(pb_ostream_t *stream, int64_t value) +{ + uint64_t zigzagged; + if (value < 0) + zigzagged = ~((uint64_t)value << 1); + else + zigzagged = (uint64_t)value << 1; + + return pb_encode_varint(stream, zigzagged); +} + +bool checkreturn pb_encode_fixed32(pb_ostream_t *stream, const void *value) +{ + uint32_t val = *(const uint32_t*)value; + pb_byte_t bytes[4]; + bytes[0] = (pb_byte_t)(val & 0xFF); + bytes[1] = (pb_byte_t)((val >> 8) & 0xFF); + bytes[2] = (pb_byte_t)((val >> 16) & 0xFF); + bytes[3] = (pb_byte_t)((val >> 24) & 0xFF); + return pb_write(stream, bytes, 4); +} + +bool checkreturn pb_encode_fixed64(pb_ostream_t *stream, const void *value) +{ + uint64_t val = *(const uint64_t*)value; + pb_byte_t bytes[8]; + bytes[0] = (pb_byte_t)(val & 0xFF); + bytes[1] = (pb_byte_t)((val >> 8) & 0xFF); + bytes[2] = (pb_byte_t)((val >> 16) & 0xFF); + bytes[3] = (pb_byte_t)((val >> 24) & 0xFF); + bytes[4] = (pb_byte_t)((val >> 32) & 0xFF); + bytes[5] = (pb_byte_t)((val >> 40) & 0xFF); + bytes[6] = (pb_byte_t)((val >> 48) & 0xFF); + bytes[7] = (pb_byte_t)((val >> 56) & 0xFF); + return pb_write(stream, bytes, 8); +} + +bool checkreturn pb_encode_tag(pb_ostream_t *stream, pb_wire_type_t wiretype, uint32_t field_number) +{ + uint64_t tag = ((uint64_t)field_number << 3) | wiretype; + return pb_encode_varint(stream, tag); +} + +bool checkreturn pb_encode_tag_for_field(pb_ostream_t *stream, const pb_field_t *field) +{ + pb_wire_type_t wiretype; + switch (PB_LTYPE(field->type)) + { + case PB_LTYPE_VARINT: + case PB_LTYPE_UVARINT: + case PB_LTYPE_SVARINT: + wiretype = PB_WT_VARINT; + break; + + case PB_LTYPE_FIXED32: + wiretype = PB_WT_32BIT; + break; + + case PB_LTYPE_FIXED64: + wiretype = PB_WT_64BIT; + break; + + case PB_LTYPE_BYTES: + case PB_LTYPE_STRING: + case PB_LTYPE_SUBMESSAGE: + case PB_LTYPE_FIXED_LENGTH_BYTES: + wiretype = PB_WT_STRING; + break; + + default: + PB_RETURN_ERROR(stream, "invalid field type"); + } + + return pb_encode_tag(stream, wiretype, field->tag); +} + +bool checkreturn pb_encode_string(pb_ostream_t *stream, const pb_byte_t *buffer, size_t size) +{ + if (!pb_encode_varint(stream, (uint64_t)size)) + return false; + + return pb_write(stream, buffer, size); +} + +bool checkreturn pb_encode_submessage(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct) +{ + /* First calculate the message size using a non-writing substream. */ + pb_ostream_t substream = PB_OSTREAM_SIZING; + size_t size; + bool status; + + if (!pb_encode(&substream, fields, src_struct)) + { +#ifndef PB_NO_ERRMSG + stream->errmsg = substream.errmsg; +#endif + return false; + } + + size = substream.bytes_written; + + if (!pb_encode_varint(stream, (uint64_t)size)) + return false; + + if (stream->callback == NULL) + return pb_write(stream, NULL, size); /* Just sizing */ + + if (stream->bytes_written + size > stream->max_size) + PB_RETURN_ERROR(stream, "stream full"); + + /* Use a substream to verify that a callback doesn't write more than + * what it did the first time. */ + substream.callback = stream->callback; + substream.state = stream->state; + substream.max_size = size; + substream.bytes_written = 0; +#ifndef PB_NO_ERRMSG + substream.errmsg = NULL; +#endif + + status = pb_encode(&substream, fields, src_struct); + + stream->bytes_written += substream.bytes_written; + stream->state = substream.state; +#ifndef PB_NO_ERRMSG + stream->errmsg = substream.errmsg; +#endif + + if (substream.bytes_written != size) + PB_RETURN_ERROR(stream, "submsg size changed"); + + return status; +} + +/* Field encoders */ + +static bool checkreturn pb_enc_varint(pb_ostream_t *stream, const pb_field_t *field, const void *src) +{ + int64_t value = 0; + + if (field->data_size == sizeof(int_least8_t)) + value = *(const int_least8_t*)src; + else if (field->data_size == sizeof(int_least16_t)) + value = *(const int_least16_t*)src; + else if (field->data_size == sizeof(int32_t)) + value = *(const int32_t*)src; + else if (field->data_size == sizeof(int64_t)) + value = *(const int64_t*)src; + else + PB_RETURN_ERROR(stream, "invalid data_size"); + + return pb_encode_varint(stream, (uint64_t)value); +} + +static bool checkreturn pb_enc_uvarint(pb_ostream_t *stream, const pb_field_t *field, const void *src) +{ + uint64_t value = 0; + + if (field->data_size == sizeof(uint_least8_t)) + value = *(const uint_least8_t*)src; + else if (field->data_size == sizeof(uint_least16_t)) + value = *(const uint_least16_t*)src; + else if (field->data_size == sizeof(uint32_t)) + value = *(const uint32_t*)src; + else if (field->data_size == sizeof(uint64_t)) + value = *(const uint64_t*)src; + else + PB_RETURN_ERROR(stream, "invalid data_size"); + + return pb_encode_varint(stream, value); +} + +static bool checkreturn pb_enc_svarint(pb_ostream_t *stream, const pb_field_t *field, const void *src) +{ + int64_t value = 0; + + if (field->data_size == sizeof(int_least8_t)) + value = *(const int_least8_t*)src; + else if (field->data_size == sizeof(int_least16_t)) + value = *(const int_least16_t*)src; + else if (field->data_size == sizeof(int32_t)) + value = *(const int32_t*)src; + else if (field->data_size == sizeof(int64_t)) + value = *(const int64_t*)src; + else + PB_RETURN_ERROR(stream, "invalid data_size"); + + return pb_encode_svarint(stream, value); +} + +static bool checkreturn pb_enc_fixed64(pb_ostream_t *stream, const pb_field_t *field, const void *src) +{ + PB_UNUSED(field); + return pb_encode_fixed64(stream, src); +} + +static bool checkreturn pb_enc_fixed32(pb_ostream_t *stream, const pb_field_t *field, const void *src) +{ + PB_UNUSED(field); + return pb_encode_fixed32(stream, src); +} + +static bool checkreturn pb_enc_bytes(pb_ostream_t *stream, const pb_field_t *field, const void *src) +{ + const pb_bytes_array_t *bytes = NULL; + + bytes = (const pb_bytes_array_t*)src; + + if (src == NULL) + { + /* Treat null pointer as an empty bytes field */ + return pb_encode_string(stream, NULL, 0); + } + + if (PB_ATYPE(field->type) == PB_ATYPE_STATIC && + PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) > field->data_size) + { + PB_RETURN_ERROR(stream, "bytes size exceeded"); + } + + return pb_encode_string(stream, bytes->bytes, bytes->size); +} + +static bool checkreturn pb_enc_string(pb_ostream_t *stream, const pb_field_t *field, const void *src) +{ + size_t size = 0; + size_t max_size = field->data_size; + const char *p = (const char*)src; + + if (PB_ATYPE(field->type) == PB_ATYPE_POINTER) + max_size = (size_t)-1; + + if (src == NULL) + { + size = 0; /* Treat null pointer as an empty string */ + } + else + { + /* strnlen() is not always available, so just use a loop */ + while (size < max_size && *p != '\0') + { + size++; + p++; + } + } + + return pb_encode_string(stream, (const pb_byte_t*)src, size); +} + +static bool checkreturn pb_enc_submessage(pb_ostream_t *stream, const pb_field_t *field, const void *src) +{ + if (field->ptr == NULL) + PB_RETURN_ERROR(stream, "invalid field descriptor"); + + return pb_encode_submessage(stream, (const pb_field_t*)field->ptr, src); +} + +static bool checkreturn pb_enc_fixed_length_bytes(pb_ostream_t *stream, const pb_field_t *field, const void *src) +{ + return pb_encode_string(stream, (const pb_byte_t*)src, field->data_size); +} + diff --git a/Pods/nanopb/pb_encode.h b/Pods/nanopb/pb_encode.h new file mode 100644 index 0000000..d9909fb --- /dev/null +++ b/Pods/nanopb/pb_encode.h @@ -0,0 +1,154 @@ +/* pb_encode.h: Functions to encode protocol buffers. Depends on pb_encode.c. + * The main function is pb_encode. You also need an output stream, and the + * field descriptions created by nanopb_generator.py. + */ + +#ifndef PB_ENCODE_H_INCLUDED +#define PB_ENCODE_H_INCLUDED + +#include "pb.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Structure for defining custom output streams. You will need to provide + * a callback function to write the bytes to your storage, which can be + * for example a file or a network socket. + * + * The callback must conform to these rules: + * + * 1) Return false on IO errors. This will cause encoding to abort. + * 2) You can use state to store your own data (e.g. buffer pointer). + * 3) pb_write will update bytes_written after your callback runs. + * 4) Substreams will modify max_size and bytes_written. Don't use them + * to calculate any pointers. + */ +struct pb_ostream_s +{ +#ifdef PB_BUFFER_ONLY + /* Callback pointer is not used in buffer-only configuration. + * Having an int pointer here allows binary compatibility but + * gives an error if someone tries to assign callback function. + * Also, NULL pointer marks a 'sizing stream' that does not + * write anything. + */ + int *callback; +#else + bool (*callback)(pb_ostream_t *stream, const pb_byte_t *buf, size_t count); +#endif + void *state; /* Free field for use by callback implementation. */ + size_t max_size; /* Limit number of output bytes written (or use SIZE_MAX). */ + size_t bytes_written; /* Number of bytes written so far. */ + +#ifndef PB_NO_ERRMSG + const char *errmsg; +#endif +}; + +/*************************** + * Main encoding functions * + ***************************/ + +/* Encode a single protocol buffers message from C structure into a stream. + * Returns true on success, false on any failure. + * The actual struct pointed to by src_struct must match the description in fields. + * All required fields in the struct are assumed to have been filled in. + * + * Example usage: + * MyMessage msg = {}; + * uint8_t buffer[64]; + * pb_ostream_t stream; + * + * msg.field1 = 42; + * stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); + * pb_encode(&stream, MyMessage_fields, &msg); + */ +bool pb_encode(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct); + +/* Same as pb_encode, but prepends the length of the message as a varint. + * Corresponds to writeDelimitedTo() in Google's protobuf API. + */ +bool pb_encode_delimited(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct); + +/* Encode the message to get the size of the encoded data, but do not store + * the data. */ +bool pb_get_encoded_size(size_t *size, const pb_field_t fields[], const void *src_struct); + +/************************************** + * Functions for manipulating streams * + **************************************/ + +/* Create an output stream for writing into a memory buffer. + * The number of bytes written can be found in stream.bytes_written after + * encoding the message. + * + * Alternatively, you can use a custom stream that writes directly to e.g. + * a file or a network socket. + */ +pb_ostream_t pb_ostream_from_buffer(pb_byte_t *buf, size_t bufsize); + +/* Pseudo-stream for measuring the size of a message without actually storing + * the encoded data. + * + * Example usage: + * MyMessage msg = {}; + * pb_ostream_t stream = PB_OSTREAM_SIZING; + * pb_encode(&stream, MyMessage_fields, &msg); + * printf("Message size is %d\n", stream.bytes_written); + */ +#ifndef PB_NO_ERRMSG +#define PB_OSTREAM_SIZING {0,0,0,0,0} +#else +#define PB_OSTREAM_SIZING {0,0,0,0} +#endif + +/* Function to write into a pb_ostream_t stream. You can use this if you need + * to append or prepend some custom headers to the message. + */ +bool pb_write(pb_ostream_t *stream, const pb_byte_t *buf, size_t count); + + +/************************************************ + * Helper functions for writing field callbacks * + ************************************************/ + +/* Encode field header based on type and field number defined in the field + * structure. Call this from the callback before writing out field contents. */ +bool pb_encode_tag_for_field(pb_ostream_t *stream, const pb_field_t *field); + +/* Encode field header by manually specifing wire type. You need to use this + * if you want to write out packed arrays from a callback field. */ +bool pb_encode_tag(pb_ostream_t *stream, pb_wire_type_t wiretype, uint32_t field_number); + +/* Encode an integer in the varint format. + * This works for bool, enum, int32, int64, uint32 and uint64 field types. */ +bool pb_encode_varint(pb_ostream_t *stream, uint64_t value); + +/* Encode an integer in the zig-zagged svarint format. + * This works for sint32 and sint64. */ +bool pb_encode_svarint(pb_ostream_t *stream, int64_t value); + +/* Encode a string or bytes type field. For strings, pass strlen(s) as size. */ +bool pb_encode_string(pb_ostream_t *stream, const pb_byte_t *buffer, size_t size); + +/* Encode a fixed32, sfixed32 or float value. + * You need to pass a pointer to a 4-byte wide C variable. */ +bool pb_encode_fixed32(pb_ostream_t *stream, const void *value); + +/* Encode a fixed64, sfixed64 or double value. + * You need to pass a pointer to a 8-byte wide C variable. */ +bool pb_encode_fixed64(pb_ostream_t *stream, const void *value); + +/* Encode a submessage field. + * You need to pass the pb_field_t array and pointer to struct, just like + * with pb_encode(). This internally encodes the submessage twice, first to + * calculate message size and then to actually write it out. + */ +bool pb_encode_submessage(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/Settings.bundle/Root.plist b/Settings.bundle/Root.plist new file mode 100644 index 0000000..faa0a94 --- /dev/null +++ b/Settings.bundle/Root.plist @@ -0,0 +1,37 @@ + + + + + StringsTable + Root + PreferenceSpecifiers + + + Type + PSGroupSpecifier + Title + Über blista-App + + + Type + PSTitleValueSpecifier + Title + Version + Key + version_preference + DefaultValue + 1.0 + + + Type + PSTitleValueSpecifier + Title + Build + Key + build_preference + DefaultValue + 1 + + + + diff --git a/Settings.bundle/en.lproj/Root.strings b/Settings.bundle/en.lproj/Root.strings new file mode 100644 index 0000000..8cd87b9 Binary files /dev/null and b/Settings.bundle/en.lproj/Root.strings differ diff --git a/assets/css/font-awesome.min.css b/assets/css/font-awesome.min.css new file mode 100644 index 0000000..9b27f8e --- /dev/null +++ b/assets/css/font-awesome.min.css @@ -0,0 +1,4 @@ +/*! + * Font Awesome 4.6.3 by @davegandy - http://fontawesome.io - @fontawesome + * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) + */@font-face{font-family:'FontAwesome';src:url('../fonts/fontawesome-webfont.eot?v=4.6.3');src:url('../fonts/fontawesome-webfont.eot?#iefix&v=4.6.3') format('embedded-opentype'),url('../fonts/fontawesome-webfont.woff2?v=4.6.3') format('woff2'),url('../fonts/fontawesome-webfont.woff?v=4.6.3') format('woff'),url('../fonts/fontawesome-webfont.ttf?v=4.6.3') format('truetype'),url('../fonts/fontawesome-webfont.svg?v=4.6.3#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-lg{font-size:1.33333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.28571429em;text-align:center}.fa-ul{padding-left:0;margin-left:2.14285714em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.14285714em;width:2.14285714em;top:.14285714em;text-align:center}.fa-li.fa-lg{left:-1.85714286em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.fa-pull-left{float:left}.fa-pull-right{float:right}.fa.fa-pull-left{margin-right:.3em}.fa.fa-pull-right{margin-left:.3em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=1)";-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2)";-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)";-webkit-transform:scale(-1, 1);-ms-transform:scale(-1, 1);transform:scale(-1, 1)}.fa-flip-vertical{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";-webkit-transform:scale(1, -1);-ms-transform:scale(1, -1);transform:scale(1, -1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-remove:before,.fa-close:before,.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook-f:before,.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-feed:before,.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-desc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-asc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before,.fa-gratipay:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"}.fa-space-shuttle:before{content:"\f197"}.fa-slack:before{content:"\f198"}.fa-envelope-square:before{content:"\f199"}.fa-wordpress:before{content:"\f19a"}.fa-openid:before{content:"\f19b"}.fa-institution:before,.fa-bank:before,.fa-university:before{content:"\f19c"}.fa-mortar-board:before,.fa-graduation-cap:before{content:"\f19d"}.fa-yahoo:before{content:"\f19e"}.fa-google:before{content:"\f1a0"}.fa-reddit:before{content:"\f1a1"}.fa-reddit-square:before{content:"\f1a2"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-stumbleupon:before{content:"\f1a4"}.fa-delicious:before{content:"\f1a5"}.fa-digg:before{content:"\f1a6"}.fa-pied-piper-pp:before{content:"\f1a7"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-drupal:before{content:"\f1a9"}.fa-joomla:before{content:"\f1aa"}.fa-language:before{content:"\f1ab"}.fa-fax:before{content:"\f1ac"}.fa-building:before{content:"\f1ad"}.fa-child:before{content:"\f1ae"}.fa-paw:before{content:"\f1b0"}.fa-spoon:before{content:"\f1b1"}.fa-cube:before{content:"\f1b2"}.fa-cubes:before{content:"\f1b3"}.fa-behance:before{content:"\f1b4"}.fa-behance-square:before{content:"\f1b5"}.fa-steam:before{content:"\f1b6"}.fa-steam-square:before{content:"\f1b7"}.fa-recycle:before{content:"\f1b8"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-tree:before{content:"\f1bb"}.fa-spotify:before{content:"\f1bc"}.fa-deviantart:before{content:"\f1bd"}.fa-soundcloud:before{content:"\f1be"}.fa-database:before{content:"\f1c0"}.fa-file-pdf-o:before{content:"\f1c1"}.fa-file-word-o:before{content:"\f1c2"}.fa-file-excel-o:before{content:"\f1c3"}.fa-file-powerpoint-o:before{content:"\f1c4"}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:"\f1c5"}.fa-file-zip-o:before,.fa-file-archive-o:before{content:"\f1c6"}.fa-file-sound-o:before,.fa-file-audio-o:before{content:"\f1c7"}.fa-file-movie-o:before,.fa-file-video-o:before{content:"\f1c8"}.fa-file-code-o:before{content:"\f1c9"}.fa-vine:before{content:"\f1ca"}.fa-codepen:before{content:"\f1cb"}.fa-jsfiddle:before{content:"\f1cc"}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"\f1cd"}.fa-circle-o-notch:before{content:"\f1ce"}.fa-ra:before,.fa-resistance:before,.fa-rebel:before{content:"\f1d0"}.fa-ge:before,.fa-empire:before{content:"\f1d1"}.fa-git-square:before{content:"\f1d2"}.fa-git:before{content:"\f1d3"}.fa-y-combinator-square:before,.fa-yc-square:before,.fa-hacker-news:before{content:"\f1d4"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-qq:before{content:"\f1d6"}.fa-wechat:before,.fa-weixin:before{content:"\f1d7"}.fa-send:before,.fa-paper-plane:before{content:"\f1d8"}.fa-send-o:before,.fa-paper-plane-o:before{content:"\f1d9"}.fa-history:before{content:"\f1da"}.fa-circle-thin:before{content:"\f1db"}.fa-header:before{content:"\f1dc"}.fa-paragraph:before{content:"\f1dd"}.fa-sliders:before{content:"\f1de"}.fa-share-alt:before{content:"\f1e0"}.fa-share-alt-square:before{content:"\f1e1"}.fa-bomb:before{content:"\f1e2"}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:"\f1e3"}.fa-tty:before{content:"\f1e4"}.fa-binoculars:before{content:"\f1e5"}.fa-plug:before{content:"\f1e6"}.fa-slideshare:before{content:"\f1e7"}.fa-twitch:before{content:"\f1e8"}.fa-yelp:before{content:"\f1e9"}.fa-newspaper-o:before{content:"\f1ea"}.fa-wifi:before{content:"\f1eb"}.fa-calculator:before{content:"\f1ec"}.fa-paypal:before{content:"\f1ed"}.fa-google-wallet:before{content:"\f1ee"}.fa-cc-visa:before{content:"\f1f0"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-cc-discover:before{content:"\f1f2"}.fa-cc-amex:before{content:"\f1f3"}.fa-cc-paypal:before{content:"\f1f4"}.fa-cc-stripe:before{content:"\f1f5"}.fa-bell-slash:before{content:"\f1f6"}.fa-bell-slash-o:before{content:"\f1f7"}.fa-trash:before{content:"\f1f8"}.fa-copyright:before{content:"\f1f9"}.fa-at:before{content:"\f1fa"}.fa-eyedropper:before{content:"\f1fb"}.fa-paint-brush:before{content:"\f1fc"}.fa-birthday-cake:before{content:"\f1fd"}.fa-area-chart:before{content:"\f1fe"}.fa-pie-chart:before{content:"\f200"}.fa-line-chart:before{content:"\f201"}.fa-lastfm:before{content:"\f202"}.fa-lastfm-square:before{content:"\f203"}.fa-toggle-off:before{content:"\f204"}.fa-toggle-on:before{content:"\f205"}.fa-bicycle:before{content:"\f206"}.fa-bus:before{content:"\f207"}.fa-ioxhost:before{content:"\f208"}.fa-angellist:before{content:"\f209"}.fa-cc:before{content:"\f20a"}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:"\f20b"}.fa-meanpath:before{content:"\f20c"}.fa-buysellads:before{content:"\f20d"}.fa-connectdevelop:before{content:"\f20e"}.fa-dashcube:before{content:"\f210"}.fa-forumbee:before{content:"\f211"}.fa-leanpub:before{content:"\f212"}.fa-sellsy:before{content:"\f213"}.fa-shirtsinbulk:before{content:"\f214"}.fa-simplybuilt:before{content:"\f215"}.fa-skyatlas:before{content:"\f216"}.fa-cart-plus:before{content:"\f217"}.fa-cart-arrow-down:before{content:"\f218"}.fa-diamond:before{content:"\f219"}.fa-ship:before{content:"\f21a"}.fa-user-secret:before{content:"\f21b"}.fa-motorcycle:before{content:"\f21c"}.fa-street-view:before{content:"\f21d"}.fa-heartbeat:before{content:"\f21e"}.fa-venus:before{content:"\f221"}.fa-mars:before{content:"\f222"}.fa-mercury:before{content:"\f223"}.fa-intersex:before,.fa-transgender:before{content:"\f224"}.fa-transgender-alt:before{content:"\f225"}.fa-venus-double:before{content:"\f226"}.fa-mars-double:before{content:"\f227"}.fa-venus-mars:before{content:"\f228"}.fa-mars-stroke:before{content:"\f229"}.fa-mars-stroke-v:before{content:"\f22a"}.fa-mars-stroke-h:before{content:"\f22b"}.fa-neuter:before{content:"\f22c"}.fa-genderless:before{content:"\f22d"}.fa-facebook-official:before{content:"\f230"}.fa-pinterest-p:before{content:"\f231"}.fa-whatsapp:before{content:"\f232"}.fa-server:before{content:"\f233"}.fa-user-plus:before{content:"\f234"}.fa-user-times:before{content:"\f235"}.fa-hotel:before,.fa-bed:before{content:"\f236"}.fa-viacoin:before{content:"\f237"}.fa-train:before{content:"\f238"}.fa-subway:before{content:"\f239"}.fa-medium:before{content:"\f23a"}.fa-yc:before,.fa-y-combinator:before{content:"\f23b"}.fa-optin-monster:before{content:"\f23c"}.fa-opencart:before{content:"\f23d"}.fa-expeditedssl:before{content:"\f23e"}.fa-battery-4:before,.fa-battery-full:before{content:"\f240"}.fa-battery-3:before,.fa-battery-three-quarters:before{content:"\f241"}.fa-battery-2:before,.fa-battery-half:before{content:"\f242"}.fa-battery-1:before,.fa-battery-quarter:before{content:"\f243"}.fa-battery-0:before,.fa-battery-empty:before{content:"\f244"}.fa-mouse-pointer:before{content:"\f245"}.fa-i-cursor:before{content:"\f246"}.fa-object-group:before{content:"\f247"}.fa-object-ungroup:before{content:"\f248"}.fa-sticky-note:before{content:"\f249"}.fa-sticky-note-o:before{content:"\f24a"}.fa-cc-jcb:before{content:"\f24b"}.fa-cc-diners-club:before{content:"\f24c"}.fa-clone:before{content:"\f24d"}.fa-balance-scale:before{content:"\f24e"}.fa-hourglass-o:before{content:"\f250"}.fa-hourglass-1:before,.fa-hourglass-start:before{content:"\f251"}.fa-hourglass-2:before,.fa-hourglass-half:before{content:"\f252"}.fa-hourglass-3:before,.fa-hourglass-end:before{content:"\f253"}.fa-hourglass:before{content:"\f254"}.fa-hand-grab-o:before,.fa-hand-rock-o:before{content:"\f255"}.fa-hand-stop-o:before,.fa-hand-paper-o:before{content:"\f256"}.fa-hand-scissors-o:before{content:"\f257"}.fa-hand-lizard-o:before{content:"\f258"}.fa-hand-spock-o:before{content:"\f259"}.fa-hand-pointer-o:before{content:"\f25a"}.fa-hand-peace-o:before{content:"\f25b"}.fa-trademark:before{content:"\f25c"}.fa-registered:before{content:"\f25d"}.fa-creative-commons:before{content:"\f25e"}.fa-gg:before{content:"\f260"}.fa-gg-circle:before{content:"\f261"}.fa-tripadvisor:before{content:"\f262"}.fa-odnoklassniki:before{content:"\f263"}.fa-odnoklassniki-square:before{content:"\f264"}.fa-get-pocket:before{content:"\f265"}.fa-wikipedia-w:before{content:"\f266"}.fa-safari:before{content:"\f267"}.fa-chrome:before{content:"\f268"}.fa-firefox:before{content:"\f269"}.fa-opera:before{content:"\f26a"}.fa-internet-explorer:before{content:"\f26b"}.fa-tv:before,.fa-television:before{content:"\f26c"}.fa-contao:before{content:"\f26d"}.fa-500px:before{content:"\f26e"}.fa-amazon:before{content:"\f270"}.fa-calendar-plus-o:before{content:"\f271"}.fa-calendar-minus-o:before{content:"\f272"}.fa-calendar-times-o:before{content:"\f273"}.fa-calendar-check-o:before{content:"\f274"}.fa-industry:before{content:"\f275"}.fa-map-pin:before{content:"\f276"}.fa-map-signs:before{content:"\f277"}.fa-map-o:before{content:"\f278"}.fa-map:before{content:"\f279"}.fa-commenting:before{content:"\f27a"}.fa-commenting-o:before{content:"\f27b"}.fa-houzz:before{content:"\f27c"}.fa-vimeo:before{content:"\f27d"}.fa-black-tie:before{content:"\f27e"}.fa-fonticons:before{content:"\f280"}.fa-reddit-alien:before{content:"\f281"}.fa-edge:before{content:"\f282"}.fa-credit-card-alt:before{content:"\f283"}.fa-codiepie:before{content:"\f284"}.fa-modx:before{content:"\f285"}.fa-fort-awesome:before{content:"\f286"}.fa-usb:before{content:"\f287"}.fa-product-hunt:before{content:"\f288"}.fa-mixcloud:before{content:"\f289"}.fa-scribd:before{content:"\f28a"}.fa-pause-circle:before{content:"\f28b"}.fa-pause-circle-o:before{content:"\f28c"}.fa-stop-circle:before{content:"\f28d"}.fa-stop-circle-o:before{content:"\f28e"}.fa-shopping-bag:before{content:"\f290"}.fa-shopping-basket:before{content:"\f291"}.fa-hashtag:before{content:"\f292"}.fa-bluetooth:before{content:"\f293"}.fa-bluetooth-b:before{content:"\f294"}.fa-percent:before{content:"\f295"}.fa-gitlab:before{content:"\f296"}.fa-wpbeginner:before{content:"\f297"}.fa-wpforms:before{content:"\f298"}.fa-envira:before{content:"\f299"}.fa-universal-access:before{content:"\f29a"}.fa-wheelchair-alt:before{content:"\f29b"}.fa-question-circle-o:before{content:"\f29c"}.fa-blind:before{content:"\f29d"}.fa-audio-description:before{content:"\f29e"}.fa-volume-control-phone:before{content:"\f2a0"}.fa-braille:before{content:"\f2a1"}.fa-assistive-listening-systems:before{content:"\f2a2"}.fa-asl-interpreting:before,.fa-american-sign-language-interpreting:before{content:"\f2a3"}.fa-deafness:before,.fa-hard-of-hearing:before,.fa-deaf:before{content:"\f2a4"}.fa-glide:before{content:"\f2a5"}.fa-glide-g:before{content:"\f2a6"}.fa-signing:before,.fa-sign-language:before{content:"\f2a7"}.fa-low-vision:before{content:"\f2a8"}.fa-viadeo:before{content:"\f2a9"}.fa-viadeo-square:before{content:"\f2aa"}.fa-snapchat:before{content:"\f2ab"}.fa-snapchat-ghost:before{content:"\f2ac"}.fa-snapchat-square:before{content:"\f2ad"}.fa-pied-piper:before{content:"\f2ae"}.fa-first-order:before{content:"\f2b0"}.fa-yoast:before{content:"\f2b1"}.fa-themeisle:before{content:"\f2b2"}.fa-google-plus-circle:before,.fa-google-plus-official:before{content:"\f2b3"}.fa-fa:before,.fa-font-awesome:before{content:"\f2b4"}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto} diff --git a/assets/css/ie8.css b/assets/css/ie8.css new file mode 100644 index 0000000..a7be0d1 --- /dev/null +++ b/assets/css/ie8.css @@ -0,0 +1,29 @@ +/* + Astral by HTML5 UP + html5up.net | @ajlkn + Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) +*/ + +/* Basic */ + + body { + background-image: url("images/bg.jpg"); + background-size: cover; + -ms-behavior: url("assets/js/ie/backgroundsize.min.htc"); + } + +/* Section/Article */ + + section > .last-child, section.last-child, article > .last-child, article.last-child { + margin-bottom: 0; + } + +/* Nav */ + + #nav a span { + display: none !important; + } + + #nav a:before { + font-size: 1.75em; + } \ No newline at end of file diff --git a/assets/css/images/bg.jpg b/assets/css/images/bg.jpg new file mode 100644 index 0000000..1476831 Binary files /dev/null and b/assets/css/images/bg.jpg differ diff --git a/assets/css/images/overlay.png b/assets/css/images/overlay.png new file mode 100644 index 0000000..f6f47f5 Binary files /dev/null and b/assets/css/images/overlay.png differ diff --git a/assets/css/main.css b/assets/css/main.css new file mode 100644 index 0000000..2cbed31 --- /dev/null +++ b/assets/css/main.css @@ -0,0 +1,1584 @@ +@import url("https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,300italic,400italic"); +@import url("font-awesome.min.css"); + +/* + Astral by HTML5 UP + html5up.net | @ajlkn + Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) +*/ + +/* Reset */ + + html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; + } + + article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { + display: block; + } + + body { + line-height: 1; + } + + ol, ul { + list-style: none; + } + + blockquote, q { + quotes: none; + } + + blockquote:before, blockquote:after, q:before, q:after { + content: ''; + content: none; + } + + table { + border-collapse: collapse; + border-spacing: 0; + } + + body { + -webkit-text-size-adjust: none; + } + +/* Box Model */ + + *, *:before, *:after { + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; + } + +/* Grid */ + + .row { + border-bottom: solid 1px transparent; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; + } + + .row > * { + float: left; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; + } + + .row:after, .row:before { + content: ''; + display: block; + clear: both; + height: 0; + } + + .row.uniform > * > :first-child { + margin-top: 0; + } + + .row.uniform > * > :last-child { + margin-bottom: 0; + } + + .row.\30 \25 > * { + padding: 0 0 0 0px; + } + + .row.\30 \25 { + margin: 0 0 -1px 0px; + } + + .row.uniform.\30 \25 > * { + padding: 0px 0 0 0px; + } + + .row.uniform.\30 \25 { + margin: 0px 0 -1px 0px; + } + + .row > * { + padding: 0 0 0 40px; + } + + .row { + margin: 0 0 -1px -40px; + } + + .row.uniform > * { + padding: 40px 0 0 40px; + } + + .row.uniform { + margin: -40px 0 -1px -40px; + } + + .row.\32 00\25 > * { + padding: 0 0 0 80px; + } + + .row.\32 00\25 { + margin: 0 0 -1px -80px; + } + + .row.uniform.\32 00\25 > * { + padding: 80px 0 0 80px; + } + + .row.uniform.\32 00\25 { + margin: -80px 0 -1px -80px; + } + + .row.\31 50\25 > * { + padding: 0 0 0 60px; + } + + .row.\31 50\25 { + margin: 0 0 -1px -60px; + } + + .row.uniform.\31 50\25 > * { + padding: 60px 0 0 60px; + } + + .row.uniform.\31 50\25 { + margin: -60px 0 -1px -60px; + } + + .row.\35 0\25 > * { + padding: 0 0 0 20px; + } + + .row.\35 0\25 { + margin: 0 0 -1px -20px; + } + + .row.uniform.\35 0\25 > * { + padding: 20px 0 0 20px; + } + + .row.uniform.\35 0\25 { + margin: -20px 0 -1px -20px; + } + + .row.\32 5\25 > * { + padding: 0 0 0 10px; + } + + .row.\32 5\25 { + margin: 0 0 -1px -10px; + } + + .row.uniform.\32 5\25 > * { + padding: 10px 0 0 10px; + } + + .row.uniform.\32 5\25 { + margin: -10px 0 -1px -10px; + } + + .\31 2u, .\31 2u\24 { + width: 100%; + clear: none; + margin-left: 0; + } + + .\31 1u, .\31 1u\24 { + width: 91.6666666667%; + clear: none; + margin-left: 0; + } + + .\31 0u, .\31 0u\24 { + width: 83.3333333333%; + clear: none; + margin-left: 0; + } + + .\39 u, .\39 u\24 { + width: 75%; + clear: none; + margin-left: 0; + } + + .\38 u, .\38 u\24 { + width: 66.6666666667%; + clear: none; + margin-left: 0; + } + + .\37 u, .\37 u\24 { + width: 58.3333333333%; + clear: none; + margin-left: 0; + } + + .\36 u, .\36 u\24 { + width: 50%; + clear: none; + margin-left: 0; + } + + .\35 u, .\35 u\24 { + width: 41.6666666667%; + clear: none; + margin-left: 0; + } + + .\34 u, .\34 u\24 { + width: 33.3333333333%; + clear: none; + margin-left: 0; + } + + .\33 u, .\33 u\24 { + width: 25%; + clear: none; + margin-left: 0; + } + + .\32 u, .\32 u\24 { + width: 16.6666666667%; + clear: none; + margin-left: 0; + } + + .\31 u, .\31 u\24 { + width: 8.3333333333%; + clear: none; + margin-left: 0; + } + + .\31 2u\24 + *, + .\31 1u\24 + *, + .\31 0u\24 + *, + .\39 u\24 + *, + .\38 u\24 + *, + .\37 u\24 + *, + .\36 u\24 + *, + .\35 u\24 + *, + .\34 u\24 + *, + .\33 u\24 + *, + .\32 u\24 + *, + .\31 u\24 + * { + clear: left; + } + + .\-11u { + margin-left: 91.66667%; + } + + .\-10u { + margin-left: 83.33333%; + } + + .\-9u { + margin-left: 75%; + } + + .\-8u { + margin-left: 66.66667%; + } + + .\-7u { + margin-left: 58.33333%; + } + + .\-6u { + margin-left: 50%; + } + + .\-5u { + margin-left: 41.66667%; + } + + .\-4u { + margin-left: 33.33333%; + } + + .\-3u { + margin-left: 25%; + } + + .\-2u { + margin-left: 16.66667%; + } + + .\-1u { + margin-left: 8.33333%; + } + + @media screen and (min-width: 737px) { + + .row > * { + padding: 25px 0 0 25px; + } + + .row { + margin: -25px 0 -1px -25px; + } + + .row.uniform > * { + padding: 25px 0 0 25px; + } + + .row.uniform { + margin: -25px 0 -1px -25px; + } + + .row.\32 00\25 > * { + padding: 50px 0 0 50px; + } + + .row.\32 00\25 { + margin: -50px 0 -1px -50px; + } + + .row.uniform.\32 00\25 > * { + padding: 50px 0 0 50px; + } + + .row.uniform.\32 00\25 { + margin: -50px 0 -1px -50px; + } + + .row.\31 50\25 > * { + padding: 37.5px 0 0 37.5px; + } + + .row.\31 50\25 { + margin: -37.5px 0 -1px -37.5px; + } + + .row.uniform.\31 50\25 > * { + padding: 37.5px 0 0 37.5px; + } + + .row.uniform.\31 50\25 { + margin: -37.5px 0 -1px -37.5px; + } + + .row.\35 0\25 > * { + padding: 12.5px 0 0 12.5px; + } + + .row.\35 0\25 { + margin: -12.5px 0 -1px -12.5px; + } + + .row.uniform.\35 0\25 > * { + padding: 12.5px 0 0 12.5px; + } + + .row.uniform.\35 0\25 { + margin: -12.5px 0 -1px -12.5px; + } + + .row.\32 5\25 > * { + padding: 6.25px 0 0 6.25px; + } + + .row.\32 5\25 { + margin: -6.25px 0 -1px -6.25px; + } + + .row.uniform.\32 5\25 > * { + padding: 6.25px 0 0 6.25px; + } + + .row.uniform.\32 5\25 { + margin: -6.25px 0 -1px -6.25px; + } + + .\31 2u\28desktop\29, .\31 2u\24\28desktop\29 { + width: 100%; + clear: none; + margin-left: 0; + } + + .\31 1u\28desktop\29, .\31 1u\24\28desktop\29 { + width: 91.6666666667%; + clear: none; + margin-left: 0; + } + + .\31 0u\28desktop\29, .\31 0u\24\28desktop\29 { + width: 83.3333333333%; + clear: none; + margin-left: 0; + } + + .\39 u\28desktop\29, .\39 u\24\28desktop\29 { + width: 75%; + clear: none; + margin-left: 0; + } + + .\38 u\28desktop\29, .\38 u\24\28desktop\29 { + width: 66.6666666667%; + clear: none; + margin-left: 0; + } + + .\37 u\28desktop\29, .\37 u\24\28desktop\29 { + width: 58.3333333333%; + clear: none; + margin-left: 0; + } + + .\36 u\28desktop\29, .\36 u\24\28desktop\29 { + width: 50%; + clear: none; + margin-left: 0; + } + + .\35 u\28desktop\29, .\35 u\24\28desktop\29 { + width: 41.6666666667%; + clear: none; + margin-left: 0; + } + + .\34 u\28desktop\29, .\34 u\24\28desktop\29 { + width: 33.3333333333%; + clear: none; + margin-left: 0; + } + + .\33 u\28desktop\29, .\33 u\24\28desktop\29 { + width: 25%; + clear: none; + margin-left: 0; + } + + .\32 u\28desktop\29, .\32 u\24\28desktop\29 { + width: 16.6666666667%; + clear: none; + margin-left: 0; + } + + .\31 u\28desktop\29, .\31 u\24\28desktop\29 { + width: 8.3333333333%; + clear: none; + margin-left: 0; + } + + .\31 2u\24\28desktop\29 + *, + .\31 1u\24\28desktop\29 + *, + .\31 0u\24\28desktop\29 + *, + .\39 u\24\28desktop\29 + *, + .\38 u\24\28desktop\29 + *, + .\37 u\24\28desktop\29 + *, + .\36 u\24\28desktop\29 + *, + .\35 u\24\28desktop\29 + *, + .\34 u\24\28desktop\29 + *, + .\33 u\24\28desktop\29 + *, + .\32 u\24\28desktop\29 + *, + .\31 u\24\28desktop\29 + * { + clear: left; + } + + .\-11u\28desktop\29 { + margin-left: 91.66667%; + } + + .\-10u\28desktop\29 { + margin-left: 83.33333%; + } + + .\-9u\28desktop\29 { + margin-left: 75%; + } + + .\-8u\28desktop\29 { + margin-left: 66.66667%; + } + + .\-7u\28desktop\29 { + margin-left: 58.33333%; + } + + .\-6u\28desktop\29 { + margin-left: 50%; + } + + .\-5u\28desktop\29 { + margin-left: 41.66667%; + } + + .\-4u\28desktop\29 { + margin-left: 33.33333%; + } + + .\-3u\28desktop\29 { + margin-left: 25%; + } + + .\-2u\28desktop\29 { + margin-left: 16.66667%; + } + + .\-1u\28desktop\29 { + margin-left: 8.33333%; + } + + } + + @media screen and (max-width: 736px) { + + .row > * { + padding: 15px 0 0 15px; + } + + .row { + margin: -15px 0 -1px -15px; + } + + .row.uniform > * { + padding: 15px 0 0 15px; + } + + .row.uniform { + margin: -15px 0 -1px -15px; + } + + .row.\32 00\25 > * { + padding: 30px 0 0 30px; + } + + .row.\32 00\25 { + margin: -30px 0 -1px -30px; + } + + .row.uniform.\32 00\25 > * { + padding: 30px 0 0 30px; + } + + .row.uniform.\32 00\25 { + margin: -30px 0 -1px -30px; + } + + .row.\31 50\25 > * { + padding: 22.5px 0 0 22.5px; + } + + .row.\31 50\25 { + margin: -22.5px 0 -1px -22.5px; + } + + .row.uniform.\31 50\25 > * { + padding: 22.5px 0 0 22.5px; + } + + .row.uniform.\31 50\25 { + margin: -22.5px 0 -1px -22.5px; + } + + .row.\35 0\25 > * { + padding: 7.5px 0 0 7.5px; + } + + .row.\35 0\25 { + margin: -7.5px 0 -1px -7.5px; + } + + .row.uniform.\35 0\25 > * { + padding: 7.5px 0 0 7.5px; + } + + .row.uniform.\35 0\25 { + margin: -7.5px 0 -1px -7.5px; + } + + .row.\32 5\25 > * { + padding: 3.75px 0 0 3.75px; + } + + .row.\32 5\25 { + margin: -3.75px 0 -1px -3.75px; + } + + .row.uniform.\32 5\25 > * { + padding: 3.75px 0 0 3.75px; + } + + .row.uniform.\32 5\25 { + margin: -3.75px 0 -1px -3.75px; + } + + .\31 2u\28mobile\29, .\31 2u\24\28mobile\29 { + width: 100%; + clear: none; + margin-left: 0; + } + + .\31 1u\28mobile\29, .\31 1u\24\28mobile\29 { + width: 91.6666666667%; + clear: none; + margin-left: 0; + } + + .\31 0u\28mobile\29, .\31 0u\24\28mobile\29 { + width: 83.3333333333%; + clear: none; + margin-left: 0; + } + + .\39 u\28mobile\29, .\39 u\24\28mobile\29 { + width: 75%; + clear: none; + margin-left: 0; + } + + .\38 u\28mobile\29, .\38 u\24\28mobile\29 { + width: 66.6666666667%; + clear: none; + margin-left: 0; + } + + .\37 u\28mobile\29, .\37 u\24\28mobile\29 { + width: 58.3333333333%; + clear: none; + margin-left: 0; + } + + .\36 u\28mobile\29, .\36 u\24\28mobile\29 { + width: 50%; + clear: none; + margin-left: 0; + } + + .\35 u\28mobile\29, .\35 u\24\28mobile\29 { + width: 41.6666666667%; + clear: none; + margin-left: 0; + } + + .\34 u\28mobile\29, .\34 u\24\28mobile\29 { + width: 33.3333333333%; + clear: none; + margin-left: 0; + } + + .\33 u\28mobile\29, .\33 u\24\28mobile\29 { + width: 25%; + clear: none; + margin-left: 0; + } + + .\32 u\28mobile\29, .\32 u\24\28mobile\29 { + width: 16.6666666667%; + clear: none; + margin-left: 0; + } + + .\31 u\28mobile\29, .\31 u\24\28mobile\29 { + width: 8.3333333333%; + clear: none; + margin-left: 0; + } + + .\31 2u\24\28mobile\29 + *, + .\31 1u\24\28mobile\29 + *, + .\31 0u\24\28mobile\29 + *, + .\39 u\24\28mobile\29 + *, + .\38 u\24\28mobile\29 + *, + .\37 u\24\28mobile\29 + *, + .\36 u\24\28mobile\29 + *, + .\35 u\24\28mobile\29 + *, + .\34 u\24\28mobile\29 + *, + .\33 u\24\28mobile\29 + *, + .\32 u\24\28mobile\29 + *, + .\31 u\24\28mobile\29 + * { + clear: left; + } + + .\-11u\28mobile\29 { + margin-left: 91.66667%; + } + + .\-10u\28mobile\29 { + margin-left: 83.33333%; + } + + .\-9u\28mobile\29 { + margin-left: 75%; + } + + .\-8u\28mobile\29 { + margin-left: 66.66667%; + } + + .\-7u\28mobile\29 { + margin-left: 58.33333%; + } + + .\-6u\28mobile\29 { + margin-left: 50%; + } + + .\-5u\28mobile\29 { + margin-left: 41.66667%; + } + + .\-4u\28mobile\29 { + margin-left: 33.33333%; + } + + .\-3u\28mobile\29 { + margin-left: 25%; + } + + .\-2u\28mobile\29 { + margin-left: 16.66667%; + } + + .\-1u\28mobile\29 { + margin-left: 8.33333%; + } + + } + +/* Basic */ + + body { + background-image: url("images/overlay.png"), url("images/bg.jpg"); + background-repeat: repeat, no-repeat; + background-size: auto, 100% 100%; + font-family: 'Source Sans Pro', sans-serif; + font-weight: 300; + color: #777777; + } + + body.is-loading *, body.is-loading *:before, body.is-loading *:after { + -moz-transition: none !important; + -webkit-transition: none !important; + -ms-transition: none !important; + transition: none !important; + -moz-animation: none !important; + -webkit-animation: none !important; + -ms-animation: none !important; + animation: none !important; + } + + input, textarea, select { + font-family: 'Source Sans Pro', sans-serif; + font-weight: 300; + color: #777777; + } + + strong, b, h1, h2, h3, h4, h5, h6 { + font-weight: 400; + color: #363636; + } + + blockquote { + border-left: solid 0.5em #ddd; + padding: 1em 0 1em 2em; + font-style: italic; + } + + em, i { + font-style: italic; + } + + hr { + border: 0; + border-top: solid 1px #ddd; + padding: 1.5em 0 0 0; + margin: 1.75em 0 0 0; + } + + sub { + position: relative; + top: 0.5em; + font-size: 0.8em; + } + + sup { + position: relative; + top: -0.5em; + font-size: 0.8em; + } + + br.clear { + clear: both; + } + + p, ul, ol, dl, table, blockquote, form { + margin-bottom: 2em; + } + +/* Table */ + + table { + width: 100%; + } + + table.default tbody tr { + border-bottom: solid 1px #f4f4f4; + } + + table.default td { + padding: 0.5em 1em 0.5em 1em; + } + + table.default th { + text-align: left; + font-weight: 400; + padding: 0.5em 1em 0.5em 1em; + } + + table.default thead { + border-bottom: solid 2px #f4f4f4; + } + +/* Form */ + + form label { + display: block; + font-weight: 400; + color: #363636; + margin: 0 0 1em 0; + } + + form input[type="text"], + form input[type="email"], + form input[type="password"], + form select, + form textarea { + -webkit-appearance: none; + border: 0; + background: #f4f4f4; + padding: 0.75em; + width: 100%; + -moz-transition: background-color .25s ease-in-out; + -webkit-transition: background-color .25s ease-in-out; + -ms-transition: background-color .25s ease-in-out; + transition: background-color .25s ease-in-out; + } + + form input[type="text"]:focus, + form input[type="email"]:focus, + form input[type="password"]:focus, + form select:focus, + form textarea:focus { + background: #f8f8f8; + } + + form input[type="text"], + form input[type="email"], + form input[type="password"], + form select { + line-height: 1.35em; + } + + form ::-webkit-input-placeholder { + color: #999; + } + + form :-moz-placeholder { + color: #999; + } + + form ::-moz-placeholder { + color: #999; + } + + form :-ms-input-placeholder { + color: #999; + } + +/* Section/Article */ + + section, article { + margin-bottom: 3em; + } + + section > :last-child, section:last-child, article > :last-child, article:last-child { + margin-bottom: 0; + } + + header > p { + color: #aaa; + } + +/* Image */ + + .image { + display: inline-block; + } + + .image img { + display: block; + width: 100%; + } + + .image.fit { + display: block; + width: 100%; + } + + .image.featured { + display: block; + width: 100%; + margin: 0 0 2em 0; + } + + .image.left { + float: left; + margin: 0 2em 2em 0; + } + + .image.centered { + display: block; + margin: 0 0 2em 0; + } + + .image.centered img { + margin: 0 auto; + width: auto; + } + +/* Button */ + + input[type="button"], + input[type="submit"], + input[type="reset"], + button, + .button { + -webkit-appearance: none; + display: inline-block; + background-color: #222222; + color: #ffffff; + border: 0; + cursor: pointer; + outline: 0; + -moz-transition: background-color .25s ease-in-out; + -webkit-transition: background-color .25s ease-in-out; + -ms-transition: background-color .25s ease-in-out; + transition: background-color .25s ease-in-out; + } + + input[type="button"]:hover, + input[type="submit"]:hover, + input[type="reset"]:hover, + button:hover, + .button:hover { + background-color: #333333; + } + + input[type="button"]:active, + input[type="submit"]:active, + input[type="reset"]:active, + button:active, + .button:active { + background-color: #444444; + } + + input[type="button"].alt, + input[type="submit"].alt, + input[type="reset"].alt, + button.alt, + .button.alt { + background-color: #777777; + } + + input[type="button"].alt:hover, + input[type="submit"].alt:hover, + input[type="reset"].alt:hover, + button.alt:hover, + .button.alt:hover { + background-color: #888888; + } + + input[type="button"].alt:active, + input[type="submit"].alt:active, + input[type="reset"].alt:active, + button.alt:active, + .button.alt:active { + background-color: #999999; + } + +/* List */ + + ul.default { + list-style: disc; + padding-left: 1em; + } + + ul.default li { + padding-left: 0.5em; + } + + ul.actions li { + display: inline-block; + margin-left: 0.5em; + } + + ul.actions li:first-child { + margin-left: 0; + } + + ol.default { + list-style: decimal; + padding-left: 1.25em; + } + + ol.default li { + padding-left: 0.25em; + } + +/* Icons */ + + .icon { + position: relative; + text-decoration: none; + } + + .icon:before { + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-family: FontAwesome; + font-style: normal; + font-weight: normal; + text-transform: none !important; + } + + .icon > .label { + display: none; + } + +/* Nav */ + + #nav a { + position: relative; + display: inline-block; + color: #ffffff; + width: 1em; + height: 1em; + line-height: 0.9em; + } + + #nav a.icon:before { + padding-right: 0; + } + +/* Panels */ + + #main { + position: relative; + overflow: hidden; + } + + .panel { + position: relative; + } + +/* Me */ + + #me .pic { + position: relative; + display: block; + } + + #me .pic:before { + content: ''; + position: absolute; + top: 0; + left: 0; + background: url("images/overlay.png"); + width: 100%; + height: 100%; + z-index: 1; + } + +/* Footer */ + + #footer { + color: #000; + color: rgba(000, 000, 000, 0.65); + } + + #footer a { + color: #000; + color: rgba(000, 000, 000, 0.65); + -moz-transition: color .25s ease-in-out; + -webkit-transition: color .25s ease-in-out; + -ms-transition: color .25s ease-in-out; + transition: color .25s ease-in-out; + } + + #footer a:hover { + color: white; + } + + #footer .copyright li { + display: inline-block; + } + + #footer .copyright li:before { + display: inline; + content: '\2022'; + opacity: 0.5; + padding: 0 0.75em 0 0.75em; + } + + #footer .copyright li:first-child:before { + display: none; + } + +/* Desktop */ + + @media screen and (min-width: 737px) { + + /* Basic */ + + html { + min-width: 100%; + min-height: 100%; + } + + body { + width: 100%; + min-width: 1000px; + min-height: 100%; + overflow-y: scroll; + background-attachment: fixed; + font-size: 14pt; + line-height: 1.75em; + } + + input, textarea, select { + font-size: 14pt; + line-height: 1.75em; + } + + h1 { + font-size: 2.4em; + letter-spacing: -0.015em; + } + + h2 { + font-size: 1.8em; + letter-spacing: -0.015em; + } + + h3, h4, h5, h6 { + font-size: 1.25em; + letter-spacing: -0.015em; + } + + /* Section/Article */ + + header { + margin: 0 0 1.5em 0; + } + + header > p { + margin: 0.5em 0 0 0; + } + + /* Button */ + + input[type="button"], + input[type="submit"], + input[type="reset"], + button, + .button { + padding: 0.7em 1.5em 0.7em 1.5em; + } + + input[type="button"].small, + input[type="submit"].small, + input[type="reset"].small, + button.small, + .button.small { + font-size: 0.75em; + } + + input[type="button"].big, + input[type="submit"].big, + input[type="reset"].big, + button.big, + .button.big { + font-size: 1.25em; + padding: 0.5em 1.25em 0.5em 1.25em; + } + + input[type="button"].huge, + input[type="submit"].huge, + input[type="reset"].huge, + button.huge, + .button.huge { + font-size: 1.5em; + padding: 0.5em 1.25em 0.5em 1.25em; + } + + /* Wrapper */ + + #wrapper { + width: 45em; + margin: 0 auto; + opacity: 0.00001; + } + + #wrapper.tall { + padding-bottom: 6em; + } + + /* Nav */ + + #nav { + text-align: center; + height: 4.25em; + cursor: default; + } + + #nav a { + font-size: 2.5em; + margin: 0 0.25em 0 0.25em; + opacity: 0.35; + outline: 0; + -moz-transition: opacity .25s ease-in-out; + -webkit-transition: opacity .25s ease-in-out; + -ms-transition: opacity .25s ease-in-out; + transition: opacity .25s ease-in-out; + } + + #nav a:before { + font-size: 0.8em; + } + + #nav a:after { + content: ''; + display: block; + position: absolute; + left: 50%; + bottom: -0.75em; + margin-left: -0.5em; + border-bottom: solid 0em #ffffff; + border-left: solid 0.5em transparent; + border-right: solid 0.5em transparent; + -moz-transition: border-bottom-width .25s ease-in-out; + -webkit-transition: border-bottom-width .25s ease-in-out; + -ms-transition: border-bottom-width .25s ease-in-out; + transition: border-bottom-width .25s ease-in-out; + } + + #nav a span { + display: block; + position: absolute; + background: #222222; + color: #ffffff; + top: -2.75em; + font-size: 0.3em; + height: 2.25em; + line-height: 2.25em; + left: 50%; + opacity: 0; + -moz-transition: opacity .25s ease-in-out; + -webkit-transition: opacity .25s ease-in-out; + -ms-transition: opacity .25s ease-in-out; + transition: opacity .25s ease-in-out; + width: 5.5em; + margin-left: -2.75em; + } + + #nav a span:after { + content: ''; + display: block; + position: absolute; + bottom: -0.4em; + left: 50%; + margin-left: -0.6em; + border-top: solid 0.6em #222222; + border-left: solid 0.6em transparent; + border-right: solid 0.6em transparent; + } + + #nav a:hover { + opacity: 1.0; + } + + #nav a:hover span { + opacity: 1.0; + } + + #nav a.active { + opacity: 1.0; + } + + #nav a.active:after { + border-bottom-width: 0.5em; + } + + /* Panels */ + + #main { + width: 45em; + background: #ffffff; + box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.25); + } + + .panel { + padding: 3.5em 2.5em 3.5em 2.5em; + position: absolute; + top: 0; + left: 0; + width: 45em; + } + + /* Me */ + + #me { + padding: 0; + height: 20em; + } + + #me .pic { + display: block; + position: absolute; + right: -1px; + top: 0; + height: 100%; + text-decoration: none; + } + + #me .pic img { + position: relative; + display: block; + height: 100%; + } + + #me .pic .arrow { + display: block; + position: absolute; + right: 0; + top: 50%; + margin-top: -1.375em; + width: 2.75em; + height: 2.75em; + background: #000; + background: rgba(0, 0, 0, 0.75); + color: #ffffff; + text-align: center; + line-height: 2.75em; + font-size: 1.5em; + z-index: 1; + -moz-transition: width .15s ease-in-out, padding-right .15s ease-in-out; + -webkit-transition: width .15s ease-in-out, padding-right .15s ease-in-out; + -ms-transition: width .15s ease-in-out, padding-right .15s ease-in-out; + transition: width .15s ease-in-out, padding-right .15s ease-in-out; + } + + #me .pic .arrow:before { + position: relative; + padding-right: 0; + top: 0.125em; + } + + #me .pic .arrow span { + display: block; + text-indent: -9999px; + } + + #me .pic:hover .arrow { + width: 3em; + padding-right: 0.25em; + } + + #me header { + position: absolute; + left: 0; + top: 0; + width: 100%; + height: 100%; + margin-left: 2.5em; + } + + #me header > h1 { + position: absolute; + left: 0; + bottom: 52.5%; + margin: 0; + } + + #me header > p { + position: absolute; + left: 0; + top: 52.5%; + font-size: 1.5em; + letter-spacing: -0.015em; + margin-top: 0; + } + + /* Footer */ + + #footer { + text-align: center; + padding: 2em 0 0 0; + font-size: 0.75em; + } + + } + +/* Mobile */ + + @media screen and (max-width: 736px) { + + /* Basic */ + + body, input, textarea, select { + font-size: 11pt; + line-height: 1.75em; + } + + h1, h2 { + font-size: 1.75em; + letter-spacing: -0.025em; + } + + h3, h4, h5, h6 { + font-size: 1.25em; + letter-spacing: -0.025em; + } + + /* Section/Article */ + + header { + margin: 0 0 1.5em 0; + } + + header > p { + margin: 0.5em 0 0 0; + } + + /* Table */ + + table.style1 { + overflow-x: scroll; + } + + /* List */ + + ul.actions li { + display: block; + margin: 0.5em 0 0 0; + } + + ul.actions li:first-child { + margin-top: 0; + } + + /* Button */ + + input[type="button"], + input[type="submit"], + input[type="reset"], + button, + .button { + display: block; + width: 100%; + padding: 0.75em 0 0.75em 0; + text-align: center; + } + + /* Wrapper */ + + #wrapper { + padding: 7px; + } + + /* Nav */ + + #nav { + text-align: center; + margin: 6px 0 8px 0; + } + + #nav a { + font-size: 2em; + opacity: 0.5; + outline: 0; + width: 1.5em; + height: 1.5em; + line-height: 1.35em; + margin: 0 0.25em 0 0.25em; + } + + #nav a:active { + opacity: 1.0; + } + + #nav a span { + display: none; + } + + /* Panels */ + + #main { + background: none; + } + + .panel { + padding: 15px 15px 15px 15px; + margin: 0 0 7px 0; + background: #ffffff; + box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.25); + } + + .panel header { + padding-top: 1em; + } + + /* Me */ + + #me .pic { + width: 100%; + } + + #me .pic img { + display: block; + width: 100%; + } + + #me .pic .arrow { + display: none; + } + + #me header { + text-align: center; + } + + #me header > h1 { + font-size: 2.15em; + letter-spacing: -0.025em; + } + + #me header > p { + font-size: 1.25em; + } + + /* Footer */ + + #footer { + text-align: center; + padding: 2em 0 0 0; + font-size: 0.85em; + } + + #footer .copyright li { + display: block; + } + + #footer .copyright li:before { + display: none; + } + + } diff --git a/assets/css/noscript.css b/assets/css/noscript.css new file mode 100644 index 0000000..169a792 --- /dev/null +++ b/assets/css/noscript.css @@ -0,0 +1,47 @@ +/* + Astral by HTML5 UP + html5up.net | @ajlkn + Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) +*/ + +/* Wrapper */ + + #wrapper { + opacity: 1.0; + } + +/* Nav */ + + #nav { + margin-top: 4em; + } + + #nav a { + opacity: 1.0; + } + + #nav a:before, #nav a:after { + display: none; + } + + #nav a span { + top: 0; + opacity: 1.0; + } + + #nav a span:after { + display: none; + } + +/* Panels */ + + #main { + background: none; + box-shadow: none; + } + + .panel { + position: relative; + background: #ffffff; + box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.25); + } \ No newline at end of file diff --git a/assets/fonts/FontAwesome.otf b/assets/fonts/FontAwesome.otf new file mode 100644 index 0000000..d4de13e Binary files /dev/null and b/assets/fonts/FontAwesome.otf differ diff --git a/assets/fonts/fontawesome-webfont.eot b/assets/fonts/fontawesome-webfont.eot new file mode 100644 index 0000000..c7b00d2 Binary files /dev/null and b/assets/fonts/fontawesome-webfont.eot differ diff --git a/assets/fonts/fontawesome-webfont.svg b/assets/fonts/fontawesome-webfont.svg new file mode 100644 index 0000000..8b66187 --- /dev/null +++ b/assets/fonts/fontawesome-webfont.svg @@ -0,0 +1,685 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/assets/fonts/fontawesome-webfont.ttf b/assets/fonts/fontawesome-webfont.ttf new file mode 100644 index 0000000..f221e50 Binary files /dev/null and b/assets/fonts/fontawesome-webfont.ttf differ diff --git a/assets/fonts/fontawesome-webfont.woff b/assets/fonts/fontawesome-webfont.woff new file mode 100644 index 0000000..6e7483c Binary files /dev/null and b/assets/fonts/fontawesome-webfont.woff differ diff --git a/assets/fonts/fontawesome-webfont.woff2 b/assets/fonts/fontawesome-webfont.woff2 new file mode 100644 index 0000000..7eb74fd Binary files /dev/null and b/assets/fonts/fontawesome-webfont.woff2 differ diff --git a/assets/js/ie/backgroundsize.min.htc b/assets/js/ie/backgroundsize.min.htc new file mode 100644 index 0000000..3d9960d --- /dev/null +++ b/assets/js/ie/backgroundsize.min.htc @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/assets/js/ie/html5shiv.js b/assets/js/ie/html5shiv.js new file mode 100644 index 0000000..dcf351c --- /dev/null +++ b/assets/js/ie/html5shiv.js @@ -0,0 +1,8 @@ +/* + HTML5 Shiv v3.6.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed +*/ +(function(l,f){function m(){var a=e.elements;return"string"==typeof a?a.split(" "):a}function i(a){var b=n[a[o]];b||(b={},h++,a[o]=h,n[h]=b);return b}function p(a,b,c){b||(b=f);if(g)return b.createElement(a);c||(c=i(b));b=c.cache[a]?c.cache[a].cloneNode():r.test(a)?(c.cache[a]=c.createElem(a)).cloneNode():c.createElem(a);return b.canHaveChildren&&!s.test(a)?c.frag.appendChild(b):b}function t(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag(); +a.createElement=function(c){return!e.shivMethods?b.createElem(c):p(c,a,b)};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/\w+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c("'+a+'")'})+");return n}")(e,b.frag)}function q(a){a||(a=f);var b=i(a);if(e.shivCSS&&!j&&!b.hasCSS){var c,d=a;c=d.createElement("p");d=d.getElementsByTagName("head")[0]||d.documentElement;c.innerHTML="x"; +c=d.insertBefore(c.lastChild,d.firstChild);b.hasCSS=!!c}g||t(a,b);return a}var k=l.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,r=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,j,o="_html5shiv",h=0,n={},g;(function(){try{var a=f.createElement("a");a.innerHTML="";j="hidden"in a;var b;if(!(b=1==a.childNodes.length)){f.createElement("a");var c=f.createDocumentFragment();b="undefined"==typeof c.cloneNode|| +"undefined"==typeof c.createDocumentFragment||"undefined"==typeof c.createElement}g=b}catch(d){g=j=!0}})();var e={elements:k.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup main mark meter nav output progress section summary time video",version:"3.6.2",shivCSS:!1!==k.shivCSS,supportsUnknownElements:g,shivMethods:!1!==k.shivMethods,type:"default",shivDocument:q,createElement:p,createDocumentFragment:function(a,b){a||(a=f);if(g)return a.createDocumentFragment(); +for(var b=b||i(a),c=b.frag.cloneNode(),d=0,e=m(),h=e.length;d #mq-test-1 { width: 42px; }',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){v(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))},g=function(a){return a.replace(c.regex.minmaxwh,"").match(c.regex.other)};if(c.ajax=f,c.queue=d,c.unsupportedmq=g,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,comments:/\/\*[^*]*\*+([^/][^*]*\*+)*\//gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\(\s*min\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,maxw:/\(\s*max\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,minmaxwh:/\(\s*m(in|ax)\-(height|width)\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/gi,other:/\([^\)]*\)/g},c.mediaQueriesSupported=a.matchMedia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var h,i,j,k=a.document,l=k.documentElement,m=[],n=[],o=[],p={},q=30,r=k.getElementsByTagName("head")[0]||l,s=k.getElementsByTagName("base")[0],t=r.getElementsByTagName("link"),u=function(){var a,b=k.createElement("div"),c=k.body,d=l.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=k.createElement("body"),c.style.background="none"),l.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&l.insertBefore(c,l.firstChild),a=b.offsetWidth,f?l.removeChild(c):c.removeChild(b),l.style.fontSize=d,e&&(c.style.fontSize=e),a=j=parseFloat(a)},v=function(b){var c="clientWidth",d=l[c],e="CSS1Compat"===k.compatMode&&d||k.body[c]||d,f={},g=t[t.length-1],p=(new Date).getTime();if(b&&h&&q>p-h)return a.clearTimeout(i),i=a.setTimeout(v,q),void 0;h=p;for(var s in m)if(m.hasOwnProperty(s)){var w=m[s],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?j||u():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?j||u():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(n[w.rules]))}for(var C in o)o.hasOwnProperty(C)&&o[C]&&o[C].parentNode===r&&r.removeChild(o[C]);o.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=k.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,r.insertBefore(E,g.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(k.createTextNode(F)),o.push(E)}},w=function(a,b,d){var e=a.replace(c.regex.comments,"").replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substring(0,b.lastIndexOf("/"));var h=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},i=!f&&d;b.length&&(b+="/"),i&&(f=1);for(var j=0;f>j;j++){var k,l,o,p;i?(k=d,n.push(h(a))):(k=e[j].match(c.regex.findStyles)&&RegExp.$1,n.push(RegExp.$2&&h(RegExp.$2))),o=k.split(","),p=o.length;for(var q=0;p>q;q++)l=o[q],g(l)||m.push({media:l.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:n.length-1,hasquery:l.indexOf("(")>-1,minw:l.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:l.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}v()},x=function(){if(d.length){var b=d.shift();f(b.href,function(c){w(c,b.href,b.media),p[b.href]=!0,a.setTimeout(function(){x()},0)})}},y=function(){for(var b=0;ba?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)+1>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b="length"in a&&a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N=M.replace("w","w#"),O="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+N+"))|)"+L+"*\\]",P=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+O+")*)|.*)\\)|)",Q=new RegExp(L+"+","g"),R=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),S=new RegExp("^"+L+"*,"+L+"*"),T=new RegExp("^"+L+"*([>+~]|"+L+")"+L+"*"),U=new RegExp("="+L+"*([^\\]'\"]*?)"+L+"*\\]","g"),V=new RegExp(P),W=new RegExp("^"+N+"$"),X={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+O),PSEUDO:new RegExp("^"+P),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+L+"*(even|odd|(([+-]|)(\\d*)n|)"+L+"*(?:([+-]|)"+L+"*(\\d+)|))"+L+"*\\)|)","i"),bool:new RegExp("^(?:"+K+")$","i"),needsContext:new RegExp("^"+L+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+L+"*((?:-\\d)?\\d*)"+L+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,aa=/[+~]/,ba=/'|\\/g,ca=new RegExp("\\\\([\\da-f]{1,6}"+L+"?|("+L+")|.)","ig"),da=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},ea=function(){m()};try{H.apply(E=I.call(v.childNodes),v.childNodes),E[v.childNodes.length].nodeType}catch(fa){H={apply:E.length?function(a,b){G.apply(a,I.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function ga(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],k=b.nodeType,"string"!=typeof a||!a||1!==k&&9!==k&&11!==k)return d;if(!e&&p){if(11!==k&&(f=_.exec(a)))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return H.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName)return H.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=1!==k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(ba,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+ra(o[l]);w=aa.test(a)&&pa(b.parentNode)||b,x=o.join(",")}if(x)try{return H.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function ha(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ia(a){return a[u]=!0,a}function ja(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ka(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function la(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||C)-(~a.sourceIndex||C);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function na(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function oa(a){return ia(function(b){return b=+b,ia(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function pa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=ga.support={},f=ga.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=ga.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=g.documentElement,e=g.defaultView,e&&e!==e.top&&(e.addEventListener?e.addEventListener("unload",ea,!1):e.attachEvent&&e.attachEvent("onunload",ea)),p=!f(g),c.attributes=ja(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ja(function(a){return a.appendChild(g.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(g.getElementsByClassName),c.getById=ja(function(a){return o.appendChild(a).id=u,!g.getElementsByName||!g.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ca,da);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ca,da);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(g.querySelectorAll))&&(ja(function(a){o.appendChild(a).innerHTML="",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+L+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+L+"*(?:value|"+K+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ja(function(a){var b=g.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+L+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ja(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",P)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===g||a.ownerDocument===v&&t(v,a)?-1:b===g||b.ownerDocument===v&&t(v,b)?1:k?J(k,a)-J(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,h=[a],i=[b];if(!e||!f)return a===g?-1:b===g?1:e?-1:f?1:k?J(k,a)-J(k,b):0;if(e===f)return la(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?la(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},g):n},ga.matches=function(a,b){return ga(a,null,null,b)},ga.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return ga(b,n,null,[a]).length>0},ga.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},ga.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&D.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},ga.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},ga.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=ga.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=ga.selectors={cacheLength:50,createPseudo:ia,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ca,da),a[3]=(a[3]||a[4]||a[5]||"").replace(ca,da),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||ga.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&ga.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ca,da).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+L+")"+a+"("+L+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=ga.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(Q," ")+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||ga.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ia(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=J(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ia(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?ia(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ia(function(a){return function(b){return ga(a,b).length>0}}),contains:ia(function(a){return a=a.replace(ca,da),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ia(function(a){return W.test(a||"")||ga.error("unsupported lang: "+a),a=a.replace(ca,da).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:oa(function(){return[0]}),last:oa(function(a,b){return[b-1]}),eq:oa(function(a,b,c){return[0>c?c+b:c]}),even:oa(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:oa(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:oa(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:oa(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function sa(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function ta(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function ua(a,b,c){for(var d=0,e=b.length;e>d;d++)ga(a,b[d],c);return c}function va(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function wa(a,b,c,d,e,f){return d&&!d[u]&&(d=wa(d)),e&&!e[u]&&(e=wa(e,f)),ia(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||ua(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:va(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=va(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?J(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=va(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):H.apply(g,r)})}function xa(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=sa(function(a){return a===b},h,!0),l=sa(function(a){return J(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];f>i;i++)if(c=d.relative[a[i].type])m=[sa(ta(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return wa(i>1&&ta(m),i>1&&ra(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&xa(a.slice(i,e)),f>e&&xa(a=a.slice(e)),f>e&&ra(a))}m.push(c)}return ta(m)}function ya(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=F.call(i));s=va(s)}H.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&ga.uniqueSort(i)}return k&&(w=v,j=t),r};return c?ia(f):f}return h=ga.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=xa(b[c]),f[u]?d.push(f):e.push(f);f=A(a,ya(e,d)),f.selector=a}return f},i=ga.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(ca,da),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(ca,da),aa.test(j[0].type)&&pa(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&ra(j),!a)return H.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,aa.test(a)&&pa(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ja(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ja(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||ka("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ja(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ka("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ja(function(a){return null==a.getAttribute("disabled")})||ka(K,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),ga}(a);m.find=s,m.expr=s.selectors,m.expr[":"]=m.expr.pseudos,m.unique=s.uniqueSort,m.text=s.getText,m.isXMLDoc=s.isXML,m.contains=s.contains;var t=m.expr.match.needsContext,u=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,v=/^.[^:#\[\.,]*$/;function w(a,b,c){if(m.isFunction(b))return m.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return m.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(v.test(b))return m.filter(b,a,c);b=m.filter(b,a)}return m.grep(a,function(a){return m.inArray(a,b)>=0!==c})}m.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?m.find.matchesSelector(d,a)?[d]:[]:m.find.matches(a,m.grep(b,function(a){return 1===a.nodeType}))},m.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(m(a).filter(function(){for(b=0;e>b;b++)if(m.contains(d[b],this))return!0}));for(b=0;e>b;b++)m.find(a,d[b],c);return c=this.pushStack(e>1?m.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(w(this,a||[],!1))},not:function(a){return this.pushStack(w(this,a||[],!0))},is:function(a){return!!w(this,"string"==typeof a&&t.test(a)?m(a):a||[],!1).length}});var x,y=a.document,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=m.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||x).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof m?b[0]:b,m.merge(this,m.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:y,!0)),u.test(c[1])&&m.isPlainObject(b))for(c in b)m.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}if(d=y.getElementById(c[2]),d&&d.parentNode){if(d.id!==c[2])return x.find(a);this.length=1,this[0]=d}return this.context=y,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):m.isFunction(a)?"undefined"!=typeof x.ready?x.ready(a):a(m):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),m.makeArray(a,this))};A.prototype=m.fn,x=m(y);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};m.extend({dir:function(a,b,c){var d=[],e=a[b];while(e&&9!==e.nodeType&&(void 0===c||1!==e.nodeType||!m(e).is(c)))1===e.nodeType&&d.push(e),e=e[b];return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),m.fn.extend({has:function(a){var b,c=m(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(m.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=t.test(a)||"string"!=typeof a?m(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&m.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?m.unique(f):f)},index:function(a){return a?"string"==typeof a?m.inArray(this[0],m(a)):m.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(m.unique(m.merge(this.get(),m(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}m.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return m.dir(a,"parentNode")},parentsUntil:function(a,b,c){return m.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return m.dir(a,"nextSibling")},prevAll:function(a){return m.dir(a,"previousSibling")},nextUntil:function(a,b,c){return m.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return m.dir(a,"previousSibling",c)},siblings:function(a){return m.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return m.sibling(a.firstChild)},contents:function(a){return m.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:m.merge([],a.childNodes)}},function(a,b){m.fn[a]=function(c,d){var e=m.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=m.filter(d,e)),this.length>1&&(C[a]||(e=m.unique(e)),B.test(a)&&(e=e.reverse())),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return m.each(a.match(E)||[],function(a,c){b[c]=!0}),b}m.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):m.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(c=a.memory&&l,d=!0,f=g||0,g=0,e=h.length,b=!0;h&&e>f;f++)if(h[f].apply(l[0],l[1])===!1&&a.stopOnFalse){c=!1;break}b=!1,h&&(i?i.length&&j(i.shift()):c?h=[]:k.disable())},k={add:function(){if(h){var d=h.length;!function f(b){m.each(b,function(b,c){var d=m.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&f(c)})}(arguments),b?e=h.length:c&&(g=d,j(c))}return this},remove:function(){return h&&m.each(arguments,function(a,c){var d;while((d=m.inArray(c,h,d))>-1)h.splice(d,1),b&&(e>=d&&e--,f>=d&&f--)}),this},has:function(a){return a?m.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],e=0,this},disable:function(){return h=i=c=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,c||k.disable(),this},locked:function(){return!i},fireWith:function(a,c){return!h||d&&!i||(c=c||[],c=[a,c.slice?c.slice():c],b?i.push(c):j(c)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!d}};return k},m.extend({Deferred:function(a){var b=[["resolve","done",m.Callbacks("once memory"),"resolved"],["reject","fail",m.Callbacks("once memory"),"rejected"],["notify","progress",m.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return m.Deferred(function(c){m.each(b,function(b,f){var g=m.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&m.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?m.extend(a,d):d}},e={};return d.pipe=d.then,m.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&m.isFunction(a.promise)?e:0,g=1===f?a:m.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&m.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;m.fn.ready=function(a){return m.ready.promise().done(a),this},m.extend({isReady:!1,readyWait:1,holdReady:function(a){a?m.readyWait++:m.ready(!0)},ready:function(a){if(a===!0?!--m.readyWait:!m.isReady){if(!y.body)return setTimeout(m.ready);m.isReady=!0,a!==!0&&--m.readyWait>0||(H.resolveWith(y,[m]),m.fn.triggerHandler&&(m(y).triggerHandler("ready"),m(y).off("ready")))}}});function I(){y.addEventListener?(y.removeEventListener("DOMContentLoaded",J,!1),a.removeEventListener("load",J,!1)):(y.detachEvent("onreadystatechange",J),a.detachEvent("onload",J))}function J(){(y.addEventListener||"load"===event.type||"complete"===y.readyState)&&(I(),m.ready())}m.ready.promise=function(b){if(!H)if(H=m.Deferred(),"complete"===y.readyState)setTimeout(m.ready);else if(y.addEventListener)y.addEventListener("DOMContentLoaded",J,!1),a.addEventListener("load",J,!1);else{y.attachEvent("onreadystatechange",J),a.attachEvent("onload",J);var c=!1;try{c=null==a.frameElement&&y.documentElement}catch(d){}c&&c.doScroll&&!function e(){if(!m.isReady){try{c.doScroll("left")}catch(a){return setTimeout(e,50)}I(),m.ready()}}()}return H.promise(b)};var K="undefined",L;for(L in m(k))break;k.ownLast="0"!==L,k.inlineBlockNeedsLayout=!1,m(function(){var a,b,c,d;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",k.inlineBlockNeedsLayout=a=3===b.offsetWidth,a&&(c.style.zoom=1)),c.removeChild(d))}),function(){var a=y.createElement("div");if(null==k.deleteExpando){k.deleteExpando=!0;try{delete a.test}catch(b){k.deleteExpando=!1}}a=null}(),m.acceptData=function(a){var b=m.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b};var M=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,N=/([A-Z])/g;function O(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(N,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:M.test(c)?m.parseJSON(c):c}catch(e){}m.data(a,b,c)}else c=void 0}return c}function P(a){var b;for(b in a)if(("data"!==b||!m.isEmptyObject(a[b]))&&"toJSON"!==b)return!1; + +return!0}function Q(a,b,d,e){if(m.acceptData(a)){var f,g,h=m.expando,i=a.nodeType,j=i?m.cache:a,k=i?a[h]:a[h]&&h;if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthh;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML="
a",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function aa(){return!0}function ba(){return!1}function ca(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=m.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof m===K||a&&m.event.triggered===a.type?void 0:m.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(E)||[""],h=b.length;while(h--)f=_.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=m.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=m.event.special[o]||{},l=m.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&m.expr.match.needsContext.test(e),namespace:p.join(".")},i),(n=g[o])||(n=g[o]=[],n.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?n.splice(n.delegateCount++,0,l):n.push(l),m.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m.hasData(a)&&m._data(a);if(r&&(k=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=_.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=m.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,n=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=n.length;while(f--)g=n[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(n.splice(f,1),g.selector&&n.delegateCount--,l.remove&&l.remove.call(a,g));i&&!n.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||m.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)m.event.remove(a,o+b[j],c,d,!0);m.isEmptyObject(k)&&(delete r.handle,m._removeData(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,o=[d||y],p=j.call(b,"type")?b.type:b,q=j.call(b,"namespace")?b.namespace.split("."):[];if(h=l=d=d||y,3!==d.nodeType&&8!==d.nodeType&&!$.test(p+m.event.triggered)&&(p.indexOf(".")>=0&&(q=p.split("."),p=q.shift(),q.sort()),g=p.indexOf(":")<0&&"on"+p,b=b[m.expando]?b:new m.Event(p,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=q.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:m.makeArray(c,[b]),k=m.event.special[p]||{},e||!k.trigger||k.trigger.apply(d,c)!==!1)){if(!e&&!k.noBubble&&!m.isWindow(d)){for(i=k.delegateType||p,$.test(i+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),l=h;l===(d.ownerDocument||y)&&o.push(l.defaultView||l.parentWindow||a)}n=0;while((h=o[n++])&&!b.isPropagationStopped())b.type=n>1?i:k.bindType||p,f=(m._data(h,"events")||{})[b.type]&&m._data(h,"handle"),f&&f.apply(h,c),f=g&&h[g],f&&f.apply&&m.acceptData(h)&&(b.result=f.apply(h,c),b.result===!1&&b.preventDefault());if(b.type=p,!e&&!b.isDefaultPrevented()&&(!k._default||k._default.apply(o.pop(),c)===!1)&&m.acceptData(d)&&g&&d[p]&&!m.isWindow(d)){l=d[g],l&&(d[g]=null),m.event.triggered=p;try{d[p]()}catch(r){}m.event.triggered=void 0,l&&(d[g]=l)}return b.result}},dispatch:function(a){a=m.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(m._data(this,"events")||{})[a.type]||[],k=m.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=m.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((m.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(e=[],f=0;h>f;f++)d=b[f],c=d.selector+" ",void 0===e[c]&&(e[c]=d.needsContext?m(c,this).index(i)>=0:m.find(c,this,null,[i]).length),e[c]&&e.push(d);e.length&&g.push({elem:i,handlers:e})}return h]","i"),ha=/^\s+/,ia=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,ja=/<([\w:]+)/,ka=/\s*$/g,ra={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],_default:k.htmlSerialize?[0,"",""]:[1,"X
","
"]},sa=da(y),ta=sa.appendChild(y.createElement("div"));ra.optgroup=ra.option,ra.tbody=ra.tfoot=ra.colgroup=ra.caption=ra.thead,ra.th=ra.td;function ua(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==K?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==K?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||m.nodeName(d,b)?f.push(d):m.merge(f,ua(d,b));return void 0===b||b&&m.nodeName(a,b)?m.merge([a],f):f}function va(a){W.test(a.type)&&(a.defaultChecked=a.checked)}function wa(a,b){return m.nodeName(a,"table")&&m.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function xa(a){return a.type=(null!==m.find.attr(a,"type"))+"/"+a.type,a}function ya(a){var b=pa.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function za(a,b){for(var c,d=0;null!=(c=a[d]);d++)m._data(c,"globalEval",!b||m._data(b[d],"globalEval"))}function Aa(a,b){if(1===b.nodeType&&m.hasData(a)){var c,d,e,f=m._data(a),g=m._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)m.event.add(b,c,h[c][d])}g.data&&(g.data=m.extend({},g.data))}}function Ba(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!k.noCloneEvent&&b[m.expando]){e=m._data(b);for(d in e.events)m.removeEvent(b,d,e.handle);b.removeAttribute(m.expando)}"script"===c&&b.text!==a.text?(xa(b).text=a.text,ya(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),k.html5Clone&&a.innerHTML&&!m.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&W.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}m.extend({clone:function(a,b,c){var d,e,f,g,h,i=m.contains(a.ownerDocument,a);if(k.html5Clone||m.isXMLDoc(a)||!ga.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(ta.innerHTML=a.outerHTML,ta.removeChild(f=ta.firstChild)),!(k.noCloneEvent&&k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||m.isXMLDoc(a)))for(d=ua(f),h=ua(a),g=0;null!=(e=h[g]);++g)d[g]&&Ba(e,d[g]);if(b)if(c)for(h=h||ua(a),d=d||ua(f),g=0;null!=(e=h[g]);g++)Aa(e,d[g]);else Aa(a,f);return d=ua(f,"script"),d.length>0&&za(d,!i&&ua(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,l,n=a.length,o=da(b),p=[],q=0;n>q;q++)if(f=a[q],f||0===f)if("object"===m.type(f))m.merge(p,f.nodeType?[f]:f);else if(la.test(f)){h=h||o.appendChild(b.createElement("div")),i=(ja.exec(f)||["",""])[1].toLowerCase(),l=ra[i]||ra._default,h.innerHTML=l[1]+f.replace(ia,"<$1>")+l[2],e=l[0];while(e--)h=h.lastChild;if(!k.leadingWhitespace&&ha.test(f)&&p.push(b.createTextNode(ha.exec(f)[0])),!k.tbody){f="table"!==i||ka.test(f)?""!==l[1]||ka.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;while(e--)m.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j)}m.merge(p,h.childNodes),h.textContent="";while(h.firstChild)h.removeChild(h.firstChild);h=o.lastChild}else p.push(b.createTextNode(f));h&&o.removeChild(h),k.appendChecked||m.grep(ua(p,"input"),va),q=0;while(f=p[q++])if((!d||-1===m.inArray(f,d))&&(g=m.contains(f.ownerDocument,f),h=ua(o.appendChild(f),"script"),g&&za(h),c)){e=0;while(f=h[e++])oa.test(f.type||"")&&c.push(f)}return h=null,o},cleanData:function(a,b){for(var d,e,f,g,h=0,i=m.expando,j=m.cache,l=k.deleteExpando,n=m.event.special;null!=(d=a[h]);h++)if((b||m.acceptData(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)n[e]?m.event.remove(d,e):m.removeEvent(d,e,g.handle);j[f]&&(delete j[f],l?delete d[i]:typeof d.removeAttribute!==K?d.removeAttribute(i):d[i]=null,c.push(f))}}}),m.fn.extend({text:function(a){return V(this,function(a){return void 0===a?m.text(this):this.empty().append((this[0]&&this[0].ownerDocument||y).createTextNode(a))},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wa(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wa(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?m.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||m.cleanData(ua(c)),c.parentNode&&(b&&m.contains(c.ownerDocument,c)&&za(ua(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&m.cleanData(ua(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&m.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return m.clone(this,a,b)})},html:function(a){return V(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(fa,""):void 0;if(!("string"!=typeof a||ma.test(a)||!k.htmlSerialize&&ga.test(a)||!k.leadingWhitespace&&ha.test(a)||ra[(ja.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(ia,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(m.cleanData(ua(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,m.cleanData(ua(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,n=this,o=l-1,p=a[0],q=m.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&na.test(p))return this.each(function(c){var d=n.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(i=m.buildFragment(a,this[0].ownerDocument,!1,this),c=i.firstChild,1===i.childNodes.length&&(i=c),c)){for(g=m.map(ua(i,"script"),xa),f=g.length;l>j;j++)d=i,j!==o&&(d=m.clone(d,!0,!0),f&&m.merge(g,ua(d,"script"))),b.call(this[j],d,j);if(f)for(h=g[g.length-1].ownerDocument,m.map(g,ya),j=0;f>j;j++)d=g[j],oa.test(d.type||"")&&!m._data(d,"globalEval")&&m.contains(h,d)&&(d.src?m._evalUrl&&m._evalUrl(d.src):m.globalEval((d.text||d.textContent||d.innerHTML||"").replace(qa,"")));i=c=null}return this}}),m.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){m.fn[a]=function(a){for(var c,d=0,e=[],g=m(a),h=g.length-1;h>=d;d++)c=d===h?this:this.clone(!0),m(g[d])[b](c),f.apply(e,c.get());return this.pushStack(e)}});var Ca,Da={};function Ea(b,c){var d,e=m(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:m.css(e[0],"display");return e.detach(),f}function Fa(a){var b=y,c=Da[a];return c||(c=Ea(a,b),"none"!==c&&c||(Ca=(Ca||m("