예제 #1
0
uint32_t TDebugProtocol::startItem() {
  uint32_t size;

  switch (write_state_.back()) {
    case UNINIT:
      // XXX figure out what to do here.
      //throw TProtocolException(TProtocolException::INVALID_DATA);
      //return writeIndented(str);
      return 0;
    case STRUCT:
      return 0;
    case SET:
      return writeIndented("");
    case MAP_KEY:
      return writeIndented("");
    case MAP_VALUE:
      return writePlain(" -> ");
    case LIST:
      size = writeIndented(
          "[" + boost::lexical_cast<string>(list_idx_.back()) + "] = ");
      list_idx_.back()++;
      return size;
    default:
      throw std::logic_error("Invalid enum value.");
  }
}
예제 #2
0
void JSONWriter::writeKey(std::string key){
	if (_options == SER_OPT_FORMATTED){
		writeIndented("\"" + key + "\"");
	}
	else{
		writeRaw("\"" + key + "\"");
	}
}
예제 #3
0
uint32_t TDebugProtocol::writeSetEnd() {
  indentDown();
  write_state_.pop_back();
  uint32_t size = 0;
  size += writeIndented("}");
  size += endItem();
  return size;
}
예제 #4
0
uint32_t TDebugProtocol::writeFieldBegin(const char* name,
                                         const TType fieldType,
                                         const int16_t fieldId) {
  // sprintf(id_str, "%02d", fieldId);
  string id_str = boost::lexical_cast<string>(fieldId);
  if (id_str.length() == 1) id_str = '0' + id_str;

  return writeIndented(
      id_str + ": " +
      name + " (" +
      fieldTypeName(fieldType) + ") = ");
}
예제 #5
0
void JSONWriter::writeStartArray(){
	if (_options == SER_OPT_FORMATTED && typeStack.top() == JSON_ARRAY){
		writeIndented("[");
	}
	else{
		writeRaw("[");
	}
	if (_options == SER_OPT_FORMATTED){
		indent++;
	}
	typeStack.push(JSON_ARRAY);
}
예제 #6
0
uint32_t TDebugProtocol::writeMessageBegin(const std::string& name,
                                           const TMessageType messageType,
                                           const int32_t seqid) {
  string mtype;
  switch (messageType) {
    case T_CALL      : mtype = "call"  ; break;
    case T_REPLY     : mtype = "reply" ; break;
    case T_EXCEPTION : mtype = "exn"   ; break;
    case T_ONEWAY    : mtype = "oneway"; break;
  }

  uint32_t size = writeIndented("(" + mtype + ") " + name + "(");
  indentUp();
  return size;
}
예제 #7
0
uint32_t DebugProtocolWriter::writeMessageBegin(const std::string& name,
                                                MessageType messageType,
                                                int32_t seqid) {
  std::string mtype;
  switch (messageType) {
  case T_CALL:      mtype = "call";   break;
  case T_REPLY:     mtype = "reply";  break;
  case T_EXCEPTION: mtype = "exn";    break;
  case T_ONEWAY:    mtype = "oneway"; break;
  }

  writeIndented("({}) {}(", mtype, name);
  indentUp();
  return 0;
}
예제 #8
0
void DebugProtocolWriter::startItem() {
  if (writeState_.empty()) {  // top level
    return;
  }
  auto& ws = writeState_.back();
  switch (ws.type) {
  case STRUCT:
    break;
  case SET:
  case MAP_KEY:
    writeIndent();
    break;
  case MAP_VALUE:
    writePlain(" -> ");
    break;
  case LIST:
    writeIndented("[{}] = ", ws.index);
    break;
  }
}
예제 #9
0
uint32_t TDebugProtocol::writeMessageEnd() {
  indentDown();
  return writeIndented(")\n");
}
예제 #10
0
uint32_t DebugProtocolWriter::writeSetEnd() {
  popState();
  writeIndented("}}");
  endItem();
  return 0;
}
예제 #11
0
uint32_t DebugProtocolWriter::writeFieldBegin(const char* name,
                                              TType fieldType,
                                              int16_t fieldId) {
  writeIndented("{:0d}: {} ({}) = ", fieldId, name, fieldTypeName(fieldType));
  return 0;
}
예제 #12
0
uint32_t DebugProtocolWriter::writeMessageEnd() {
  indentDown();
  writeIndented(")\n");
  return 0;
}