本文整理汇总了C++中stringstream::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ stringstream::clear方法的具体用法?C++ stringstream::clear怎么用?C++ stringstream::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stringstream
的用法示例。
在下文中一共展示了stringstream::clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadWorldServer
void Display::loadWorldServer(stringstream& msg)
{
string text;
msg >> text;
while (text!="End")
{
if (text == "Tile")
{
msg.clear();
Tile tile;
tile.deserialize(msg);
m_map[tile.getPos()] = tile;
}
if (text == "Player")
{
msg.clear();
Player player;
player.deserialize(msg);
game::pHandler.addPlayer(player);
}
text = "End";
msg.clear();
msg >> text;
}
reloadAll_ = true;
isLoaded_ = true;
}
示例2: main
int main() {
scanf("%d\n\n", &N);
for(int T = 0;; T++) {
if(T > 0) printf("\n");
getline(cin, line);
ss.clear();
ss.str(line);
elements.clear();
while(ss >> a)
elements.push_back(a);
sort(elements.begin(), elements.end());
getline(cin, line);
ss.clear();
ss.str(line);
adj.clear();
adj.resize(256);
while(ss >> a >> b >> c)
adj[a].push_back(c);
if(!dfs(""))
printf("NO\n");
if(!getline(cin, line)) break;
}
}
示例3: rysuj_plansze
void rysuj_plansze()
{
al_clear_to_color(al_map_rgb(255,247,255));
al_draw_filled_rounded_rectangle(square_x, square_y, square_x + square_size, square_y + square_size, square_size/50, square_size/50, al_map_rgb(188,172,159));
for(int a = 0; a < 4; a++){
for(int b = 0; b < 4; b++){
al_draw_filled_rounded_rectangle(square_x + a * break_size + break_size + a * tile_size, square_y + b * break_size + break_size + b * tile_size, square_x + a * break_size + break_size + a * tile_size + tile_size, square_y + b * break_size + break_size + b * tile_size + tile_size, square_size/50, square_size/50, al_map_rgb(205,191,178));
}
}
al_draw_text(howtoarial, al_map_rgb(112,108,99), square_x/2, square_y + tile_size - break_size, ALLEGRO_ALIGN_CENTRE, howto.c_str());
al_draw_text(titlearial, al_map_rgb(112,108,99), square_x/2, square_y - break_size * 2, ALLEGRO_ALIGN_CENTRE, title.c_str());
new_game.draw();// Rysowanie przycisku New game
undo.draw();// Rysowanie przycisku Undo
//
// Rysowanie okienka Score
//
al_draw_filled_rounded_rectangle(square_x + square_size + break_size * 4, square_y + break_size, screen_w - break_size * 4, square_y + tile_size + break_size, square_size/50, square_size/50, al_map_rgb(112,108,99));
al_draw_text(scorearial, al_map_rgb(255,247,255), square_x + square_size + square_x/2, square_y + break_size * 2, ALLEGRO_ALIGN_CENTRE, scoretxt.c_str());
ss.clear();
ss << score;
ss >> scorenum;
al_draw_text(scorearial, al_map_rgb(255,247,255), square_x + square_size + square_x/2, square_y + break_size + tile_size/2, ALLEGRO_ALIGN_CENTRE, scorenum.c_str());
//
// Rysowanie okienka Highscore
//
al_draw_filled_rounded_rectangle(square_x + square_size + break_size * 4, square_y + break_size * 2 + tile_size, screen_w - break_size * 4, square_y + tile_size * 2 + break_size * 2, square_size/50, square_size/50, al_map_rgb(112,108,99));
al_draw_text(scorearial, al_map_rgb(255,247,255), square_x + square_size + square_x/2, square_y + break_size * 3 + tile_size, ALLEGRO_ALIGN_CENTRE, highscoretxt.c_str());
ss.clear();
ss << highscore;
ss >> highscorenum;
al_draw_text(scorearial, al_map_rgb(255,247,255), square_x + square_size + square_x/2, square_y + break_size * 2 + tile_size/2 + tile_size, ALLEGRO_ALIGN_CENTRE, highscorenum.c_str());
//
// Rysowanie kafelków
//
for(int a = 0; a < 4; a++){
for(int b = 0; b < 4; b++){
if(tiles[a][b].number > 0){
al_draw_filled_rounded_rectangle(square_x + a * break_size + break_size + a * tile_size + 10 * tile_size/20 - tiles[a][b].animation_size * tile_size/20, square_y + b * break_size + break_size + b * tile_size + 10 * tile_size/20 - tiles[a][b].animation_size * tile_size/20, square_x + a * break_size + break_size + a * tile_size + tile_size - 10 * tile_size/20 + tiles[a][b].animation_size * tile_size/20, square_y + b * break_size + break_size + b * tile_size + tile_size - 10 * tile_size/20 + tiles[a][b].animation_size * tile_size/20, square_size/50, square_size/50, al_map_rgb(tiles[a][b].r,tiles[a][b].g,tiles[a][b].b));
ss.clear();
ss << tiles[a][b].number;
ss >> text;
if(tiles[a][b].number > 4){
al_draw_text(arial, al_map_rgb(255,247,255), square_x + tile_size * a + break_size * a + break_size + tile_size/2, square_y + tile_size * b + break_size * b + break_size + tile_size/2 - 25, ALLEGRO_ALIGN_CENTRE, text.c_str());
}else{
al_draw_text(arial, al_map_rgb(125,114,110), square_x + tile_size * a + break_size * a + break_size + tile_size/2, square_y + tile_size * b + break_size * b + break_size + tile_size/2 - 25, ALLEGRO_ALIGN_CENTRE, text.c_str());
}
}
}
}
示例4: STOP_TALKING_TO_MOTOR
void Motor::STOP_TALKING_TO_MOTOR( stringstream& cmd)
{
cmd.clear();
cmd << "{0" << CRLF;
SendCommand(cmd);
cmd.str("");
cmd.clear();
}
示例5: TALK_TO_MOTOR
void Motor::TALK_TO_MOTOR(stringstream& cmd)
{
cmd.clear();
cmd << "{" << MotorID << CRLF;
SendCommand(cmd);
cmd.str("");
cmd.clear();
}
示例6: main
int main () {
int n1, n2;
int idx = 0;
while (1) {
string inp;
getline(cin, inp);
ss.str("");
ss.clear();
ss.str(inp);
ss >> n1;
if (n1 == 0) break;
cout<<"Run #"<<++idx<<": ";
vector <string> set1(n1);
for (int i = 0;i < n1; i++) {
getline(cin, set1[i]);
}
getline(cin, inp);
ss.str("");
ss.clear();
ss.str(inp);
ss >> n2;
vector <string> set2(n2);
for (int i = 0;i < n2;i++) {
getline(cin, set2[i]);
}
bool flag = false;
if (n1 == n2) {
flag = true;
for (int i = 0;i<n1;i++) {
if (set1[i] != set2[i]) {
flag = false;
break;
}
}
}
if (flag) {
cout<<"Accepted"<<endl;
}
else {
string s1 = clean(set1);
string s2 = clean(set2);
if (s1 == s2) {
cout<<"Presentation Error"<<endl;
}
else {
cout<<"Wrong Answer"<<endl;
}
}
}
return 0;
}
示例7: showPanel
void InfoPanel::showPanel()
{
SDL_Rect background = {x, y, SCREEN_WIDTH, SCREEN_HEIGHT*0.25};
SDL_FillRect(screen, &background, 0x000000);
Render::UnfilledRect(screen, x, y, SCREEN_WIDTH, SCREEN_HEIGHT*0.25, 5, 0xffffff);
s << h_offset << ", " << v_offset << ", " << currentFPS;
SDL_Surface * t = TTF_RenderText_Blended( font, s.str().c_str(), {255, 255, 255} );
Render::apply_surface(x+CELL_SIZE, y+CELL_SIZE, t, screen);
s.str("");
s.clear();
if (p.get_selected_cell()->get_o() != NULL && p.get_selected_cell()->get_visible() == true)
{
t = TTF_RenderText_Blended( font, p.get_selected_cell()->get_o()->get_title().c_str(), {255, 255, 255});
Render::apply_surface(x+CELL_SIZE, y+2*CELL_SIZE, t, screen);
p.get_selected_cell()->get_o()->draw_ActionSurface();
}
else if (p.get_selected_cell()->get_visible() == false)
{
t = TTF_RenderText_Blended( font, "This cell is obscured by the fog of war", {255, 255, 255});
Render::apply_surface(x+CELL_SIZE, y+2*CELL_SIZE, t, screen);
}
Render::UnfilledRect(screen, x+SCREEN_WIDTH*0.25, y, SCREEN_WIDTH*0.50, SCREEN_HEIGHT*0.25, 2, 0xffffff);
SDL_FreeSurface(t);
minmap->drawMap();
}
示例8: printNode
void printNode(stringstream& lineStream, NodeList& NList) {
string Nodes, junk;
int nodeID;
lineStream >> nodeID;
if(lineStream.fail()) {
lineStream.clear();
lineStream >> Nodes;
if(lineStream.fail()) {
cout << "Error: too few arguments" << endl;
return;
}
if(Nodes != "all") {
cout << "Error: invalid argument" << endl;
return;
}
if(!endOfArgs(lineStream)) return;
//if argument is "all", print all nodes
cout << "Print: " << endl;
Node* current = NList.getNHead();
while(current != NULL) {
cout << *current;
current = current -> getNextN();
}
return;
}
示例9: detectAndDisplay
/** @function detectAndDisplay */
void detectAndDisplay(Mat &frame)
{
static vector<Rect> faces;
static Mat frame_gray;
cvtColor( frame, frame_gray, CV_BGR2GRAY );
equalizeHist( frame_gray, frame_gray );
//-- Detect faces
face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30) );
size_t tam = faces.size();
for(size_t i = 0; i < tam; i++){
Point center( faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5 );
/// Transforma o valor da coodenada x do pixel central da face (int --> char *)
ss.clear();
ss << center.x;
ss >> bytes;
cout << bytes << endl;
/// Envia o valor da coodenada x do pixel central da face para a porta serial do Arduino
RS232_cputs(COM, bytes);
/// Cria uma elipse em volta do pixel central da face para destacá-la
//ellipse( frame, center, Size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar( 255, 255, 255 ), 4, 8, 0 );
}
/// Exibir a frame do vídeo que acabou de ser processada
//imshow( window_name, frame );
}
示例10: GetColumn
int TablePaser::GetColumn(stringstream& ss_str, std::basic_istream<char>& in_put, string& column)
{
column = "";
if (ss_str.eof())
return -1;
char cur_char[2];
cur_char[1] = 0;
char separator = ' ';
if (ss_str.get(cur_char[0]).eof())
return 1;
if (cur_char[0] == ' ')
return 1;
else if (cur_char[0] == '"')
separator = '"';
else
column += string(cur_char);
while (1)
{
if (ss_str.eof())
{
if (separator == '"')
{
if (in_put.eof())
return 0;
column += string("\n\0");
ss_str.clear();
in_put.getline(LineData, LINE_DATA_MAX);
ss_str << LineData;
}
else
return 0;
}
ss_str.getline(LineData, 4096, separator);
column += LineData;
//column.append(LineData);
if (ss_str.eof())
continue;
if (separator == ' ')
return 1;
else if (separator == '"')
{
if (ss_str.eof())
return 0;
ss_str.get(cur_char[0]);
if (ss_str.eof())
return 1;
else if (cur_char[0] == ' ')
return 1;
else if (cur_char[0] != separator)
separator = ' ';
//column.push_back(cur_char);
column += string(cur_char);
}
}
return -1;
}
示例11: printDEBUG
void printDEBUG(stringstream& s)
{
if (DEBUG == 1)
{
cout << s.str();
}
s.clear();
}
示例12: integer
int integer(string s) {
int a;
ss.str("");
ss.clear();
ss.str(s);
ss >> a;
return a;
}
示例13: main
int main(int argc, char *argv[])
{
int seed=time(NULL);
if(argc > 1)
{
ss.clear();
ss<<argv[1];
ss>>seed;
}
示例14: SendCommand
QByteArray Motor::SendCommand(stringstream& cmd)
{
m_pPort->write(cmd.str().c_str(),cmd.str().length());
m_pPort->waitForBytesWritten(0);
//qDebug() << "Sent command " << cmd.str().c_str();
cmd.str("");
cmd.clear();
delay(10);
return m_pPort->readLine();
}
示例15: mem_logger_print
void mem_logger_print(avr_t* avr, const int level, const char * format, va_list args)
{
// va_list args;
// va_start(args, format);
char buff[100];
vsnprintf(buff, 100, format, args);
oss.clear();
oss << buff;
// va_end(args);
}