示例#1
0
 bool seek(size_t v, int origin)
 {
     if (origin == SEEK_CUR)
         stream.seekp(v, std::ios_base::cur);
     else if (origin == SEEK_END)
         stream.seekp(v, std::ios_base::end);
     else
         stream.seekp(v, std::ios_base::beg);
     return !stream.fail();
 }
示例#2
0
文件: transport.cpp 项目: xandr84/RPC
Variant ClientBase::sendBuffer(char type, RequestID requestID, std::ostringstream &stream)
{	
	unsigned int size = (unsigned int)stream.tellp();
	size -= sizeof(size);
	stream.seekp(0);
	stream.write((const char*)&size, sizeof(size));

	RequestData rd;
	rd.type = MessageType(type);
	rd.id = requestID;
	rd.data = stream.str();

	if(asyncMode())
	{
		rd.writeCompletePtr.reset(new FutureResult);
		bool empty = m_messageQueue.empty();
		m_messageQueue.push(rd);
		if(empty)
		{
			writeData(m_messageQueue.front().data);			
		}
		return rd.writeCompletePtr;
	}
	else
	{
		writeData(rd.data);	
	}
	return Variant();
}
示例#3
0
文件: main.cpp 项目: CCJY/coliru
std::string expand(Range const& key)
{
    thread_local std::ostringstream oss;
    oss.str().clear();
    oss.clear();
    oss.seekp(0);
    oss << " (subst_for_" << key.to_string() << ':' << (rand()%42) << ") ";
    return oss.str();
}
ostream & Journal(entier level)
{
  if (level <= journal_level) {
    cerr << "[" << level << "] ";
    return cerr;
  } else {
    junk_journal.seekp(0);
    return junk_journal;
  }
}
示例#5
0
std::string to_binary(std::ostringstream &out, const T &t) {
  out.clear();
  out.seekp(0);
  bf::fold(t, 0, app_item(out));
  // because out.str() gives us the contents of the string buffer,
  // not the contents written since clear() was called, we need to
  // chop off any remaining garbage at the end.
  std::string rv = out.str();
  rv.resize(out.tellp());
  return rv;
}
示例#6
0
文件: Tools.cpp 项目: emmanouil/MOOOK
u64 write_playlist_segment(u64 seg_num, u64 timeref){
	tmp = vidListStream.str();
	vidListStream.seekp(0);
	vidListStream << "\n\t\t{ \n\t\t\"Open_segment_time\":" << "\"" << timeref << "\",";
	vidListStream << "\n\t\t\"Video_Segment\": \"seg_" << seg_num << "_gpac.m4s\",\n\t\t\"Skel_Segments\":";
//	vidListStream << "[" << skelListStream.str() << "],\n\t\t";
//	vidListStream << "\"Slides\": [" << imListStream.str() << "]\n";
				
	if (seg_num == 1){
		vidListStream << "\t\t}\n";
	}
	else{
		vidListStream << "\t\t},\n";
	}

	vidListStream << tmp;

	finalStream << "{\"Playlist\":\n\t[" << vidListStream.str();
	vidPlaylist.open("x64/Debug/out/playlist.json");
	vidPlaylist << finalStream.str();
	vidPlaylist.close();

	finalStream.str("");
//	imListStream.str("");
//	skelListStream.str("");
					
	playlistStream << "http://" << ipAddr << ":8080/x64/Debug/out/seg_" << seg_num << "_gpac.m4s\n";
	playlistFile.open("x64/Debug/out/playlist.m3u8");
	if (playlistFile.is_open()){
		playlistFile << playlistStream.str();
	}
			
	playlistFile.close();

	seg_num++;
	return seg_num;

}
示例#7
0
void cleanup() {
    featureVector.clear();
    os.clear(); os.seekp(0);    // reset string stream
    os.str("");
}
示例#8
0
 void close()
 {
     stream.seekp(0, std::ios_base::end);
     std::string v = stream.str();
     SteamRemoteStorage()->FileWrite(filename.c_str(), &v[0], v.size());
 }