Пример #1
0
void
WayPointFileWinPilot::composeFlags(TextWriter &writer,
                                   const WaypointFlags &src)
{
  if (src.Airport)
    writer.write('A');
  if (src.TurnPoint)
    writer.write('T');
  if (src.LandPoint)
    writer.write('L');
  if (src.Home)
    writer.write('H');
  if (src.StartPoint)
    writer.write('S');
  if (src.FinishPoint)
    writer.write('F');
  if (src.Restricted)
    writer.write('R');
  if (src.WaypointFlag)
    writer.write('W');

  // set as turnpoint by default if nothing else
  if (!src.Airport && !src.TurnPoint && !src.LandPoint && !src.Home &&
      !src.StartPoint && !src.FinishPoint && !src.Restricted &&
      !src.WaypointFlag)
    writer.write('T');
}
Пример #2
0
		/// <summary>
		/// レコードを書き込みます。
		/// </summary>
		/// <param name="record">
		/// 書き込むデータ
		/// </param>
		/// <returns>
		/// なし
		/// </returns>
		void write(const String& record)
		{
			if (!std::exchange(m_isHead, false))
			{
				m_writer.write(L',');
			}

			m_writer.write(L'\"');

			m_writer.write(record);

			m_writer.write(L'\"');
		}
Пример #3
0
QString RewriteBinding::rewrite(QString code, unsigned position,
                                AST::Statement *node)
{
    TextWriter w;
    _writer = &w;
    _position = position;
    _inLoop = 0;

    accept(node);

    unsigned startOfStatement = node->firstSourceLocation().begin() - _position;
    unsigned endOfStatement = node->lastSourceLocation().end() - _position;

    _writer->replace(startOfStatement, 0, QLatin1String("(function ") + QString::fromUtf8(_name) + QLatin1String("() { "));
    _writer->replace(endOfStatement, 0, QLatin1String(" })"));

    if (rewriteDump()) {
        qWarning() << "=============================================================";
        qWarning() << "Rewrote:";
        qWarning() << qPrintable(code);
    }

    w.write(&code);

    if (rewriteDump()) {
        qWarning() << "To:";
        qWarning() << qPrintable(code);
        qWarning() << "=============================================================";
    }

    return code;
}
Пример #4
0
void
WaypointWriter::WriteAngle(TextWriter &writer, const Angle &angle,
                           bool is_latitude)
{
  // Calculate degrees, minutes and seconds
  int deg, min, sec;
  bool is_positive;
  angle.ToDMS(deg, min, sec, is_positive);

  // Save them into the buffer string
  writer.printf(is_latitude ? "%02d:%02d:%02d" : "%03d:%02d:%02d", deg, min, sec);

  // Attach the buffer string to the output
  if (is_latitude)
    writer.write(is_positive ? "N" : "S");
  else
    writer.write(is_positive ? "E" : "W");
}
Пример #5
0
static void
write_xml_string(TextWriter &writer, const TCHAR *source)
{
  while (*source) {
    switch (*source) {
    case '<':
      writer.write("&lt;");
      break;
    case '>':
      writer.write("&gt;");
      break;
    case '&':
      writer.write("&amp;");
      break;
    case '\'':
      writer.write("&apos;");
      break;
    case '"':
      writer.write("&quot;");
      break;
    default:
      writer.write(*source);
      break;
    }
    source++;
  }
}
Пример #6
0
void
WaypointWriter::WriteWaypoint(TextWriter &writer, const Waypoint& wp)
{
  // Write the waypoint id
  writer.printf("%u,", wp.original_id > 0 ? wp.original_id : wp.id);

  // Write the latitude
  WriteAngle(writer, wp.location.latitude, true);
  writer.write(',');

  // Write the longitude id
  WriteAngle(writer, wp.location.longitude, false);
  writer.write(',');

  // Write the altitude id
  WriteAltitude(writer, wp.altitude);
  writer.write(',');

  // Write the waypoint flags
  WriteFlags(writer, wp);
  writer.write(',');

  // Write the waypoint name
  writer.write(wp.name.c_str());
  writer.write(',');

  // Write the waypoint description
  writer.writeln(wp.comment.c_str());
}
Пример #7
0
void
WayPointFileWinPilot::composeAngle(TextWriter &writer,
                                   const Angle& src, const bool lat)
{
  // Calculate degrees, minutes and seconds
  int deg, min, sec;
  bool is_positive;
  if (lat)
    Units::LatitudeToDMS(src, &deg, &min, &sec, &is_positive);
  else
    Units::LongitudeToDMS(src, &deg, &min, &sec, &is_positive);

  // Save them into the buffer string
  writer.printf(lat ? "%02d:%02d:%02d" : "%03d:%02d:%02d",
            deg, min, sec);

  // Attach the buffer string to the output
  if (lat)
    writer.write(is_positive ? "N" : "S");
  else
    writer.write(is_positive ? "E" : "W");
}
void CasmReader::readText(charstring Filename,
                          std::shared_ptr<SymbolTable> EnclosingScope) {
  Symtab = std::make_shared<SymbolTable>(EnclosingScope);
  Driver Parser(Symtab);
  if (TraceRead)
    Parser.setTraceParsing(true);
  if (TraceLexer)
    Parser.setTraceLexing(true);
  if (!Parser.parse(Filename)) {
    foundErrors();
    return;
  }
  if (Install)
    Symtab->install();
  if (TraceTree) {
    TextWriter Writer;
    Writer.write(stderr, Symtab.get());
  }
}
Пример #9
0
void
WaypointWriter::WriteFlags(TextWriter &writer, const Waypoint &wp)
{
  if (wp.IsAirport())
    writer.write('A');
  if (wp.flags.turn_point)
    writer.write('T');
  if (wp.IsLandable())
    writer.write('L');
  if (wp.flags.home)
    writer.write('H');
  if (wp.flags.start_point)
    writer.write('S');
  if (wp.flags.finish_point)
    writer.write('F');

  // set as turnpoint by default if nothing else
  if (!wp.flags.turn_point &&
      !wp.IsLandable() &&
      !wp.flags.home &&
      !wp.flags.start_point &&
      !wp.flags.finish_point)
    writer.write('T');
}
Пример #10
0
void
WayPointFileWinPilot::composeLine(TextWriter &writer, const Waypoint& wp)
{
  // Attach the waypoint id to the output
  writer.printf("%u,", wp.id);
  // Attach the latitude to the output
  composeAngle(writer, wp.Location.Latitude, true);
  writer.write(',');
  // Attach the longitude id to the output
  composeAngle(writer, wp.Location.Longitude, false);
  writer.write(',');
  // Attach the altitude id to the output
  composeAltitude(writer, wp.Altitude);
  writer.write(',');
  // Attach the waypoint flags to the output
  composeFlags(writer, wp.Flags);
  writer.write(',');
  // Attach the waypoint name to the output
  writer.write(wp.Name.c_str());
  writer.write(',');
  // Attach the waypoint description to the output
  writer.writeln(wp.Comment.c_str());
}
Пример #11
0
		/// <summary>
		/// 改行します。
		/// </summary>
		/// <returns>
		/// なし
		/// </returns>
		void nextLine()
		{
			m_writer.write(L"\r\n");

			m_isHead = true;
		}
Пример #12
0
void
XMLNode::serialiseR(const XMLNodeData *pEntry, TextWriter &writer, int nFormat)
{
  unsigned cb;
  int nChildFormat = -1;
  bool bHasChildren = false;

  assert(pEntry);

  // If the element has no name then assume this is the head node.
  if (!string_is_empty(pEntry->lpszName)) {
    // "<elementname "
    cb = nFormat == -1 ? 0 : nFormat;

    write_indent(writer, cb);
    writer.write('<');
    if (pEntry->isDeclaration)
      writer.write('?');
    writer.write(pEntry->lpszName);

    // Enumerate attributes and add them to the string
    for (auto i = pEntry->pAttribute.begin(), end = pEntry->pAttribute.end();
         i != end; ++i) {
      const XMLNodeData::Attribute *pAttr = &*i;
      writer.write(' ');
      writer.write(pAttr->lpszName);
      writer.write('=');
      writer.write('"');
      if (pAttr->lpszValue != NULL)
        write_xml_string(writer, pAttr->lpszValue);
      writer.write('"');
      pAttr++;
    }

    bHasChildren = pEntry->HasChildren();
    if (pEntry->isDeclaration) {
      writer.write('?');
      writer.write('>');
      if (nFormat != -1)
        writer.newline();
    } else
    // If there are child nodes we need to terminate the start tag
    if (bHasChildren) {
      writer.write('>');
      if (nFormat != -1)
        writer.newline();
    }
  }

  // Calculate the child format for when we recurse.  This is used to
  // determine the number of spaces used for prefixes.
  if (nFormat != -1) {
    if (!string_is_empty(pEntry->lpszName))
      nChildFormat = nFormat + 1;
    else
      nChildFormat = nFormat;
  }

  /* write the child elements */
  for (auto i = pEntry->begin(), end = pEntry->end(); i != end; ++i)
    serialiseR(i->d, writer, nChildFormat);

  /* write the text */
  if (!pEntry->text.empty()) {
    if (nFormat != -1) {
      write_indent(writer, nFormat + 1);
      write_xml_string(writer, pEntry->text.c_str());
      writer.newline();
    } else {
      write_xml_string(writer, pEntry->text.c_str());
    }
  }

  if (!string_is_empty(pEntry->lpszName) && !pEntry->isDeclaration) {
    // If we have child entries we need to use long XML notation for
    // closing the element - "<elementname>blah blah blah</elementname>"
    if (bHasChildren) {
      // "</elementname>\0"
      if (nFormat != -1)
        write_indent(writer, nFormat);

      writer.write("</");
      writer.write(pEntry->lpszName);

      writer.write('>');
    } else {
      // If there are no children we can use shorthand XML notation -
      // "<elementname/>"
      // "/>\0"
      writer.write("/>");
    }

    if (nFormat != -1)
      writer.newline();
  }
}
Пример #13
0
static void
write_indent(TextWriter &writer, unsigned n)
{
  while (n-- > 0)
    writer.write(INDENTCHAR);
}