本文整理汇总了C++中StringWriter类的典型用法代码示例。如果您正苦于以下问题:C++ StringWriter类的具体用法?C++ StringWriter怎么用?C++ StringWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StringWriter类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST_F
TEST_F(StringWriterTest, WriteChar) {
StringWriter buf;
buf.Write('a');
buf.Write(static_cast<char16>(0x3032));
char16 const expected[] = { 'a', 0x3032, 0 };
EXPECT_STREQ(expected, buf.ToString().value());
}
示例2: writer
//------------------------------------------------------------------------
bool XmlRepresentationHelper::startCell ()
{
if (!checkState (kInCell))
return false;
StringWriter writer (stream);
String string;
string.printf ("%s", START_TAG_STRING(CELL_TAG));
writer.write (string);
writer.write (ENDLINE_A);
return true;
}
示例3: send_request
void * send_request(void * gg){
Socket s = Socket("localhost",80);
StringWriter sw ( s.getOutputStream() );
StringReader sr ( s.getInputStream() );
struct timeval start,end;
static char * request =
"GET /index.html HTTP/1.1\n"
"Host: oink\n\n";
gettimeofday( &start , NULL );
sw.write( request );
sr.readLine();
gettimeofday( &end , NULL );
long long val =
(long long)
( end.tv_sec - start.tv_sec) * 1000000L +
( end.tv_usec - start.tv_usec);
update_times( (int) val);
--thread_count;
}
示例4: endLayer
//------------------------------------------------------------------------
XmlRepresentationHelper::~XmlRepresentationHelper ()
{
if (state == kInLayer)
endLayer ();
if (state == kInCell)
endCell ();
if (state == kInPage)
endPage ();
StringWriter writer (stream);
String string;
// end representation
string.printf ("\t%s", END_TAG_STRING(REPRESENTATION_TAG));
writer.write (string);
writer.write (ENDLINE_A);
// end piper
writer.write (END_TAG_STRING(ROOTXML_TAG));
writer.write (ENDLINE_A);
}
示例5: TEST
TEST(Decompressor, GZip) {
StringWriter* writer = new StringWriter;
GZipCompressor compressor(writer);
EXPECT_LT(0, compressor.WriteString(IPSUM));
EXPECT_LT(writer->GetBuffer().size(), compressor.totalBytesIn());
StringWriter* outputWriter = new StringWriter;
GZipDecompressor decompressor(outputWriter);
EXPECT_EQ(decompressor.WriteString(writer->GetBuffer()), IPSUM.size());
ASSERT_EQ(compressor.totalBytesIn(), outputWriter->GetBuffer().size());
for (int i = 0; i < outputWriter->GetBuffer().size(); ++i) {
EXPECT_EQ(IPSUM.data()[i], outputWriter->GetBuffer()[i]);
};
};
示例6: PanelCrashReport
PanelCrashReport(UnexpectedThrowable PanelCrashReport::unexpectedthrowable)
{
setBackground(new Color(0x2e3444));
setLayout(new BorderLayout());
StringWriter stringwriter = new StringWriter();
unexpectedthrowable.field_6514_b.printStackTrace(new PrintWriter(stringwriter));
String s = stringwriter.toString();
String s1 = "";
String s2 = "";
try
{
s2 = (new StringBuilder()).append(s2).append("Generated ").append((new SimpleDateFormat()).format(new Date())).append("\n").toString();
s2 = (new StringBuilder()).append(s2).append("\n").toString();
s2 = (new StringBuilder()).append(s2).append("Minecraft: Minecraft Alpha v1.2.2 (Mrneo240 Custom v0.4)\n").toString();
s2 = (new StringBuilder()).append(s2).append("OS: ").append(System.getProperty("os.name")).append(" (").append(System.getProperty("os.arch")).append(") version ").append(System.getProperty("os.version")).append("\n").toString();
s2 = (new StringBuilder()).append(s2).append("Java: ").append(System.getProperty("java.version")).append(", ").append(System.getProperty("java.vendor")).append("\n").toString();
s2 = (new StringBuilder()).append(s2).append("VM: ").append(System.getProperty("java.vm.name")).append(" (").append(System.getProperty("java.vm.info")).append("), ").append(System.getProperty("java.vm.vendor")).append("\n").toString();
s2 = (new StringBuilder()).append(s2).append("LWJGL: ").append(Sys.getVersion()).append("\n").toString();
s1 = GL11.glGetString(7936);
s2 = (new StringBuilder()).append(s2).append("OpenGL: ").append(GL11.glGetString(7937)).append(" version ").append(GL11.glGetString(7938)).append(", ").append(GL11.glGetString(7936)).append("\n").toString();
}
catch(Throwable throwable)
{
s2 = (new StringBuilder()).append(s2).append("[failed to get system properties (").append(throwable).append(")]\n").toString();
}
s2 = (new StringBuilder()).append(s2).append("\n").toString();
s2 = (new StringBuilder()).append(s2).append(s).toString();
String s3 = "";
s3 = (new StringBuilder()).append(s3).append("\n").toString();
s3 = (new StringBuilder()).append(s3).append("\n").toString();
if(s.contains("Pixel format not accelerated"))
{
s3 = (new StringBuilder()).append(s3).append(" Bad video card drivers! \n").toString();
s3 = (new StringBuilder()).append(s3).append(" ----------------------- \n").toString();
s3 = (new StringBuilder()).append(s3).append("\n").toString();
s3 = (new StringBuilder()).append(s3).append("Minecraft was unable to start because it failed to find an accelerated OpenGL mode.\n").toString();
s3 = (new StringBuilder()).append(s3).append("This can usually be fixed by updating the video card drivers.\n").toString();
if(s1.toLowerCase().contains("nvidia"))
{
s3 = (new StringBuilder()).append(s3).append("\n").toString();
s3 = (new StringBuilder()).append(s3).append("You might be able to find drivers for your video card here:\n").toString();
s3 = (new StringBuilder()).append(s3).append(" http://www.nvidia.com/\n").toString();
} else
if(s1.toLowerCase().contains("ati"))
{
s3 = (new StringBuilder()).append(s3).append("\n").toString();
s3 = (new StringBuilder()).append(s3).append("You might be able to find drivers for your video card here:\n").toString();
s3 = (new StringBuilder()).append(s3).append(" http://www.amd.com/\n").toString();
}
} else
{
s3 = (new StringBuilder()).append(s3).append(" Minecraft has crashed! \n").toString();
s3 = (new StringBuilder()).append(s3).append(" ---------------------- \n").toString();
s3 = (new StringBuilder()).append(s3).append("\n").toString();
s3 = (new StringBuilder()).append(s3).append("Minecraft has stopped running because it encountered a problem.\n").toString();
s3 = (new StringBuilder()).append(s3).append("\n").toString();
s3 = (new StringBuilder()).append(s3).append("If you wish to report this, please copy this entire text and email it to [email protected]\n").toString();
s3 = (new StringBuilder()).append(s3).append("Please include a description of what you did when the error occured.\n").toString();
}
s3 = (new StringBuilder()).append(s3).append("\n").toString();
s3 = (new StringBuilder()).append(s3).append("\n").toString();
s3 = (new StringBuilder()).append(s3).append("\n").toString();
s3 = (new StringBuilder()).append(s3).append("--- BEGIN ERROR REPORT ").append(Integer.toHexString(s3.hashCode())).append(" --------\n").toString();
s3 = (new StringBuilder()).append(s3).append(s2).toString();
s3 = (new StringBuilder()).append(s3).append("--- END ERROR REPORT ").append(Integer.toHexString(s3.hashCode())).append(" ----------\n").toString();
s3 = (new StringBuilder()).append(s3).append("\n").toString();
s3 = (new StringBuilder()).append(s3).append("\n").toString();
TextArea textarea = new TextArea(s3, 0, 0, 1);
textarea.setFont(new Font("Monospaced", 0, 12));
add(new CanvasMajongLogo(), "North");
add(new CanvasCrashReport(80), "East");
add(new CanvasCrashReport(80), "West");
add(new CanvasCrashReport(100), "South");
add(textarea, "Center");
}
示例7: stream
//------------------------------------------------------------------------
// XmlRepresentationHelper Implementation
//------------------------------------------------------------------------
XmlRepresentationHelper::XmlRepresentationHelper (const Vst::RepresentationInfo& info,
const FIDString companyName,
const FIDString pluginName, const TUID& pluginUID,
IBStream* stream)
: stream (stream)
{
StringWriter writer (stream);
String string;
writer.write ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
writer.write (ENDLINE_A);
string.printf ("<!DOCTYPE %s PUBLIC \"-//Steinberg//DTD VST Remote 1.1//EN\" \"http://dtd.steinberg.net/VST-Remote-1.1.dtd\">", ROOTXML_TAG);
writer.write (string.text8 ());
writer.write (ENDLINE_A);
string.printf ("<%s %s=\"1.0\">", ROOTXML_TAG, ATTR_VERSION);
writer.write (string.text8 ());
writer.write (ENDLINE_A);
//---Plug-in Tag----------------
FUID uid (pluginUID);
char uidText[33];
uid.toString (uidText);
string.printf ("<%s %s=\"%s\" %s=\"%s\" %s=\"%s\"/>", PLUGIN_TAG, ATTR_CLASSID, uidText, ATTR_NAME, pluginName, ATTR_VENDOR, companyName);
writer.write (string);
writer.write (ENDLINE_A);
//---Representation Tag----------------
string.printf ("\t<%s", REPRESENTATION_TAG);
writer.write (string);
string.printf (" %s=\"%s\"", ATTR_NAME, info.name);
writer.write (string);
string.printf (" %s=\"%s\"", ATTR_VENDOR, info.vendor);
writer.write (string);
string.printf (" %s=\"%s\"", ATTR_VERSION, info.version);
writer.write (string);
if (strcmp ((char*)info.host, ""))
{
string.printf (" %s=\"%s\"", ATTR_HOST, info.host);
writer.write (string);
}
writer.write (">");
writer.write (ENDLINE_A);
state = kInRepresentation;
}
示例8: print
static size_t print(StringWriter& sb, const char* s) {
return sb.write(reinterpret_cast<const uint8_t*>(s), strlen(s));
}
示例9: nameString
//------------------------------------------------------------------------
bool XmlRepresentationHelper::startEndTitleDisplay (Vst::ParameterInfo& info)
{
String nameString (info.title);
if (nameString.isEmpty ())
return false;
if (!checkState (kInTitleDisplay))
return false;
StringWriter writer (stream);
String string;
string.printf ("<%s>", TITLEDISPLAY_TAG);
writer.write (string);
writer.write (ENDLINE_A);
// start of name scope
if (!checkState (kInName))
{
string.printf ("%s", END_TAG_STRING (TITLEDISPLAY_TAG));
writer.write (string);
writer.write (ENDLINE_A);
return false;
}
string.printf ("<%s>%s</%s>", NAME_TAG, nameString.text8 (), NAME_TAG);
writer.write (string);
writer.write (ENDLINE_A);
if (nameString.length () > MEDIUM_TITLE_LIMIT)
{
nameString.assign (info.shortTitle);
if (! nameString.isEmpty ())
{
nameString.removeChars (); // remove space
if (nameString.length () > MEDIUM_TITLE_LIMIT)
nameString.remove (MEDIUM_TITLE_LIMIT); // Trimming the rest to get a short string
string.printf ("<%s>%s</%s>", NAME_TAG, nameString.text8 (), NAME_TAG);
writer.write (string);
writer.write (ENDLINE_A);
}
}
if (nameString.length () > SHORT_TITLE_LIMIT)
{
nameString.remove (SHORT_TITLE_LIMIT); // Trimming the rest to get a short string
string.printf ("<%s>%s</%s>", NAME_TAG, nameString.text8 (), NAME_TAG);
writer.write (string);
writer.write (ENDLINE_A);
}
if (!checkState (kInTitleDisplay))
return false;
// end of name scope
string.printf ("%s", END_TAG_STRING (TITLEDISPLAY_TAG));
writer.write (string);
writer.write (ENDLINE_A);
if (!checkState (kInLayer))
return false;
return true;
}