aboutsummaryrefslogtreecommitdiff
path: root/objectivec/GPBDescriptor.m
diff options
context:
space:
mode:
authorDimitris Koutsogiorgas <dimitris@squareup.com>2016-06-24 17:40:29 -0700
committerDimitris Koutsogiorgas <dimitris@squareup.com>2016-06-26 10:38:58 -0700
commit37ca94f8aed073b70e3d0fae3aab33eac35e3fec (patch)
treef7142f28f46a9c8d85ce7f42db72f8de4a78db13 /objectivec/GPBDescriptor.m
parent325cc42e98b24d8a3a62f3d72a6e1ffdd5ab8ef4 (diff)
downloadprotobuf-37ca94f8aed073b70e3d0fae3aab33eac35e3fec.tar.gz
protobuf-37ca94f8aed073b70e3d0fae3aab33eac35e3fec.tar.bz2
protobuf-37ca94f8aed073b70e3d0fae3aab33eac35e3fec.zip
Get value from text format name in GPBEnumDescriptor
Diffstat (limited to 'objectivec/GPBDescriptor.m')
-rw-r--r--objectivec/GPBDescriptor.m17
1 files changed, 17 insertions, 0 deletions
diff --git a/objectivec/GPBDescriptor.m b/objectivec/GPBDescriptor.m
index 2709737c..90636d3d 100644
--- a/objectivec/GPBDescriptor.m
+++ b/objectivec/GPBDescriptor.m
@@ -745,6 +745,23 @@ uint32_t GPBFieldAlternateTag(GPBFieldDescriptor *self) {
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];