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


C++ Exception::append方法代码示例

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


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

示例1: throw

void Exception::append(const Exception &another, size_t startDepth) throw() {
	Exception base;

	if (this == &another) {
		base.append(another, startDepth);
		append(base, 0);
		return;
	}

	size_t baseEntryCount = 0;
	if (!isEmpty()) {
		assert(base.isEmpty());

		base.append(*this, 0);
		baseEntryCount = 1 + base.maxDepth_;

		clear();
	}

	size_t subEntryCount = baseEntryCount + (another.maxDepth_ - startDepth);
	if (subEntryCount > 0) {
		subEntries_ =
				static_cast<Entry*>(allocate(sizeof(Entry) * subEntryCount));
		if (subEntries_ == NULL) {
			subEntryCount = 0;
		}
	}
	maxDepth_ = subEntryCount;

	for (size_t i = 0; i <= subEntryCount; i++) {
		Entry &dest = (i > 0 ? subEntries_[i - 1] : topEntry_);

		const Entry *src;
		if (i < baseEntryCount) {
			src = base.getEntryAt(i);
		}
		else {
			src = another.getEntryAt(startDepth + (i - baseEntryCount));
		}

		setEntry(dest, *src);
	}

	fillWhat();
}
开发者ID:Naoyuki-Yatsuda,项目名称:griddb_nosql,代码行数:45,代码来源:type.cpp

示例2: se

/** Constructor.
 * @param config Fawkes configuration
 */
BlackBoardLoggerPlugin::BlackBoardLoggerPlugin(Configuration *config)
  : Plugin(config)
{
  std::set<std::string> ifaces;

  std::string prefix = "/fawkes/bblogger/";
  std::string replay_prefix = "/fawkes/bblogreplay/";

  std::string scenario = "";
  try {
    scenario = config->get_string((prefix + "scenario").c_str());
  } catch (Exception &e) {
    e.append("No scenario defined, configure %sscenario", prefix.c_str());
    throw;
  }

  /*
  bool generate_replay_config = false;
  try {
    generate_replay_config = config->get_bool((prefix + "generate_replay_config").c_str());
  } catch (Exception &e) {} // ignored, use default set above
  */

  std::string scenario_prefix = prefix + scenario + "/";
  std::string ifaces_prefix   = scenario_prefix + "interfaces/";

  std::string logdir = LOGDIR;
  bool        buffering = true;
  bool        flushing = false;
  try {
    logdir = config->get_string((scenario_prefix + "logdir").c_str());
  } catch (Exception &e) { /* ignored, use default set above */ }
  try {
    buffering = config->get_bool((scenario_prefix + "buffering").c_str());
  } catch (Exception &e) { /* ignored, use default set above */ }
  try {
    flushing = config->get_bool((scenario_prefix + "flushing").c_str());
  } catch (Exception &e) { /* ignored, use default set above */ }

  struct stat s;
  int err = stat(logdir.c_str(), &s);
  if (err != 0) {
    char buf[1024];
    Exception se ("Cannot access logdir %s (%s)",
		  logdir.c_str(), strerror_r(errno, buf, 1024));
    if (mkdir(logdir.c_str(), 0755) != 0) {
      se.append("Failed to create log directory (%s)",
		strerror_r(errno, buf, 1024));
      throw se;
    }
  } else if ( ! S_ISDIR(s.st_mode) ) {
    throw Exception("Logdir path %s is not a directory", logdir.c_str());
  }

  // We do not have the framework clock available at this point, but for the start
  // time of the log we are only interested in the system time anyway
  Time start;

  char date[21];
  Time now;
  struct tm *tmp = localtime(&(now.get_timeval()->tv_sec));
  strftime(date, 21, "%F-%H-%M-%S", tmp);
  std::string replay_cfg_prefix = replay_prefix + scenario + "-" + date + "/logs/";

  Configuration::ValueIterator *i = config->search(ifaces_prefix.c_str());
  while (i->next()) {
    std::string iface_name = std::string(i->path()).substr(ifaces_prefix.length());
    iface_name = iface_name.substr(0, iface_name.find("/"));

    //printf("Adding sync thread for peer %s\n", peer.c_str());
    BBLoggerThread *log_thread = new BBLoggerThread(i->get_string().c_str(),
						    logdir.c_str(),
						    buffering, flushing,
						    scenario.c_str(), &start);

    std::string filename = log_thread->get_filename();
    config->set_string((replay_cfg_prefix + iface_name + "/file").c_str(), filename);

    thread_list.push_back(log_thread);
  }
  delete i;

  if ( thread_list.empty() ) {
    throw Exception("No interfaces configured for logging, aborting");
  }

  BBLoggerThread *bblt = dynamic_cast<BBLoggerThread *>(thread_list.front());
  bblt->set_threadlist(thread_list);
}
开发者ID:sanyaade-teachings,项目名称:fawkes,代码行数:92,代码来源:bblogger_plugin.cpp


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