Exemple #1
0
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());
}
//------------------------------------------------------------------------
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;
}
//------------------------------------------------------------------------
bool XmlRepresentationHelper::endLayer ()
{
	if (!checkState (kInCell))
		return false;

	StringWriter writer (stream);
	String string;
	string.printf ("%s", END_TAG_STRING(LAYER_TAG));
	writer.write (string);
	writer.write (ENDLINE_A);

	return true;
}
//------------------------------------------------------------------------
bool XmlRepresentationHelper::startEndCell ()
{
	if (!checkState (kInCell))
		return false;

	StringWriter writer (stream);
	String string;
	string.printf ("<%s/>", CELL_TAG);
	writer.write (string);
	writer.write (ENDLINE_A);

	if (!checkState (kInPage))
		return false;
	return true;
}
//------------------------------------------------------------------------
bool XmlRepresentationHelper::startPage (FIDString name, int32 unitID)
{
	if (!checkState (kInPage))
		return false;

	StringWriter writer (stream);
	String string;
	if (unitID != -1)
		string.printf ("<%s %s=\"%s\" %s=\"%d\">", PAGE_TAG, ATTR_NAME, name, ATTR_UNITID, unitID);
	else
		string.printf ("<%s %s=\"%s\">", PAGE_TAG, ATTR_NAME, name);
	writer.write (string);
	writer.write (ENDLINE_A);

	return true;
}
Exemple #6
0
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;
}
//------------------------------------------------------------------------
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);
}
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]);
  };
};
//------------------------------------------------------------------------
bool XmlRepresentationHelper::startLayer (int32 type, int32 id, FIDString _function, FIDString style, bool ended)
{
	if (!checkState (kInLayer))
		return false;

	StringWriter writer (stream);
	String string;

	string.printf ("<%s %s=\"%s\" %s=\"%d\"", LAYER_TAG, ATTR_TYPE, Vst::LayerType::layerTypeFIDString[type], ATTR_PARAMID, id);
	writer.write (string);

	if (_function)
	{
		string.printf (" %s=\"%s\"", Vst::Attributes::kFunction, _function);
		writer.write (string);
	}
	if (style)
	{
		string = Vst::LayerType::layerTypeFIDString[type];
		if (type == Vst::LayerType::kSwitch)
			string.printf (" %s=\"%s\"", Vst::Attributes::kSwitchStyle, style);
		else if (type == Vst::LayerType::kLED)
			string.printf (" %s=\"%s\"", Vst::Attributes::kLEDStyle, style);
		else
			string.printf (" %s=\"%s\"",  Vst::Attributes::kStyle, style);
		writer.write (string);
	}

	if (ended)
	{
		writer.write ("/>");
		if (!checkState (kInCell))
			return false;
	}
	else
		writer.write (">");
	writer.write (ENDLINE_A);

	return true;
}
Exemple #10
0
TEST_F(StringWriterTest, WriteFormatU) {
  StringWriter buf;
  buf.Write("%u %d", -1234, static_cast<uint32>(-1234));
  // Note: first one is static_cast<int64>(-1234)
  EXPECT_STREQ(L"18446744073709550382 4294966062", buf.ToString().value());
}
Exemple #11
0
TEST_F(StringWriterTest, WriteFormatR) {
  StringWriter buf;
  buf.Write("%r %R", 12345, 12345);
  EXPECT_STREQ(L"9ix 9IX", buf.ToString().value());
}
Exemple #12
0
TEST_F(StringWriterTest, WriteFormatS) {
  StringWriter buf;
  buf.Write("%s %5s %-5s", "foo", "bar", "baz");
  EXPECT_STREQ(L"foo bar     baz", buf.ToString().value());
}
Exemple #13
0
TEST_F(StringWriterTest, WriteFormatD) {
  StringWriter buf;
  buf.Write("%d %4d %-4d %04d %+d", 12, 34, 56, 78, 90);
  EXPECT_STREQ(L"12 34     56 0078 +90", buf.ToString().value());
}
Exemple #14
0
TEST_F(StringWriterTest, WriteFormatD2) {
  StringWriter buf;
  buf.Write("%d %4d %-4d %04d %+d", -12, -34, -56, -78, -90);
  EXPECT_STREQ(L"-12 -34   -56 0-78 -90", buf.ToString().value());
}
Exemple #15
0
TEST_F(StringWriterTest, WriteFormatC) {
  StringWriter buf;
  buf.Write("%c", 'a');
  EXPECT_STREQ(L"a", buf.ToString().value());
}
Exemple #16
0
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");
}
//------------------------------------------------------------------------
// 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;
}
static size_t print(StringWriter& sb, const char* s) {
  return sb.write(reinterpret_cast<const uint8_t*>(s), strlen(s));
}
Exemple #19
0
TEST_F(StringWriterTest, WriteFormatX) {
  StringWriter buf;
  buf.Write("%x %X", 0xBEEF, 0xFEED);
  EXPECT_STREQ(L"beef FEED", buf.ToString().value());
}
Exemple #20
0
TEST_F(StringWriterTest, WriteString) {
  StringWriter buf;
  buf.Write("abc");
  buf.Write(L"XYZ");
  EXPECT_STREQ(L"abcXYZ", buf.ToString().value());
}
//------------------------------------------------------------------------
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;
}