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


C++ stringstream::clear方法代码示例

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


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

示例1: getMemoryStatus

diagnostic_msgs::DiagnosticStatus getMemoryStatus() {
    diagnostic_msgs::DiagnosticStatus memoryStatus;

    memoryStatus.name = "memoryStatus";
    memoryStatus.message = "The current memory status is ";
    float percentage = (memory.memFree + memory.memCached + memory.memBuffers) * 1.0 / memory.memTotal;
    if (0.3 <= percentage) {
	memoryStatus.level = 0;
	memoryStatus.message += " OK";
    }
    else if (0.2 <= percentage) {
	memoryStatus.level = 1;
	memoryStatus.message += " moderate";
    }
    else {
	memoryStatus.level = 2;
	memoryStatus.message += " weak";
    }

    memoryStatus.hardware_id = "memory";
    memoryStatus.values.resize(5);

    floatStringHelper.clear();
    floatStringHelper << percentage;
    memoryStatus.values[0].key = "free";
    floatStringHelper >> memoryStatus.values[0].value;

    floatStringHelper.clear();
    floatStringHelper << memory.memTotal;
    memoryStatus.values[1].key = "memTotal";
    floatStringHelper >> memoryStatus.values[1].value;

    floatStringHelper.clear();
    floatStringHelper << memory.memFree;
    memoryStatus.values[2].key = "memFree";
    floatStringHelper >> memoryStatus.values[2].value;

    floatStringHelper.clear();
    floatStringHelper << memory.memCached;
    memoryStatus.values[3].key = "memCached";
    floatStringHelper >> memoryStatus.values[3].value;

    floatStringHelper.clear();
    floatStringHelper << memory.memBuffers;
    memoryStatus.values[4].key = "memBuffers";
    floatStringHelper >> memoryStatus.values[4].value;

    return memoryStatus;
}
开发者ID:NIFTi-Fraunhofer,项目名称:nifti_uav,代码行数:49,代码来源:memoryInfo.cpp

示例2: printBytesPercent

void GuiHelper::printBytesPercent(GRender& render, uint32_t x, uint32_t y, long total, long other) {

	static std::stringstream ss;
	ss.str("");
	ss.clear();
	ss.imbue(std::locale(""));

	std::string unit;
	int div = 1;
	int digits = 0;

	switch (bytePercentUnit) {
	case GH_TYPE_BYTE:	div = 1; digits = 0; unit = " B"; break;
	case GH_TYPE_KBYTE: div = 1024; digits = 1; unit = " KiB"; break;
	case GH_TYPE_MBYTE: div = 1024 * 1024; digits = 1; unit = " MiB"; break;
	}

	float percent = (total) ? (100.0 * other / (total)) : (0);
	ss << " (" << std::setiosflags(std::ios::fixed) << std::setprecision(1) << percent << "%)";
	render.printR(x, y, ss.str());
	ss.str("");
	ss << std::setprecision(digits) << (other / (float) div) << unit ;
	render.printR(x-9, y, ss.str());

}
开发者ID:k-a-z-u,项目名称:NetAnalyzer,代码行数:25,代码来源:GuiHelper.cpp

示例3: printERRLOG

void printERRLOG() {
  std::string errLine;
  while( std::getline(ERRLOG,errLine) ) {
    std::cerr << errLine << std::endl;
  }
  ERRLOG.clear();
}
开发者ID:YSShannon,项目名称:rf-ace,代码行数:7,代码来源:newtest.hpp

示例4:

 // This resets the flags of streamToReset and sets its string to be
 // newString.
 inline void
 ParsingUtilities::ResetStringstream( std::stringstream& streamToReset,
                                      std::string const& newString )
 {
   streamToReset.clear();
   streamToReset.str( newString );
 }
开发者ID:benoleary,项目名称:LesHouchesParserClasses_CPP,代码行数:9,代码来源:ParsingUtilities.hpp

示例5: init

    void init(uint64_t const _i)
    {
        i = _i;

        if (options.doubleIndexing)
        {
            indexBeginQry = (length(gH.qrySeqs) / options.queryPart) * i;
            indexEndQry = (i+1 == options.queryPart) // last interval
                            ? length(gH.qrySeqs) // reach until end
                            : (length(gH.qrySeqs) / options.queryPart) * (i+1);
            // make sure different frames of one sequence in same interval
            indexBeginQry -= (indexBeginQry % qNumFrames(blastProgram));
            indexEndQry -= (indexEndQry % qNumFrames(blastProgram));
        } else
        {
            indexBeginQry = qNumFrames(blastProgram) * i;
            indexEndQry = qNumFrames(blastProgram) * (i+1);
        }

        clear(seeds);
        clear(seedIndex);
        matches.clear();
        seedRefs.clear();
        seedRanks.clear();
//         stats.clear();
        statusStr.clear();
        statusStr.precision(2);
    }
开发者ID:jtroehr,项目名称:lambda,代码行数:28,代码来源:holders.hpp

示例6: flushLogs

void NaCl::flushLogs() {
    string loutStr = lout.str();
    if(loutStr.length() != 0) {
        accumulatedEvents.Set("isDirty", true);
		accumulatedEvents.Set("messages", loutStr);
        lout.str(string());
        lout.clear();
    }
    string lerrStr = lerr.str();
    if(lerrStr.length() != 0) {
        accumulatedEvents.Set("isDirty", true);
		accumulatedEvents.Set("errors", lerrStr);
        lerr.str(string());
        lerr.clear();
    }
}
开发者ID:csantosbh,项目名称:Lauen,代码行数:16,代码来源:NaCl.cpp

示例7: setup

   void setup () {

      // ----------------------------------------------------------------------
      // Initialize the Log component

      // Name of log file
      log_file = Parameters::get_optional<std::string>(
            "Log.log_file", "log.txt");
      log_file = Driver::output_dir + log_file;

      // Open log file
#ifdef PARALLEL_MPI
      if (Driver::proc_ID == log_master) {
         lout.open(log_file.c_str());
      }
#else // PARALLEL_MPI
      lout.open(log_file.c_str());
#endif // PARALLEL_MPI
      initialized = true;

      // Write the log file header
      lout << "Hydrodynamics Simulation" << std::endl << std::endl;

      // If the buffer is not empty, push it to the file
      lout << buffer.str();
      buffer.clear();
      buffer.str("");

   }
开发者ID:bkkrueger,项目名称:toy_hydro,代码行数:29,代码来源:Log.cpp

示例8: clear_stringstream

// stringstreamをクリアして再利用できるようにする
void IPBase::clear_stringstream(std::stringstream &ss) {
	static const std::string empty_string;

	ss.str(empty_string);
	ss.clear();
	ss << std::dec;     // clear()でも元に戻らないので、毎回指定する。
}
开发者ID:y3k00000,项目名称:OpenCVwithUVC,代码行数:8,代码来源:IPBase.cpp

示例9: SendSteamMessages

void CPlayer::SendSteamMessages(MessageTypes type, std::stringstream &ss)
{
    if (!ss.str().empty())
    {
        std::string item;

        while (std::getline(ss, item))
        {
            item = MSG_COLOR_WHITE + item + "|r"; // Default chat to white.
            const char* msg = item.c_str();

            if ((type & CHAT_BOX) != 0)
                ChatHandler(GetSession()).SendSysMessage(msg);
            if ((type & CHAT_WIDE) != 0)
            {
                WorldPacket data(SMSG_NOTIFICATION, (strlen(msg) + 1));
                data << msg;
                GetSession()->SendPacket(&data);
            }
        }

        ss.str(""); // Clear content
        ss.clear(); // Clear state flags.
    }
}
开发者ID:wow4all,项目名称:mangos-tbc,代码行数:25,代码来源:CPlayer.cpp

示例10:

void SettingsDAOSqlite3Impl::set( const std::string& key, const double& value ) {
	static std::stringstream ss;
	ss.str("");
	ss.clear();
	ss << value;
	set( key, ss.str() );
}
开发者ID:emoryau,项目名称:gemini,代码行数:7,代码来源:SettingsDAOSqlite3Impl.cpp

示例11: generateIndexedIndependent

    virtual std::string generateIndexedIndependent(const OperationNode<Base>& indexedIndep,
            const IndexPattern& ip) override {
        bool isX = indexedIndep.getInfo()[0] == 0;
        if (isX) {
            return _nameGen->generateIndexedIndependent(indexedIndep, ip);
        }

        size_t nIndex = indexedIndep.getArguments().size();

        CPPADCG_ASSERT_KNOWN(indexedIndep.getOperationType() == CGOpCode::LoopIndexedIndep, "Invalid node type");
        CPPADCG_ASSERT_KNOWN(nIndex > 0, "Invalid number of arguments");

        std::vector<const IndexDclrOperationNode<Base>*> indices(nIndex);
        for (size_t i = 0; i < nIndex; ++i) {// typically there is only one index but there may be more
            CPPADCG_ASSERT_KNOWN(indexedIndep.getArguments()[i].getOperation() != nullptr, "Invalid argument");
            CPPADCG_ASSERT_KNOWN(indexedIndep.getArguments()[i].getOperation()->getOperationType() == CGOpCode::Index, "Invalid argument");
            indices[i] = &static_cast<const IndexOperationNode<Base>&> (*indexedIndep.getArguments()[i].getOperation()).getIndex();
        }

        _ss.clear();
        _ss.str("");

        _ss << _multName << "[" << LanguageC<Base>::indexPattern2String(ip, indices) << "]";
        return _ss.str();
    }
开发者ID:FreeScienceCommunity,项目名称:CppADCodeGen,代码行数:25,代码来源:lang_c_default_hessian_var_name_gen.hpp

示例12: setupNewLine

void NCursesIOManager::setupNewLine(std::stringstream & ss, int & positionX, int & positionY) const
{
	move(positionY, positionX);
	++positionY;
	ss.clear();
	ss.str("");
}
开发者ID:kiuKisas,项目名称:Plazza,代码行数:7,代码来源:NCursesIOManager.cpp

示例13: getLanguageMode

bool XQueryCompiler::getLanguageMode(std::stringstream& s) const
{
  const size_t lPeekSize = 7;
  char lPeek[lPeekSize];
  s.get(lPeek, lPeekSize);
  s.clear();
  s.seekg(0, s.beg);

  bool lXQueryMode;

  if (strncmp(lPeek, "jsoniq", lPeekSize - 1) == 0)
  {
    lXQueryMode = false;
  }
  else if (strncmp(lPeek, "xquery", lPeekSize - 1) == 0)
  {
    lXQueryMode = true;
  }
  else
  {
    if (theCompilerCB->theRootSctx) // could be null in eval
    {
      StaticContextConsts::language_kind_t lKind
        = theCompilerCB->theRootSctx->language_kind();
      lXQueryMode = (lKind != StaticContextConsts::language_kind_jsoniq);
    }
    else
    {
      lXQueryMode = true;
    }
  }
  return lXQueryMode;
}
开发者ID:alyst,项目名称:zorba,代码行数:33,代码来源:compiler_api.cpp

示例14: to_string

std::string to_string(const T& item) {
    static std::stringstream ss;
    ss.clear();

    ss << item;

    return ss.str();
}
开发者ID:NoiSek,项目名称:libgdx-cpp,代码行数:8,代码来源:StringConvertion.hpp

示例15: from_hex_string

returnType from_hex_string(std::string str) {
    static std::stringstream ss;
    ss.clear();
    ss << std::hex << str;
    returnType retval;
    ss >> retval;
    
    return retval;
}
开发者ID:NoiSek,项目名称:libgdx-cpp,代码行数:9,代码来源:StringConvertion.hpp


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