<commit_before>// Copyright (c) 2016 <NAME>. All rights reserved.
//
#include <iostream>

#include <boost/filesystem.hpp>
#include <glog/logging.h>

#include "rpc/smf_gen/cpp_generator.h"
#include "rpc/smf_gen/smf_file.h"

DEFINE_bool(print_smf_gen_to_stderr,
            false,
            "prints to stderr the outputs of the generated header");
DEFINE_string(output_path,
              "",
              "prints to stderr the outputs of the generated header");


namespace smf_gen {

bool generate(const flatbuffers::Parser &parser, std::string file_name) {
  smf_file fbfile(parser, file_name);

  std::string header_code =
    get_header_prologue(&fbfile) + get_header_includes(&fbfile)
    + get_header_services(&fbfile) + get_header_epilogue(&fbfile);


  if (FLAGS_print_smf_gen_to_stderr) { std::cerr << header_code << std::endl; }
  if (!FLAGS_output_path.empty()) {
    FLAGS_output_path =
      boost::filesystem::canonical(FLAGS_output_path.c_str()).string();
    if (!flatbuffers::DirExists(FLAGS_output_path.c_str())) {
      LOG(ERROR) << "--output_path specified, but directory: "
                 << FLAGS_output_path << " does not exist;";
      return false;
    }
    boost::filesystem::path p(file_name);
    file_name = p.filename().string();
  }
  const std::string fname = FLAGS_output_path.empty() ?
                              file_name + ".smf.fb.h" :
                              FLAGS_output_path + "/" + file_name + ".smf.fb.h";
  LOG(INFO) << fname;

  return flatbuffers::SaveFile(fname.c_str(), header_code, false);
}

}  // namespace smf_gen
<commit_msg>smf_gen: add correct --output_path description<commit_after>// Copyright (c) 2016 <NAME>. All rights reserved.
//
#include <iostream>

#include <boost/filesystem.hpp>
#include <glog/logging.h>

#include "rpc/smf_gen/cpp_generator.h"
#include "rpc/smf_gen/smf_file.h"

DEFINE_bool(print_smf_gen_to_stderr,
            false,
            "prints to stderr the outputs of the generated header");
DEFINE_string(output_path, "", "output path of the generated files");


namespace smf_gen {

bool generate(const flatbuffers::Parser &parser, std::string file_name) {
  smf_file fbfile(parser, file_name);

  std::string header_code =
    get_header_prologue(&fbfile) + get_header_includes(&fbfile)
    + get_header_services(&fbfile) + get_header_epilogue(&fbfile);


  if (FLAGS_print_smf_gen_to_stderr) { std::cerr << header_code << std::endl; }
  if (!FLAGS_output_path.empty()) {
    FLAGS_output_path =
      boost::filesystem::canonical(FLAGS_output_path.c_str()).string();
    if (!flatbuffers::DirExists(FLAGS_output_path.c_str())) {
      LOG(ERROR) << "--output_path specified, but directory: "
                 << FLAGS_output_path << " does not exist;";
      return false;
    }
    boost::filesystem::path p(file_name);
    file_name = p.filename().string();
  }
  const std::string fname = FLAGS_output_path.empty() ?
                              file_name + ".smf.fb.h" :
                              FLAGS_output_path + "/" + file_name + ".smf.fb.h";
  LOG(INFO) << fname;

  return flatbuffers::SaveFile(fname.c_str(), header_code, false);
}

}  // namespace smf_gen

{'fraction_non_alphanumeric': 0.13528855250709557, 'fraction_numerical': 0.002522863450015768, 'mean_word_length': 3.4055555555555554, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5487821', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1048, 'n_words': 199}