Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F115938190
RoadLogEvent.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Jun 3, 23:41
Size
2 KB
Mime Type
text/x-c
Expires
Thu, Jun 5, 23:41 (2 d)
Engine
blob
Format
Raw Data
Handle
26581675
Attached To
rCADDMESH CADD_mesher
RoadLogEvent.cpp
View Options
/****************************************************************************
**
** Copyright (C) 2008-2009 C. Bradford Barber. All rights reserved.
** $Id: //product/qhull/main/rel/cpp/road/RoadLogEvent.cpp#8 $$Change: 1053 $
** $DateTime: 2009/10/02 22:00:28 $$Author: bbarber $
**
****************************************************************************/
#//! RoadError -- All exceptions thrown by Qhull are RoadErrors
#include <iostream>
#include <sstream>
#include <string>
#include "RoadError.h"
using std::cout;
using std::endl;
using std::ostringstream;
using std::string;
#ifdef _MSC_VER // Microsoft Visual C++ -- warning level 4
#endif
namespace orgQhull {
#//Conversion
string RoadLogEvent::
toString(const char *tag, int code) const
{
ostringstream os;
if(tag && code){
os<< tag << code;
if(format_string){
os<< " ";
}
}
if(!format_string){
return os.str();
}
const char *s= format_string;
int dCount= 0; // Count of %d
int fCount= 0; // Count of %f
char extraCode= '\0';
while(*s){
if(*s!='%'){
os<< *s++;
}else{
char c= *++s;
s++;
switch(c){
case 'd':
if(++dCount>2){
os<< " ERROR_three_%d_in_format ";
}else if(dCount==2){
os<< int_2;
}else{
os<< int_1;
}
break;
case 'e':
if(firstExtraCode(os, c, &extraCode)){
os<< double_1;
}
break;
case 'f':
if(++fCount>1){
os<< " ERROR_two_%f_in_format ";
}else{
os<< float_1;
}
break;
case 'i':
if(firstExtraCode(os, c, &extraCode)){
os<< int64_1;
}
break;
case 's':
if(firstExtraCode(os, c, &extraCode)){
os<< cstr_1;
}
break;
case 'x':
if(firstExtraCode(os, c, &extraCode)){
os<< void_1;
}
break;
case '%':
os<< c;
break;
default:
os<< " ERROR_%" << c << "_not_defined_in_format";
break;
}
}
}
if(s[-1]!='\n'){
os<< endl;
}
return os.str();
}//toString
#//Class helpers (static)
//! True if this char is the first extra code
bool RoadLogEvent::
firstExtraCode(std::ostream &os, char c, char *extraCode){
if(*extraCode){
os<< " ERROR_%" << *extraCode << "_and_%" << c << "_in_format ";
return false;
}
*extraCode= c;
return true;
}//firstExtraCode
}//namespace orgQhull
Event Timeline
Log In to Comment