本文整理汇总了C++中writeString函数的典型用法代码示例。如果您正苦于以下问题:C++ writeString函数的具体用法?C++ writeString怎么用?C++ writeString使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了writeString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeString
bool SystemFile::writeString( const string & kstr )
{
return writeString( kstr.c_str(), kstr.size() );
}
示例2: writeString
std::string ExternalQueryBuilder::composeLoadAllQuery() const
{
WriteBufferFromOwnString out;
writeString("SELECT ", out);
if (dict_struct.id)
{
if (!dict_struct.id->expression.empty())
{
writeParenthesisedString(dict_struct.id->expression, out);
writeString(" AS ", out);
}
writeQuoted(dict_struct.id->name, out);
if (dict_struct.range_min && dict_struct.range_max)
{
writeString(", ", out);
if (!dict_struct.range_min->expression.empty())
{
writeParenthesisedString(dict_struct.range_min->expression, out);
writeString(" AS ", out);
}
writeQuoted(dict_struct.range_min->name, out);
writeString(", ", out);
if (!dict_struct.range_max->expression.empty())
{
writeParenthesisedString(dict_struct.range_max->expression, out);
writeString(" AS ", out);
}
writeQuoted(dict_struct.range_max->name, out);
}
}
else if (dict_struct.key)
{
auto first = true;
for (const auto & key : *dict_struct.key)
{
if (!first)
writeString(", ", out);
first = false;
if (!key.expression.empty())
{
writeParenthesisedString(key.expression, out);
writeString(" AS ", out);
}
writeQuoted(key.name, out);
}
}
for (const auto & attr : dict_struct.attributes)
{
writeString(", ", out);
if (!attr.expression.empty())
{
writeParenthesisedString(attr.expression, out);
writeString(" AS ", out);
}
writeQuoted(attr.name, out);
}
writeString(" FROM ", out);
if (!db.empty())
{
writeQuoted(db, out);
writeChar('.', out);
}
if (!schema.empty())
{
writeQuoted(schema, out);
writeChar('.', out);
}
writeQuoted(table, out);
if (!where.empty())
{
writeString(" WHERE ", out);
writeString(where, out);
}
writeChar(';', out);
return out.str();
}
示例3: main
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
char * endMessageTop = "You am ";
char * endMessageBottomLose = "lose ";
char * endMessageBottomWin = "Not lose";
char * deadMessage = "Dead ";
unsigned char player;
unsigned char mines[NUM_MINES];
while (1) {
timer = 0;
button = 0;
player = initPlayer();
initProgram();
printPlayer(player);
generateMines(mines);
//run while none of the end-game situations have occurred
while ((timer < 4) && !didPlayerWin(player)
&& !didPlayerHitMine(player, mines)) {
if (button) {
switch (button) {
case BIT0:
player = movePlayer(player, RIGHT);
break;
case BIT1:
player = movePlayer(player, LEFT);
break;
case BIT2:
player = movePlayer(player, UP);
break;
case BIT3:
player = movePlayer(player, DOWN);
break;
}
button = 0;
}
}
//if the timer hits 2 seconds, or if the player hits a mine, the game is over
if (timer == 4 || didPlayerHitMine(player, mines)) {
//displays a special message if the player lost due to hitting a mine
if (didPlayerHitMine(player, mines)) {
cursorToLineOne();
writeString(deadMessage, 8);
_delay_cycles(500000);
}
button = 0;
//displays game over message
cursorToLineOne();
writeString(endMessageTop, 8);
cursorToLineTwo();
writeString(endMessageBottomLose, 8);
}
//if the player hits 0xC7 they win, display the win message
else if (didPlayerWin(player)) {
button = 0;
cursorToLineOne();
writeString(endMessageTop, 8);
cursorToLineTwo();
writeString(endMessageBottomWin, 8);
}
// Waits for a button input and then resets the game
while (button != 0) {
}
}
}
示例4: writeTypedListElement
void writeTypedListElement( TAThread thread, const TypedListElement * value ) {
const int * start;
switch ( value->type ) {
case IntTObjCode : writeString( thread, "IntTObj" ); writeInt ( thread, value->data.IntTObj ); break;
case CharTObjCode : writeString( thread, "CharTObj" ); writeChar ( thread, value->data.CharTObj ); break;
case ShortTObjCode : writeString( thread, "ShortTObj" ); writeShort ( thread, value->data.ShortTObj ); break;
case LongTObjCode : writeString( thread, "LongTObj" ); writeLong ( thread, value->data.LongTObj ); break;
case LLongTObjCode : writeString( thread, "LLongTObj" ); writeLLong ( thread, value->data.LLongTObj ); break;
case IntMaxTObjCode : writeString( thread, "IntMaxTObj" ); writeIntMax( thread, value->data.IntMaxTObj ); break;
case SizeTObjCode : writeString( thread, "SizeTObj" ); writeSize ( thread, value->data.SizeTObj ); break;
case PtrDiffTObjCode: writeString( thread, "PtrDiffTObj" ); writeLong ( thread, value->data.PtrDiffTObj ); break;
case WIntTObjCode : writeString( thread, "WIntTObj" ); writeWChar ( thread, value->data.WIntTObj ); break;
case FloatTObjCode:
start = (int *)& value->data.FloatTObj;
writeString( thread, "FloatTObj" );
writeIntArray( thread, start, sizeof( float ) / sizeof( int ) );
break;
case DoubleTObjCode:
start = (int *)& value->data.DoubleTObj;
writeString( thread, "DoubleTObj" );
writeIntArray( thread, start, sizeof( double ) / sizeof( int ) );
break;
case LongDoubleTObjCode:
start = (int *)& value->data.LongDoubleTObj;
writeString( thread, "LongDoubleTObj" );
writeIntArray( thread, start, sizeof( long double ) / sizeof( int ) );
break;
case CStringCode : writeString( thread, "CString" ); writeString ( thread, value->data.CString ); break;
case WStringCode : writeString( thread, "WString" ); writeWString( thread, value->data.WString ); break;
case VoidTPtrObjCode: writeString( thread, "VoidTPtrObj" ); writePointer( thread, value->data.VoidTPtrObj ); break;
default: assertion( 0, "writeTypedListElement : unsupported type" ); break;
}
} // writeTypedListElement
示例5: writeString
void KdbxXmlWriter::writeNumber(const QString& qualifiedName, int number)
{
writeString(qualifiedName, QString::number(number));
}
示例6: writeString
void File::writeLine()
{
writeString("\n");
}
示例7: writeUInt32
void BinaryOutput::writeString32(const char* s) {
writeUInt32(strlen(s) + 1);
writeString(s);
}
示例8: main
int main( int argc, char* argv[] )
{
char cwd[2048];
_getcwd( cwd, sizeof(cwd) );
// zar <opt> <dir>
if ( argc != 4 )
{
printf( "Usage:\n"
"archive: zar -a <name> <dir>\n"
"unarchive: zar -x <name> <dir>\n"
"remove: zar -d <name> <filelist>\n" );
return 0;
}
const char* opt = argv[1];
const char* name = argv[2];
const char* dir = argv[3];
if ( std::string(opt) == "-a" )
{
// read files
std::vector<File> files;
if ( -1 != _chdir(dir) )
{
printf( "Processing %s...\n", dir );
readFiles( files, "*.*" );
}
else
{
printf( "Path %s not found\n", dir );
}
_chdir( cwd );
// check for duplicate file names
int i;
for ( i = 0 ; i < (int)files.size() ; ++i )
{
for ( int j = i+1 ; j < (int)files.size() ; ++j )
{
if ( files[i].name == files[j].name )
{
printf( "Warning: Two files have identical names (%s). Paths:\n", files[i].name.c_str() );
printf( "%s\n", files[i].path.c_str() );
printf( "%s\n", files[j].path.c_str() );
printf( "Removing %s/%s...\n", files[j].path.c_str(), files[j].name.c_str() );
files.erase( files.begin()+j );
--j;
}
}
}
// write zip
printf( "Writing %s...\n", name );
gzFile zip = gzopen( name, "wb" );
writeInt( zip, files.size() );
for ( i = 0 ; i < (int)files.size() ; ++i )
{
File& file = files[i];
writeString( zip, file.name.c_str() );
writeBytes( zip, file.data.begin(), file.data.size() );
}
gzclose( zip );
}
else if ( std::string(opt) == "-x" )
{
// read zip
printf( "Reading %s...\n", name );
gzFile zip = gzopen( name, "rb" );
if ( !zip )
{
printf( "Failed to open %s.", name );
return 1;
}
std::vector<File> files;
int count = readInt( zip );
files.resize( count );
for ( int i = 0 ; i < count ; ++i )
{
File& file = files[i];
readString( zip, file.name );
readBytes( zip, file.data );
}
gzclose( zip );
// write files
if ( -1 != _chdir(dir) )
{
for ( int i = 0 ; i < (int)files.size() ; ++i )
{
File& file = files[i];
printf( "Writing %s...\n", file.name.c_str() );
FILE* fh = fopen( file.name.c_str(), "wb" );
if ( fh )
{
fwrite( file.data.begin(), 1, file.data.size(), fh );
fclose( fh );
}
else
{
printf( "Cannot write to file: %s\n", file.name.c_str() );
//.........这里部分代码省略.........
示例9: writeItem
static void writeItem(WTF::Vector<char>& vector, WebCore::HistoryItem* item)
{
// Original url
writeString(vector, item->originalURLString());
// Url
writeString(vector, item->urlString());
// Title
writeString(vector, item->title());
// Form content type
writeString(vector, item->formContentType());
// Form data
const WebCore::FormData* formData = item->formData();
if (formData) {
WTF::String flattenedFormData = formData->flattenToString();
writeString(vector, flattenedFormData);
if (!flattenedFormData.isEmpty()) {
// save the identifier as it is not included in the flatten data
int64_t id = formData->identifier();
vector.append((char*)&id, sizeof(int64_t));
}
} else
writeString(vector, WTF::String()); // Empty constructor does not allocate a buffer.
// Target
writeString(vector, item->target());
AndroidWebHistoryBridge* bridge = item->bridge();
ALOG_ASSERT(bridge, "We should have a bridge here!");
// Screen scale
const float scale = bridge->scale();
ALOGV("Writing scale %f", scale);
vector.append((char*)&scale, sizeof(float));
const float textWrapScale = bridge->textWrapScale();
ALOGV("Writing text wrap scale %f", textWrapScale);
vector.append((char*)&textWrapScale, sizeof(float));
// Scroll position.
const int scrollX = item->scrollPoint().x();
vector.append((char*)&scrollX, sizeof(int));
const int scrollY = item->scrollPoint().y();
vector.append((char*)&scrollY, sizeof(int));
// Document state
const WTF::Vector<WTF::String>& docState = item->documentState();
WTF::Vector<WTF::String>::const_iterator end = docState.end();
unsigned stateSize = docState.size();
ALOGV("Writing docState %d", stateSize);
vector.append((char*)&stateSize, sizeof(unsigned));
for (WTF::Vector<WTF::String>::const_iterator i = docState.begin(); i != end; ++i) {
writeString(vector, *i);
}
// Is target item
ALOGV("Writing isTargetItem %d", item->isTargetItem());
vector.append((char)item->isTargetItem());
// Children count
unsigned childCount = item->children().size();
ALOGV("Writing childCount %d", childCount);
vector.append((char*)&childCount, sizeof(unsigned));
}
示例10: writeString
/*
* Write a string to a file
*/
int8_t sd::writeString(FIL* f, char* str) {
return writeString(f,(uint8_t*)str);
}
示例11: printRTC
//.........这里部分代码省略.........
break;*/
/*case DDMMYY:
sprintf(str, " %02d.%02d.%02d", date.day, date.month, date.year % 100);
break;*/
/*case hhmm:
sprintf(str, " %02d.%02d", date.hour, date.minute);
break;
case DDMM:
sprintf(str, " %02d.%02d", date.day, date.month);
break;*/
default:
i = BUF_SIZE;
while (--i)
str[i-1] = '\0';
break;
}
break;
case 6 ... 7:
switch (rtcMenu.state)
{
case hhmmss:
sprintf(str, "%02d.%02d.%02d", date.hour, date.minute, date.second);
break;
case dd_hhmm:
sprintf(str, "%c%c %02d.%02d", DOW(date.dow)[0], DOW(date.dow)[1], date.minute, date.second);
break;
case DDMMYY:
sprintf(str, "%02d.%02d.%02d", date.day, date.month, date.year % 100);
break;
/*case hhmm:
sprintf(str, " %02d.%02d", date.hour, date.minute);
break;
case DDMM:
sprintf(str, " %02d.%02d", date.day, date.month);
break;*/
default:
i = BUF_SIZE;
while (--i)
str[i - 1] = '\0';
break;
}
break;
case 4 ... 5:
switch (rtcMenu.state)
{
case hhmm:
sprintf(str, "%02d.%02d", date.hour, date.minute);
break;
case DDMM:
sprintf(str, "%02d.%02d", date.day, date.month);
break;
default:
i = BUF_SIZE;
while (--i)
str[i - 1] = '\0';
break;
}
break;
case 3:
switch (rtcMenu.state)
{
case ddd:
sprintf(str, "%02d.%02d", date.hour, date.minute);
break;
}
break;
case 2:
switch (rtcMenu.state)
{
case dd:
sprintf(str, "%c%c", date.hour, date.minute);
break;
default:
i = BUF_SIZE;
while (--i)
str[i - 1] = '\0';
break;
}
break;
case 0 ... 1:
sprintf(str, " ");
break;
}
if (*str == 0)
{
cnt++;
advState();
if (cnt < DATEVIEWS)
{
goto menu_loop;
}
else
{
sprintf(str, "ERR");
}
}
writeString(digits, str);
screen.changed |= digits;
}
示例12: parseNext
bool RC2UI::makeDialog()
{
line = in->readLine();
do {
QFile fileOut;
QString buffer;
int count;
QCString className;
uint x, y, w, h;
uint endDesc;
bool space = FALSE;
for ( endDesc = 0; endDesc < line.length() ; endDesc++ ) {
char c = (QChar)line.at(endDesc);
if ( space && (c >= '0') && (c <= '9') )
break;
space = c==' ';
}
QString desc = line.left(endDesc-1);
line = line.right( line.length() - endDesc );
className = parseNext( desc, ' ' );
count = sscanf( line, "%d, %d, %d, %d", &x, &y, &w, &h );
if ( !count && count == EOF )
return FALSE;
char property[256];
QStringList styles;
QStringList extendedStyles;
QString caption = "";
QString baseClass = "";
QString widgetType;
QString widgetName;
QString arguments;
int pointsize;
QString fontname;
do {
if ( in->eof() )
return TRUE;
line = "";
do {
line += in->readLine();
} while ( line[(int)line.length()-1] == '|' ||
line[(int)line.length()-1] == ',' );
count = sscanf( line, "%s", property );
line = line.right( line.length() - line.find(" ") -1 );
if ( QString(property) == "STYLE" ) {
styles = splitStyles(line);
if ( styles.contains( "WS_CAPTION" ) )
baseClass = "QDialog";
else
baseClass = "QWidget";
} else if ( QString(property) == "CAPTION" ) {
caption = stripQM( line );
} else if ( QString(property) == "FONT" ) {
QString pt = line.left( line.find(",") );
pointsize = pt.toInt();
fontname = stripQM(line.right( line.length() - line.find(",") - 2 ));
}
} while ( line != "BEGIN" );
if ( writeToFile ) {
QString outputFile = QString(className) + ".ui";
fileOut.setName( outputFile );
if (!fileOut.open( IO_WriteOnly ) )
qFatal( "rc2ui: Could not open output file '%s'", outputFile.latin1() );
out = new QTextStream( &fileOut );
} else {
out = new QTextStream( &buffer, IO_WriteOnly );
}
*out << "<!DOCTYPE UI><UI>" << endl;
writeClass( className );
wi(); *out << "<widget>"<< endl; indent();
writeClass( baseClass );
writeCString( "name", className );
writeRect( "geometry", x, y, w, h );
writeString( "caption", caption );
writeFont( fontname, pointsize );
do {
line = in->readLine().stripWhiteSpace();
if ( line == "END" )
continue;
widgetType = parseNext(line, ' ');
arguments = line.stripWhiteSpace();
while ( arguments[(int)arguments.length()-1] == ',' ||
arguments[(int)arguments.length()-1] == '|' )
arguments += " "+in->readLine().stripWhiteSpace();
wi(); *out << "<widget>" << endl; indent();
WidgetType ID = IDUnknown;
QString controlType;
QString widgetID;
//.........这里部分代码省略.........
示例13: startMap32
void MessageEncoder::writeMap(const qpid::types::Variant::Map& properties, const Descriptor* d, bool large)
{
void* token = large ? startMap32(d) : startMap8(d);
for (qpid::types::Variant::Map::const_iterator i = properties.begin(); i != properties.end(); ++i) {
writeString(i->first);
switch (i->second.getType()) {
case qpid::types::VAR_MAP:
case qpid::types::VAR_LIST:
//not allowed (TODO: revise, only strictly true for application-properties) whereas this is now a more general method)
QPID_LOG(warning, "Ignoring nested map/list; not allowed in application-properties for AMQP 1.0");
case qpid::types::VAR_VOID:
writeNull();
break;
case qpid::types::VAR_BOOL:
writeBoolean(i->second);
break;
case qpid::types::VAR_UINT8:
writeUByte(i->second);
break;
case qpid::types::VAR_UINT16:
writeUShort(i->second);
break;
case qpid::types::VAR_UINT32:
writeUInt(i->second);
break;
case qpid::types::VAR_UINT64:
writeULong(i->second);
break;
case qpid::types::VAR_INT8:
writeByte(i->second);
break;
case qpid::types::VAR_INT16:
writeShort(i->second);
break;
case qpid::types::VAR_INT32:
writeInt(i->second);
break;
case qpid::types::VAR_INT64:
writeULong(i->second);
break;
case qpid::types::VAR_FLOAT:
writeFloat(i->second);
break;
case qpid::types::VAR_DOUBLE:
writeDouble(i->second);
break;
case qpid::types::VAR_STRING:
if (i->second.getEncoding() == BINARY) {
writeBinary(i->second);
} else {
writeString(i->second);
}
break;
case qpid::types::VAR_UUID:
writeUuid(i->second);
break;
}
}
if (large) endMap32(properties.size()*2, token);
else endMap8(properties.size()*2, token);
}
示例14: Function_Tests
void Function_Tests (void)
{
int i, j ;
int k ;
int l ;
int m ;
WORD handle, h1, h2 ;
WORD parms[20];
unsigned char wks1[255] ;
unsigned char wks2[255] ;
unsigned char wks3[255] ;
gfx_Cls() ;
putstr("file_Run, file_Exec and\nfile_LoadFunction Tests") ;
printf("file_Run, file_Exec and file_LoadFunction Tests\n") ;
j = mem_Heap() ;
handle = file_LoadFunction(functest) ;
h1 = writeString(0, "Please enter your name") ; // prompts string
h2 = writeString(h1, "") ; // result string, must be max length if following strings are to be 'kept'
printf("String Handles %d %d\n", h1, h2) ;
parms[0] = h1 ; // prompt string
parms[1] = h2 ; // result string
parms[2] = 20 ;
parms[3] = 1 ; // 1 = save screen, 0 = don't save screen
TimeLimit4D = 5000000 ;
i = file_CallFunction(handle, 4, parms) ; // calls a function
printf("You typed %d characters", i) ;
readString(h2, wks1) ; // read string immediately as it will be overwritten 'soon'
printf(">%s<\n", wks1) ;
k = mem_Heap() ;
mem_Free(handle) ;
l = mem_Heap() ;
sleep(5000) ; // give time to read the 'restored' screen
h1 = writeString(0, "Please type anything") ; // prompts string
h2 = writeString(h1, "") ; // result string, must be max length if following strings are to be 'kept'
parms[0] = h1 ; // prompt string
parms[1] = h2 ; // result string
parms[2] = 20 ;
parms[3] = 0 ; // 1 = save screen, 0 = don't save screen
i = file_Exec(functest, 4, parms) ;
readString(h2, wks2) ; // read string immediately as it will be overwritten 'soon'
gfx_Cls() ;
h1 = writeString(0, "Please some more") ; // prompts string
h2 = writeString(h1, "") ; // result string, must be max length if following strings are to be 'kept'
parms[0] = h1 ; // prompt string
parms[1] = h2 ; // result string
parms[2] = 20 ;
parms[3] = 0 ; // 1 = save screen, 0 = don't save screen
i = file_Run(functest, 4, parms) ;
readString(h2, wks3) ; // read string immediately as it will be overwritten 'soon'
gfx_Cls() ;
m = mem_Heap() ;
printf("Memfree before loadfunction = %d\n", j) ;
printf("Memfree after loadfunction = %d\n", k) ;
printf("Memfree after free = %d\n", l) ;
printf("Memfree at end = %d\n", m) ;
printf("You typed\n") ;
printf(wks1) ;
printf("\n") ;
printf(wks2) ;
printf("\n") ;
printf(wks3) ;
printf("\n") ;
TimeLimit4D = 2000 ;
}
示例15: Q_ASSERT
void KdbxXmlWriter::writeEntry(const Entry* entry)
{
Q_ASSERT(!entry->uuid().isNull());
m_xml.writeStartElement("Entry");
writeUuid("UUID", entry->uuid());
writeNumber("IconID", entry->iconNumber());
if (!entry->iconUuid().isNull()) {
writeUuid("CustomIconUUID", entry->iconUuid());
}
writeColor("ForegroundColor", entry->foregroundColor());
writeColor("BackgroundColor", entry->backgroundColor());
writeString("OverrideURL", entry->overrideUrl());
writeString("Tags", entry->tags());
writeTimes(entry->timeInfo());
const QList<QString> attributesKeyList = entry->attributes()->keys();
for (const QString& key : attributesKeyList) {
m_xml.writeStartElement("String");
// clang-format off
bool protect =
(((key == "Title") && m_meta->protectTitle()) || ((key == "UserName") && m_meta->protectUsername())
|| ((key == "Password") && m_meta->protectPassword())
|| ((key == "URL") && m_meta->protectUrl())
|| ((key == "Notes") && m_meta->protectNotes())
|| entry->attributes()->isProtected(key));
// clang-format on
writeString("Key", key);
m_xml.writeStartElement("Value");
QString value;
if (protect) {
if (!m_innerStreamProtectionDisabled && m_randomStream) {
m_xml.writeAttribute("Protected", "True");
bool ok;
QByteArray rawData = m_randomStream->process(entry->attributes()->value(key).toUtf8(), &ok);
if (!ok) {
raiseError(m_randomStream->errorString());
}
value = QString::fromLatin1(rawData.toBase64());
} else {
m_xml.writeAttribute("ProtectInMemory", "True");
value = entry->attributes()->value(key);
}
} else {
value = entry->attributes()->value(key);
}
if (!value.isEmpty()) {
m_xml.writeCharacters(stripInvalidXml10Chars(value));
}
m_xml.writeEndElement();
m_xml.writeEndElement();
}
const QList<QString> attachmentsKeyList = entry->attachments()->keys();
for (const QString& key : attachmentsKeyList) {
m_xml.writeStartElement("Binary");
writeString("Key", key);
m_xml.writeStartElement("Value");
m_xml.writeAttribute("Ref", QString::number(m_idMap[entry->attachments()->value(key)]));
m_xml.writeEndElement();
m_xml.writeEndElement();
}
writeAutoType(entry);
if (m_kdbxVersion >= KeePass2::FILE_VERSION_4) {
writeCustomData(entry->customData());
}
// write history only for entries that are not history items
if (entry->parent()) {
writeEntryHistory(entry);
}
m_xml.writeEndElement();
}