Ejemplo n.º 1
0
		void Writer::writeArray(Appender& appender, const Value& value, Size indent)
		{
			appender.append("[" + lineBreak());
			for (Size i = 0; i < value.getLength(); i++)
			{
				appender.append(space(indent + 1));
				write(appender, value.get(i), indent + 1);
				if (i + 1 != value.getLength())
				{
					appender.append(",");
				}
				appender.append(lineBreak());
			}
			appender.append(space(indent) + "]");
		}
Ejemplo n.º 2
0
		void Writer::writeObject(Appender& appender, const Value& value, Size indent)
		{
			appender.append("{" + lineBreak());
			auto propNames = value.getPropertyNames();
			for (Size i = 0; i < propNames.size(); i++)
			{
				const std::string& name = propNames[i];
				appender.append(space(indent + 1) + '"' + name + "\": ");
				write(appender, value.get(name), indent + 1);
				if (i + 1 != propNames.size())
				{
					appender.append(",");
				}
				appender.append(lineBreak());
			}
			appender.append(space(indent) + "}");
		}
Ejemplo n.º 3
0
		size_t dispatch_to_string(const Arg& arg, Appender& app, FmtFlags flags,
								  integral_constant<bool, false> has_overload2_opt,
								  integral_constant<bool, true> has_overload1_opt,
								  integral_constant<bool, b1> has_overload2,
								  integral_constant<bool, b2> has_overload1)
		{
			auto string = to_string(arg, flags);
			app.append(string);
			return string.size();
		}
Ejemplo n.º 4
0
		void generic_append(char const *begin,char const *end,Appender &a)
		{
			a.append('"');
			char const *i,*last;
			char buf[8] = "\\u00";
			for(i=begin,last = begin;i!=end;) {
				char const *addon = 0;
				unsigned char c=*i;
				switch(c) {
				case 0x22: addon = "\\\""; break;
				case 0x5C: addon = "\\\\"; break;
				case '\b': addon = "\\b"; break;
				case '\f': addon = "\\f"; break;
				case '\n': addon = "\\n"; break;
				case '\r': addon = "\\r"; break;
				case '\t': addon = "\\t"; break;
				default:
					if(c<=0x1F) {
						static char const tohex[]="0123456789abcdef";
						buf[4]=tohex[c >>  4];
						buf[5]=tohex[c & 0xF];
						buf[6]=0;
						addon = buf;
					}
				};
				if(addon) {
					a.append(last,i-last);
					a.append(addon);
					i++;
					last = i;
				}
				else {
					i++;
				}
			}
			a.append(last,i-last);
			a.append('"');
		}
Ejemplo n.º 5
0
// gather command from serial input
// this may be performed in multiple passes - only a newline (not stored) marks command ready to process
void processSerialCommands() {
	int inch;

	// append any newly arrived chars & execute command if return received
	while ((inch = Serial.read()) >= 0) {
		if (inch == '\n') { // end of line
			if(doCommand(commandBuffer)) {
				showPrompt();
			}

			commandAp.reset();
			return; // process at most one command per loop
		}
		else { // continue line
			commandAp.append((char) inch);
		}
	}
}
Ejemplo n.º 6
0
		size_t dispatch_to_string(const basic_string_view<CharT, Traits>& arg, Appender& app, FmtFlags flags)
		{
			app.append(arg);
			return arg.size();
		}
Ejemplo n.º 7
0
 void assertString(const vespalib::string &input, const vespalib::string &output) {
     std::vector<char> buf;
     _appender.append(buf, input.c_str(), input.size());
     EXPECT_EQUAL(output, vespalib::string(&buf[0], buf.size()));
 }
Ejemplo n.º 8
0
		void Writer::writeString(Appender& appender, const std::string& value)
		{
			appender.append('"' + value + '"');
		}
Ejemplo n.º 9
0
		void Writer::writeNumber(Appender& appender, Float64 value)
		{
			appender.append(std::floor(value) == value ? std::to_string((Int32) value) : std::to_string(value));
		}
Ejemplo n.º 10
0
		void Writer::writeBoolean(Appender& appender, bool value)
		{
			appender.append(value ? "true" : "false");
		}
Ejemplo n.º 11
0
		void Writer::writeNull(Appender& appender)
		{
			appender.append("null");
		}