parameters: (extensions)
return_statement: return function
docstring: Returns mapping function from strings to corresponding extensions.
docstring_summary: Returns mapping function from strings to corresponding extensions.
docstring_tokens: Returns mapping function from strings to corresponding extensions .
function: def generate_string_to_extension_mapping(extensions):
      """Returns mapping function from strings to corresponding extensions."""
  
      function = '''
      bool GetExtensionFromString(const char* str, Extension* extension) {{
          static const char* known_ext_strs[] = {{ {strs} }};
          static const Extension known_ext_ids[] = {{ {ids} }};
          const auto b = std::begin(known_ext_strs);
          const auto e = std::end(known_ext_strs);
          const auto found = std::equal_range(
              b, e, str, [](const char* str1, const char* str2) {{
                  return std::strcmp(str1, str2) < 0;
              }});
          if (found.first == e || found.first == found.second) return false;
  
          *extension = known_ext_ids[found.first - b];
          return true;
      }}
      '''.format(strs=', '.join(['"{}"'.format(e) for e in extensions]),
                 ids=', '.join(['Extension::k{}'.format(e) for e in extensions]))
  
      return function
function_tokens: def generate_string_to_extension_mapping ( extensions ) : function = '''
      bool GetExtensionFromString(const char* str, Extension* extension) {{
          static const char* known_ext_strs[] = {{ {strs} }};
          static const Extension known_ext_ids[] = {{ {ids} }};
          const auto b = std::begin(known_ext_strs);
          const auto e = std::end(known_ext_strs);
          const auto found = std::equal_range(
              b, e, str, [](const char* str1, const char* str2) {{
                  return std::strcmp(str1, str2) < 0;
              }});
          if (found.first == e || found.first == found.second) return false;
  
          *extension = known_ext_ids[found.first - b];
          return true;
      }}
      ''' . format ( strs = ', ' . join ( [ '"{}"' . format ( e ) for e in extensions ] ) , ids = ', ' . join ( [ 'Extension::k{}' . format ( e ) for e in extensions ] ) ) return function