Пример #1
0
//------------------------------------------------------------------------
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;
}
Пример #2
0
//------------------------------------------------------------------------
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;
}
Пример #3
0
//------------------------------------------------------------------------
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;
}
Пример #4
0
//------------------------------------------------------------------------
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;
}
Пример #5
0
//------------------------------------------------------------------------
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);
}
Пример #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;
}
Пример #7
0
//------------------------------------------------------------------------
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;
}
Пример #8
0
//------------------------------------------------------------------------
// 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;
}
Пример #9
0
//------------------------------------------------------------------------
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;
}
Пример #10
0
static size_t print(StringWriter& sb, const char* s) {
  return sb.write(reinterpret_cast<const uint8_t*>(s), strlen(s));
}