• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ database类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中database的典型用法代码示例。如果您正苦于以下问题:C++ database类的具体用法?C++ database怎么用?C++ database使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: do_update_set

static int
do_update_set(const symboldb_options &opt, database &db, char **argv)
{
  database::package_set_id set = db.lookup_package_set(opt.set_name.c_str());
  if (set == database::package_set_id()) {
    fprintf(stderr, "error: package set \"%s\" does not exist\n",
	    opt.set_name.c_str());
    return 1;
  }

  typedef std::vector<database::package_id> pset;
  pset ids;
  {
    package_set_consolidator<database::package_id> psc;
    if (!load_rpms(opt, db, argv, psc)) {
      return 1;
    }
    ids = psc.values();
  }

  db.txn_begin();
  {
    database::advisory_lock lock
      (db.lock(database::PACKAGE_SET_LOCK_TAG, set.value()));
    if (db.update_package_set(set, ids)) {
      finalize_package_set(opt, db, set);
    }
  }
  db.txn_commit();
  return 0;
}
开发者ID:pombredanne,项目名称:symboldb,代码行数:31,代码来源:symboldb.cpp


示例2: init_DB_level

void isomorph::init_DB_level(database &D, INT level, INT verbose_level)
{
	INT f_v = (verbose_level >= 1);
	btree B1, B2;
	INT f_compress = TRUE;
	INT f_duplicatekeys = TRUE;
	INT i;

	if (f_v) {
		cout << "isomorph::init_DB_level level=" << level << endl;
		}
	sprintf(fname_db_level, "%sstarter_lvl_%ld.db", prefix, level);
	sprintf(fname_db_level_idx1, "%sstarter_lvl_%ld_a.idx", prefix, level);
	sprintf(fname_db_level_idx2, "%sstarter_lvl_%ld_b.idx", prefix, level);
	sprintf(fname_db_level_ge, "%sstarter_lvl_%ld_ge.bin", prefix, level);

	D.init(fname_db_level, VECTOR, f_compress);
	
	B1.init(fname_db_level_idx1, f_duplicatekeys, 0 /* btree_idx */);
	B1.add_key_INT4(0, 0); 
	D.btree_access().append(B1);

	B2.init(fname_db_level_idx2, f_duplicatekeys, 1 /* btree_idx */);
		// 2 up to 2+level-1 are the values of the starter (of size level)
	for (i = 0; i < level; i++) {
		B2.add_key_INT4(2 + i, 0);
		}
	D.btree_access().append(B2);
}
开发者ID:SALAM2016,项目名称:orbiter,代码行数:29,代码来源:isomorph_database.C


示例3: pay_worker

void refund_worker_type::pay_worker(share_type pay, database& db)
{
   total_burned += pay;
   db.modify(db.get(asset_id_type()).dynamic_data(db), [pay](asset_dynamic_data_object& d) {
      d.current_supply -= pay;
   });
}
开发者ID:emfrias,项目名称:graphene,代码行数:7,代码来源:worker_object.cpp


示例4: do_create_set

static int
do_create_set(const symboldb_options &opt, database &db, char **argv)
{
  if (db.lookup_package_set(opt.set_name.c_str())
      != database::package_set_id()) {
    fprintf(stderr, "error: package set \"%s\" already exists\n",
	    opt.set_name.c_str());
    return 1;
  }

  typedef std::vector<database::package_id> pset;
  pset ids;
  {
    package_set_consolidator<database::package_id> psc;
    if (!load_rpms(opt, db, argv, psc)) {
      return 1;
    }
    ids = psc.values();
  }

  db.txn_begin();
  database::package_set_id set =
    db.create_package_set(opt.set_name.c_str());
  if (db.update_package_set(set, ids)) {
    finalize_package_set(opt, db, set);
  }
  db.txn_commit();
  return 0;
}
开发者ID:pombredanne,项目名称:symboldb,代码行数:29,代码来源:symboldb.cpp


示例5: load_zip

static void
load_zip(database &db,
	 database::contents_id cid, const rpm_file_entry &file)
{
  zip_file zip(&file.contents);
  std::vector<unsigned char> data;
  while (true) {
    try {
      if (!zip.next()) {
	break;
      }
    } catch (os_exception &e) {
      // FIXME: Use proper, zip_file-specific exception.
      // zip.name() is not necessarily valid at this point.
      db.add_java_error(cid, e.what(), "");
      // Exit the loop because the file is likely corrupted significantly.
      break;
    }
    try {
      zip.data(data);
    } catch (os_exception &e) {
      // FIXME: Use proper, zip_file-specific exception.
      db.add_java_error(cid, e.what(), zip.name());
    }
    if (java_class::has_signature(data)) {
      try {
	java_class jc(&data);
	db.add_java_class(cid, jc);
      } catch (java_class::exception &e) {
	db.add_java_error(cid, e.what(), zip.name());
      }
    }
  }
}
开发者ID:pombredanne,项目名称:symboldb,代码行数:34,代码来源:rpm_load.cpp


示例6: apply

 void apply(database &db, const operation &o, const options_type &opts) {
     auto undo_session = db.start_undo_session(!(opts &
                                                 skip_undo_operation));
     db.pre_apply_operation(o);
     o.visit(apply_operation_visitor(db, opts));
     db.post_apply_operation(o);
     undo_session.squash();
 }
开发者ID:,项目名称:,代码行数:8,代码来源:


示例7: add_solution

solution_id add_solution(database& db, assignment_id assignment, std::vector<student_id> solvers,
		std::vector<task> editied_tasks) {
	auto id = db.new_solution_id();
	for(auto solver: solvers) {
		db.get_student(solver).add_solution(id);
	}
	auto tmp = solution{assignment, id, std::move(solvers), std::move(editied_tasks)};
	db.add_solution(std::move(tmp));
	return id;
}
开发者ID:Florianjw,项目名称:owl,代码行数:10,代码来源:solution.cpp


示例8: do_show_soname_conflicts

static int
do_show_soname_conflicts(const symboldb_options &opt, database &db)
{
  database::package_set_id pset = db.lookup_package_set(opt.set_name.c_str());
  if (pset > database::package_set_id()) {
    db.print_elf_soname_conflicts(pset);
    return 0;
  } else {
    fprintf(stderr, "error: invalid package set: %s\n", opt.set_name.c_str());
    return 1;
  }
}
开发者ID:pombredanne,项目名称:symboldb,代码行数:12,代码来源:symboldb.cpp


示例9: add_files

static void
add_files(const symboldb_options &opt, database &db, python_analyzer &pya,
	  const rpm_package_info &pkginfo, database::package_id pkg,
	  const char *rpm_path, rpm_file_entry &file)
{
  std::vector<unsigned char> digest;
  std::vector<unsigned char> preview;
  prepare_load(rpm_path, file, digest, preview);

  file.infos.front().normalize_name();

  database::file_id fid;
  database::contents_id cid;
  database::attribute_id aid;
  bool added;
  int contents_length;
  db.add_file(pkg, file.infos.front(), digest, preview, fid, cid,
	      added, contents_length);

  bool looks_like_python =
    unpack_files(pkginfo) && is_python_path(file.infos.front());

  if (file.infos.size() > 1) {
    assert(!file.infos.front().ghost());
    for (std::vector<rpm_file_info>::iterator
	 p = file.infos.begin() + 1, end = file.infos.end();
	 p != end; ++p) {
      assert(!p->ghost());
      p->normalize_name();
      aid = db.intern_file_attribute(*p);
      db.add_file(pkg, p->name, p->mtime, p->ino, cid, aid);
      looks_like_python = looks_like_python
	|| (unpack_files(pkginfo) && is_python_path(file.infos.front()));
    }
  }

  if (added) {
    if (unpack_files(pkginfo)) {
      do_load_formats(opt, db, pya, cid, file);
    }
  } else {
    // We might recognize additonal files as Python files if they are
    // loaded later under a different name.
    if (looks_like_python) {
      load_python(opt, db, pya, cid, file);
    }
  }
  // If the contents in the database was truncated, update it with the
  // longer version.
  if (static_cast<size_t>(contents_length) < preview.size()) {
    db.update_contents_preview(cid, preview);
  }
}
开发者ID:pombredanne,项目名称:symboldb,代码行数:53,代码来源:rpm_load.cpp


示例10: do_run_example

static int
do_run_example(const symboldb_options &opt, database &db, char **argv)
{
  int errors = 0;
  while (*argv) {
    file_handle file(*argv, "r");
    file_handle::line line_handle;
    std::string current;
    unsigned lineno = 0;
    unsigned start_lineno;
    try {
      while (file.getline(line_handle)) {
	++lineno;
	std::string line(line_handle.str());
	bool start = current.empty();
	if (starts_with(line, "    ")) {
	  current += "      ";
	  current.append(line.begin() + 4, line.end());
	} else if (starts_with(line, "\t")) {
	  current.append(line.begin() + 1, line.end());
	} else if (!current.empty()) {
	  if (opt.output != symboldb_options::quiet) {
	    fprintf(stderr, "info: executing %s:%u\n", *argv, start_lineno);
	  }
	  db.exec_sql(current.c_str());
	  current.clear();
	  start = false;
	} else {
	  start = false;
	}
	if (start && !current.empty()) {
	  start_lineno = lineno;
	}
      }
      if (!current.empty()) {
	if (opt.output != symboldb_options::quiet) {
	  fprintf(stderr, "info: executing %s:%u\n", *argv, start_lineno);
	}
	db.exec_sql(current.c_str());
      }
    } catch (pg_exception &e) {
      dump("error: ", e, stderr);
      ++errors;
    }
    ++argv;
  }
  if (errors > 0) {
    return 1;
  } else {
    return 0;
  }
}
开发者ID:pombredanne,项目名称:symboldb,代码行数:52,代码来源:symboldb.cpp


示例11: get_all_tables_numbers

// Return a sorted vector of all table numbers.
std::vector<table::Number> get_all_tables_numbers(database const& table_file)
{
    int const tables_count = table_file.tables_count();
    std::vector<table::Number> numbers;
    numbers.reserve(tables_count);
    for(int i = 0; i != tables_count; ++i)
        {
        numbers.push_back(table_file.get_nth_table(i).number());
        }

    std::sort(numbers.begin(), numbers.end());

    return numbers;
}
开发者ID:vadz,项目名称:lmi.new,代码行数:15,代码来源:rate_table_tool.cpp


示例12: load_rpm_internal

static database::package_id
load_rpm_internal(const symboldb_options &opt, database &db,
		  const char *rpm_path, rpm_package_info &pkginfo)
{
  rpm_parser rpmparser(rpm_path);
  python_analyzer pya;
  pkginfo = rpmparser.package();
  // We can destroy the lock immediately because we are running in a
  // transaction.
  lock_rpm(db, pkginfo);
  rpm_file_entry file;

  database::package_id pkg;
  if (!db.intern_package(rpmparser.package(), pkg)) {
    if (opt.output != symboldb_options::quiet) {
      fprintf(stderr, "info: skipping %s from %s\n",
	      rpmparser.nevra(), rpm_path);
    }
    return pkg;
  }

  if (opt.output != symboldb_options::quiet) {
    fprintf(stderr, "info: loading %s from %s\n", rpmparser.nevra(), rpm_path);
  }

  dependencies(opt, db, pkg, rpmparser);
  scripts(opt, db, pkg, rpmparser);
  triggers(opt, db, pkg, rpmparser);

  // FIXME: We should not read arbitrary files into memory, only ELF
  // files.
  while (rpmparser.read_file(file)) {
    if (file.infos.size() > 1) {
      // Hard links, so this is a real file.
      add_files(opt, db, pya, pkginfo, pkg, rpm_path, file);
      continue;
    }

    assert(!file.infos.empty());
    rpm_file_info &info(file.infos.front());
    if (info.is_directory()) {
      db.add_directory(pkg, info);
    } else if (info.is_symlink()) {
      db.add_symlink(pkg, info);
    } else {
      add_files(opt, db, pya, pkginfo, pkg, rpm_path, file);
    }
  }
  return pkg;
}
开发者ID:pombredanne,项目名称:symboldb,代码行数:50,代码来源:rpm_load.cpp


示例13: rpm_load

database::package_id
rpm_load(const symboldb_options &opt, database &db,
	 const char *path, rpm_package_info &info,
	 const checksum *expected, const char *url)
{
  if (expected && (expected->type != hash_sink::sha256
		   && expected->type != hash_sink::sha1)) {
    raise<std::runtime_error>("unsupported hash type");
  }

  // Unreferenced RPMs should not be visible to analyzers, so we can
  // load each RPM in a separate transaction.  We make a synchronous
  // commit when referencing the RPM data, so a non-synchronous commit
  // is sufficient here.
  db.txn_begin_no_sync();
  database::package_id pkg = load_rpm_internal(opt, db, path, info);

  hash_sink sha256(hash_sink::sha256);
  hash_sink sha1(hash_sink::sha1);
  {
    fd_handle handle;
    handle.open_read_only(path);
    fd_source source(handle.get());
    tee_sink tee(&sha256, &sha1);
    copy_source_to_sink(source, tee);
  }
  assert(sha256.octets() == sha1.octets());

  std::vector<unsigned char> digest;
  sha256.digest(digest);
  db.add_package_digest(pkg, digest, sha256.octets());
  if (expected && expected->type == hash_sink::sha256
      && expected->value != digest) {
    raise<std::runtime_error>("checksum mismatch");
  }
  sha1.digest(digest);
  db.add_package_digest(pkg, digest, sha1.octets());
  if (expected && expected->type == hash_sink::sha1
      && expected->value != digest) {
    raise<std::runtime_error>("checksum mismatch");
  }
  if (url != NULL) {
    db.add_package_url(pkg, url);
  }

  db.txn_commit();
  return pkg;
}
开发者ID:pombredanne,项目名称:symboldb,代码行数:48,代码来源:rpm_load.cpp


示例14: _is_authorized_asset

bool _is_authorized_asset(
   const database& d,
   const account_object& acct,
   const asset_object& asset_obj)
{
   if( acct.allowed_assets.valid() )
   {
      if( acct.allowed_assets->find( asset_obj.id ) == acct.allowed_assets->end() )
         return false;
      // must still pass other checks even if it is in allowed_assets
   }

   for( const auto id : acct.blacklisting_accounts )
   {
      if( asset_obj.options.blacklist_authorities.find(id) != asset_obj.options.blacklist_authorities.end() )
         return false;
   }

   if( d.head_block_time() > HARDFORK_415_TIME )
   {
      if( asset_obj.options.whitelist_authorities.size() == 0 )
         return true;
   }

   for( const auto id : acct.whitelisting_accounts )
   {
      if( asset_obj.options.whitelist_authorities.find(id) != asset_obj.options.whitelist_authorities.end() )
         return true;
   }

   return false;
}
开发者ID:8001800,项目名称:graphene,代码行数:32,代码来源:is_authorized_asset.cpp


示例15: expire

void
expire(const symboldb_options &opt, database &db)
{
  if (opt.output != symboldb_options::quiet) {
    fprintf(stderr, "info: expiring URL cache\n");
  }
  db.expire_url_cache();

  if (opt.output != symboldb_options::quiet) {
    fprintf(stderr, "info: expiring unreferenced packages\n");
  }
  db.expire_packages();

  if (opt.output != symboldb_options::quiet) {
    fprintf(stderr, "info: expiring file contents\n");
  }
  db.expire_file_contents();

  if (opt.output != symboldb_options::quiet) {
    fprintf(stderr, "info: expiring java classes\n");
  }
  db.expire_java_classes();

  if (opt.output != symboldb_options::quiet) {
    fprintf(stderr, "info: expiring unused RPMs\n");
  }
  {
    typedef std::vector<std::vector<unsigned char> > digvec;
    std::tr1::shared_ptr<file_cache> fcache(opt.rpm_cache());
    digvec fcdigests;
    fcache->digests(fcdigests);
    std::sort(fcdigests.begin(), fcdigests.end());
    digvec dbdigests;
    db.referenced_package_digests(dbdigests);
    digvec result;
    std::set_difference(fcdigests.begin(), fcdigests.end(),
			dbdigests.begin(), dbdigests.end(),
			std::back_inserter(result));
    fd_handle dir;
    dir.open_directory(opt.rpm_cache_path().c_str());
    for (digvec::iterator p = result.begin(), end = result.end();
	 p != end; ++p) {
      dir.unlinkat(base16_encode(p->begin(), p->end()).c_str(), 0);
    }
  }
}
开发者ID:pombredanne,项目名称:symboldb,代码行数:46,代码来源:expire.cpp


示例16: open_test_database

void open_test_database( database& db, const fc::path& dir )
{
   database::open_args args;
   args.data_dir = dir;
   args.shared_mem_dir = dir;
   args.initial_supply = INITIAL_TEST_SUPPLY;
   args.shared_file_size = TEST_SHARED_MEM_SIZE;
   db.open( args );
}
开发者ID:superman-dongyanjie,项目名称:steem,代码行数:9,代码来源:block_tests.cpp


示例17: dependencies

static void
dependencies(const symboldb_options &, database &db,
	     database::package_id pkg, rpm_parser &rpmparser)
{
  const std::vector<rpm_dependency> &deps(rpmparser.dependencies());
  for (std::vector<rpm_dependency>::const_iterator
	 p = deps.begin(), end = deps.end(); p != end; ++p) {
    db.add_package_dependency(pkg, *p);
  }
}
开发者ID:pombredanne,项目名称:symboldb,代码行数:10,代码来源:rpm_load.cpp


示例18: serializedChoices

  part::part(const database& db, sqlite3_stmt* row)
  {
    int id = sqlite3_column_int(row, 0);

    type_ = static_cast<part_type>(sqlite3_column_int(row, 3));

    switch (type_)
    {
      case part_type::noun_phrase:
      {
        new(&noun_phrase_.role) std::string(reinterpret_cast<const char*>(sqlite3_column_blob(row, 4)));
        new(&noun_phrase_.selrestrs) std::set<std::string>(db.selrestrs(id));
        new(&noun_phrase_.synrestrs) std::set<std::string>(db.synrestrs(id));

        break;
      }

      case part_type::preposition:
      {
        std::string serializedChoices(reinterpret_cast<const char*>(sqlite3_column_blob(row, 5)));
        new(&preposition_.choices) std::vector<std::string>(split<std::vector<std::string>>(serializedChoices, ","));
        
        preposition_.literal = (sqlite3_column_int(row, 6) == 1);

        break;
      }

      case part_type::literal:
      {
        new(&literal_) std::string(reinterpret_cast<const char*>(sqlite3_column_blob(row, 7)));

        break;
      }

      case part_type::verb:
      case part_type::adjective:
      case part_type::adverb:
      case part_type::invalid:
      {
        break;
      }
    }
  }
开发者ID:hatkirby,项目名称:verbly,代码行数:43,代码来源:part.cpp


示例19: with_skip_flags

void with_skip_flags(
   database& db,
   uint32_t skip_flags,
   Lambda callback )
{
   node_property_object& npo = db.node_properties();
   skip_flags_restorer restorer( npo, npo.skip_flags );
   npo.skip_flags = skip_flags;
   callback();
   return;
}
开发者ID:elmato,项目名称:graphene,代码行数:11,代码来源:db_with.hpp


示例20: scripts

static void
scripts(const symboldb_options &, database &db,
	database::package_id pkg, rpm_parser &rpmparser)
{
  std::vector<rpm_script> scripts;
  rpmparser.scripts(scripts);
  for (std::vector<rpm_script>::const_iterator
	 p = scripts.begin(), end = scripts.end(); p != end; ++p) {
    db.add_package_script(pkg, *p);
  }
}
开发者ID:pombredanne,项目名称:symboldb,代码行数:11,代码来源:rpm_load.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ database_type类代码示例发布时间:2022-05-31
下一篇:
C++ data_type类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap