def METHOD_NAME(items, class_name, install_dir, header_path, output_scope):
    namespaces = output_scope.split("::")
    file_name = "%s.cpp" % class_name
    output_file = os.path.join(install_dir, file_name)
    with open(output_file, "w+") as outf:
        outf.write("// Copyright 2015-present Facebook. All Rights Reserved.\n")
        outf.write("// ** AUTOGENERATED FILE. DO NOT HAND-EDIT **\n\n")
        outf.write('#include "%s/%s.h"\n\n' % (header_path, class_name))
        outf.write("#include <stdexcept>\n\n")
        for ns in namespaces:
            outf.write("namespace %s { " % ns)
        outf.write("\n\n")
        # const string names
        for item in items:
            outf.write(
                'static const std::string k%s%s = "%s";\n'
                % (class_name, item[0], item[1])
            )
        # generate enum to string convert function
        outf.write(
            "const std::string& get%sString(%s type) {\n" % (class_name, class_name)
        )
        outf.write('  static const std::string k%sInvalidType = "";\n' % class_name)
        outf.write("\n  switch (type) {\n")
        for item in items:
            outf.write(
                "    case %s::%s : return k%s%s;\n"
                % (class_name, item[0], class_name, item[0])
            )
        outf.write("  }\n")
        outf.write("  return k%sInvalidType;\n" % class_name)
        outf.write("};\n\n")
        outf.write(
            "  %s get%sFromString(const std::string& str) {\n"
            % (class_name, class_name)
        )
        for item in items:
            outf.write(
                "  if (str == k%s%s)  return %s::%s;\n"
                % (class_name, item[0], class_name, item[0])
            )
        outf.write(
            " throw std::invalid_argument"
            ' ("No matching %s from string");\n' % (class_name)
        )
        outf.write("};\n")
        outf.write("\n\n")
        for _ in namespaces:
            outf.write("}")
        outf.write("\n\n")