当前位置: 首页>>代码示例>>C++>>正文


C++ path::leaf方法代码示例

本文整理汇总了C++中fs::path::leaf方法的典型用法代码示例。如果您正苦于以下问题:C++ path::leaf方法的具体用法?C++ path::leaf怎么用?C++ path::leaf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fs::path的用法示例。


在下文中一共展示了path::leaf方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: write_ledger_as_pdf

std::string write_ledger_as_pdf(Ledger const& ledger, fs::path const& filepath)
{
    throw_if_interdicted(ledger);

    fs::path print_dir(configurable_settings::instance().print_directory());

    fs::path real_filepath(orthodox_filename(filepath.leaf()));
    LMI_ASSERT(fs::portable_name(real_filepath.string()));

    if(contains(global_settings::instance().pyx(), "xml"))
        {
        fs::path xml_file = unique_filepath(print_dir / real_filepath, ".xml");

        fs::ofstream ofs(xml_file, ios_out_trunc_binary());
        ledger.write(ofs);
        ofs.close();
        if(!ofs.good())
            {
            fatal_error()
                << "Unable to write output file '"
                << xml_file
                << "'."
                << LMI_FLUSH
                ;
            }
        }

    fs::path xml_fo_file = unique_filepath(print_dir / real_filepath, ".fo.xml");

    fs::ofstream ofs(xml_fo_file, ios_out_trunc_binary());
    ledger.write_xsl_fo(ofs);
    ofs.close();
    if(!ofs.good())
        {
        fatal_error()
            << "Unable to write output file '"
            << xml_fo_file
            << "'."
            << LMI_FLUSH
            ;
        }

    fs::path pdf_out_file = unique_filepath(print_dir / real_filepath, ".pdf");

    std::ostringstream oss;
    oss
        << configurable_settings::instance().xsl_fo_command()
        << " -fo "  << '"' << xml_fo_file  << '"'
        << " -pdf " << '"' << pdf_out_file << '"'
        ;
    system_command(oss.str());
    return pdf_out_file.string();
}
开发者ID:vadz,项目名称:lmi,代码行数:53,代码来源:ledger_xsl.cpp

示例2: is_binary_file

bool bcp_implementation::is_binary_file(const fs::path& p)
{
   if(m_cvs_mode || m_svn_mode)
   {
      std::map<fs::path, bool, path_less>::iterator pos = m_cvs_paths.find(p);
      if(pos != m_cvs_paths.end()) return pos->second;
   }
   static const boost::regex e(
      ".*\\."
      "(?:"
         "c|cxx|cpp|h|hxx|hpp|inc|html?|css|mak|in"
      ")"
      "|"
      "(Jamfile|makefile|configure)",
      boost::regex::perl | boost::regex::icase);
   return !boost::regex_match(p.leaf(), e);

}
开发者ID:dchandran,项目名称:evolvenetworks,代码行数:18,代码来源:file_types.cpp

示例3: init_library_scanner

static void init_library_scanner(const fs::path& p, bool cvs_mode, const std::string& libname, bool recurse = false)
{
   /*
   if(free_function_names.count(libname) == 0)
   {
      free_function_names[libname] = "[\\x0]";
      class_names[libname] = "[\\x0]";
      variable_names[libname] = "[\\x0]";
   }
   */
   //
   // Don't add files created by build system:
   //
   if((p.leaf() == "bin") || (p.leaf() == "bin-stage"))
      return; 
   //
   // Don't add version control directories:
   //
   if((p.leaf() == "CVS") || (p.leaf() == ".svn"))
      return; 
   //
   // don't add directories not under version control:
   //
   if(cvs_mode && !fs::exists(p / "CVS/Entries"))
      return;
   if(cvs_mode && !fs::exists(p / ".svn/entries"))
      return;
   //
   // Enumerate files and directories:
   //
   fs::directory_iterator i(p);
   fs::directory_iterator j;
   while(i != j)
   {
      if(fs::is_directory(*i))
         init_library_scanner(*i, cvs_mode, libname, true);
      if(bcp_implementation::is_source_file(*i))
      {
         static boost::regex function_scanner(
            "(?|"                       // Branch reset group
               "(?:\\<\\w+\\>[^>;{},:]*)"  // Return type
               "(?:"
                  "(\\<\\w+\\>)"           // Maybe class name
                  "\\s*"
                  "(?:<[^>;{]*>)?"         // Maybe template specialisation
                  "::\\s*)?"
               "(\\<(?!throw|if|while|for|catch)\\w+\\>)" // function name
               "\\s*"
               "\\("
                  "[^\\(\\);{}]*"          // argument list
               "\\)"
               "\\s*"
               "\\{"                       // start of definition
            "|"
               "(\\<\\w+\\>)"              // Maybe class name
               "\\s*"
               "(?:<[^>;{]*>)?"            // Maybe template specialisation
               "::\\s*"
               "~?\\1"                     // function name, same as class name
               "\\s*"
               "\\("
                  "[^\\(\\);{}]*"          // argument list
               "\\)"
               "\\s*"
               "\\{"                       // start of definition
            ")"                            // end branch reset
            );
         fileview view(*i);
         boost::regex_iterator<const char*> a(view.begin(), view.end(), function_scanner);
         boost::regex_iterator<const char*> b;
         while(a != b)
         {
            if((*a)[1].matched)
            {
               std::string n = a->str(1);
               class_names[libname].insert(n);
            }
            else
            {
               std::string n = a->str(2);
               free_function_names[libname].insert(n);
            }
            ++a;
         }
      }
      ++i;
   }

   if(recurse == false)
   {
      //
      // Build the regular expressions:
      //
      const char* e1 = 
         "^(?>[[:blank:]]*)(?!#)[^;{}\\r\\n]*"
         "(?|"
         "(?:class|struct)[^:;{}#]*"
         "(";
      // list of class names goes here...
      const char* e2 = 
//.........这里部分代码省略.........
开发者ID:0xDEC0DE8,项目名称:mcsema,代码行数:101,代码来源:add_dependent_lib.cpp

示例4: copy_path

void bcp_implementation::copy_path(const fs::path& p)
{
   assert(!fs::is_directory(m_boost_path / p));
   if(fs::exists(m_dest_path / p))
   {
      std::cout << "Copying (and overwriting) file: " << p.string() << "\n";
     fs::remove(m_dest_path / p);
   }
   else
      std::cout << "Copying file: " << p.string() << "\n";
   //
   // create the path to the new file if it doesn't already exist:
   //
   create_path(p.branch_path());
   //
   // do text based copy if requested:
   //
   if(p.leaf() == "Jamroot")
   {
      static std::vector<char> v1, v2;
      v1.clear();
      v2.clear();
      std::ifstream is((m_boost_path / p).c_str());
      std::copy(std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>(), std::back_inserter(v1));

      static boost::regex libname_matcher;
      if(libname_matcher.empty())
      {
         libname_matcher.assign("boost_");
      }

      regex_replace(std::back_inserter(v2), v1.begin(), v1.end(), libname_matcher, m_namespace_name + "_");
      std::swap(v1, v2);
      v2.clear();

      std::ofstream os;
      if(m_unix_lines)
         os.open((m_dest_path / p).c_str(), std::ios_base::binary | std::ios_base::out);
      else
         os.open((m_dest_path / p).c_str(), std::ios_base::out);
      os.write(&*v1.begin(), v1.size());
      os.close();
   }
   else if(m_namespace_name.size() && m_lib_names.size() && is_jam_file(p))
   {
      static std::vector<char> v1, v2;
      v1.clear();
      v2.clear();
      std::ifstream is((m_boost_path / p).c_str());
      std::copy(std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>(), std::back_inserter(v1));

      static boost::regex libname_matcher;
      if(libname_matcher.empty())
      {
         std::string re = "\\<";
         re += *m_lib_names.begin();
         for(std::set<std::string>::const_iterator i = ++m_lib_names.begin(); i != m_lib_names.end(); ++i)
         {
            re += "|" + *i;
         }
         re += "\\>";
         libname_matcher.assign(re);
      }

      regex_replace(std::back_inserter(v2), v1.begin(), v1.end(), libname_matcher, get_new_library_name(m_namespace_name));
      std::swap(v1, v2);
      v2.clear();

      std::ofstream os;
      if(m_unix_lines)
         os.open((m_dest_path / p).c_str(), std::ios_base::binary | std::ios_base::out);
      else
         os.open((m_dest_path / p).c_str(), std::ios_base::out);
      os.write(&*v1.begin(), v1.size());
      os.close();
   }
   else if(m_namespace_name.size() && is_source_file(p))
   {
      //
      // v1 hold the current content, v2 is temp buffer.
      // Each time we do a search and replace the new content 
      // ends up in v2: we then swap v1 and v2, and clear v2.
      //
      static std::vector<char> v1, v2;
      v1.clear();
      v2.clear();
      std::ifstream is((m_boost_path / p).c_str());
      std::copy(std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>(), std::back_inserter(v1));

      static const boost::regex namespace_matcher(
         "(?|"
            "(namespace\\s+)boost(_\\w+)?(?:(\\s*::\\s*)phoenix)?"
         "|"
            "(namespace\\s+)(adstl|phoenix|rapidxml)\\>"
         "|"
            "()\\<boost((?:_(?!intrusive_tags)\\w+)?\\s*(?:::))(?:(\\s*)phoenix)?"
         "|"
            "()\\<((?:adstl|phoenix|rapidxml)\\s*(?:::))"
         "|"
         "(namespace\\s+\\w+\\s*=\\s*(?:::\\s*)?)boost(_\\w+)?(?:(\\s*::\\s*)phoenix)?"
//.........这里部分代码省略.........
开发者ID:AlexanderGarmash,项目名称:boost-ndk,代码行数:101,代码来源:copy_path.cpp

示例5: FileNameMatches

bool FileNameMatches(
	const char*		inPattern,
	const fs::path&		inFile)
{
	return FileNameMatches(inPattern, inFile.leaf());
}
开发者ID:BackupTheBerlios,项目名称:japi-svn,代码行数:6,代码来源:MFile.cpp

示例6: name

void CXX_Generator::
generate (po::variables_map const& vm, Schema& schema, fs::path const& file_path)
{
  //Name is the actual file name.
#if BOOST_FILESYSTEM_VERSION == 2
  std::string name (file_path.leaf ());
#else
  std::string name (file_path.filename ().string ());
#endif

  //Stores file suffixes (defaults are .hpp, ipp, and cpp)
  std::string hxx_suffix (vm["cxx-header-suffix"].as<std::string> ());
  std::string ixx_suffix (vm["cxx-inline-suffix"].as<std::string> ());
  std::string cxx_suffix (vm["cxx-source-suffix"].as<std::string> ());

  //Specifies a regular expression of the form pattern/replacement
  //when constructing the file names.
  std::string hxx_expr (vm["cxx-header-regex"].as<std::string> ());
  std::string ixx_expr (vm["cxx-inline-regex"].as<std::string> ());
  std::string cxx_expr (vm["cxx-source-regex"].as<std::string> ());


  //Output file names are named <name>.<suffix>
  std::string hxx_name (regex::perl_s (name, hxx_expr) + hxx_suffix);
  std::string ixx_name (regex::perl_s (name, ixx_expr) + ixx_suffix);
  std::string cxx_name (regex::perl_s (name, cxx_expr) + cxx_suffix);

  //File handlers are created for each file name
  fs::path hxx_path (hxx_name);
  fs::path ixx_path (ixx_name);
  fs::path cxx_path (cxx_name);

  //Files are opened for output.  Note that the inline
  //file is only opened IF the inline_ value is true (otherwise
  //the file is ignored).
  fs::wofstream hxx (hxx_path, std::ios_base::out);
  fs::wofstream ixx;
  fs::wofstream cxx (cxx_path, std::ios_base::out);

  if (!hxx.is_open ())
  {
    wcerr << hxx_name.c_str () << ": error: unable to open in write mode"
          << endl;
    return;
  }


  //Boolean value set to the "cxx-generate-inline" option value
  bool inline_ (vm.count ("cxx-generate-inline"));

  if (inline_)
  {
    ixx.open (ixx_path, std::ios_base::out);

    if (!ixx.is_open ())
    {
      wcerr << ixx_name.c_str () << ": error: unable to open in write mode"
            << endl;
      return;
    }
  }

  if (!cxx.is_open ())
  {
    wcerr << cxx_name.c_str () << ": error: unable to open in write mode"
          << endl;
    return;
  }

  // Banner.
  //
  //Takes in the name of a "banner" file.  This banner, if it exists, will
  //be inserted at the head of the output files.
  {
    using namespace std;

    std::string name (vm["cxx-banner-file"].as<std::string> ());

    fs::wifstream banner;

    if (!name.empty ())
    {
      banner.open (name, ios_base::in | ios_base::binary);

      if (!banner.is_open ())
      {
        wcerr << name.c_str () << ": error: unable to open in read mode"
              << endl;
        return;
      }
    }

    // header
    //
    {
      std::string bn (vm["cxx-header-banner-file"].as<std::string> ());

      if (!bn.empty ())
      {
        fs::wifstream b (bn, ios_base::in | ios_base::binary);
//.........这里部分代码省略.........
开发者ID:DOCGroup,项目名称:XSC,代码行数:101,代码来源:Generator.cpp


注:本文中的fs::path::leaf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。