Example #1
0
String ScrollingStateNode::scrollingStateTreeAsText() const
{
    TextStream ts;

    dump(ts, 0);
    return ts.release();
}
Example #2
0
String GraphicsLayer::layerTreeAsText(LayerTreeAsTextBehavior behavior) const
{
    TextStream ts;

    dumpLayer(ts, 0, behavior);
    return ts.release();
}
Example #3
0
 static String htmlForLink(int x, int y, int width, int height, const char* url)
 {
     TextStream ts;
     ts << "<a style='position: absolute; left: " << x << "px; top: " << y << "px; width: " << width << "px; height: " << height
         << "px' href='" << url << "'>" << url << "</a>";
     return ts.release();
 }
Example #4
0
void PDFDocumentImage::dump(TextStream& ts) const
{
    Image::dump(ts);
    ts.dumpProperty("page-count", pageCount());
    ts.dumpProperty("crop-box", m_cropBox);
    if (m_rotationDegrees)
        ts.dumpProperty("rotation", m_rotationDegrees);
}
Example #5
0
void QChemInput::readEfpParamsSection(TextStream& textStream)
{
   EfpFragment parser;
   while (!textStream.atEnd()) {
      parser.loadNextFragment(textStream);
      if (textStream.previousLine().contains("$end", Qt::CaseInsensitive)) break;
   }
}
Example #6
0
String GraphicsLayer::layerTreeAsText(LayerTreeFlags flags) const
{
    TextStream ts;

    RenderingContextMap renderingContextMap;
    dumpLayer(ts, 0, flags, renderingContextMap);
    return ts.release();
}
Example #7
0
void Image::dump(TextStream& ts) const
{
    if (isAnimated())
        ts.dumpProperty("animated", isAnimated());

    if (isNull())
        ts.dumpProperty("is-null-image", true);

    ts.dumpProperty("size", size());
}
Example #8
0
bool
AsxParser::ParseBuffer (MemoryBuffer *buffer)
{
	this->buffer = buffer;
	TextStream *stream = new TextStream ();
	buffer->SeekSet (0);
	stream->OpenBuffer ((char *) buffer->GetCurrentPtr (), buffer->GetSize ());

	return parser->parse_stream (stream);
}
static String externalRepresentation(RenderBox* renderer, RenderAsTextBehavior behavior)
{
    TextStream ts;
    if (!renderer->hasLayer())
        return ts.release();

    RenderLayer* layer = renderer->layer();
    RenderTreeAsText::writeLayers(ts, layer, layer, layer->rect(), 0, behavior);
    return ts.release();
}
Example #10
0
String LayerRendererChromium::layerTreeAsText() const
{
    TextStream ts;
    if (rootLayer()) {
        ts << rootLayer()->layerTreeAsText();
        ts << "RenderSurfaces:\n";
        dumpRenderSurfaces(ts, 1, rootLayer());
    }
    return ts.release();
}
Example #11
0
MacroDef::eAppendStat MacroDef::AppendMacroExpansion
(TextStream & text)
{
  char c;
  bool stat;
  while (text.Consume(c))
    {
	  if ('%' == c)
		{
		  if (text.Expect ("%"))
			{
			  // escape of '%' character: that's OK
			  _definition.Append (c);
			  _definition.Append (c);
			  continue;
			}

		  int argIdx = 0;
		  for (int digitCount = 0; digitCount < 2; digitCount++)
			{
			  stat = text.Consume(c);
			  if (! stat)
				{
				  return kAppendBadArg;
				}
			  if ((c >= '0') && (c <= '9'))
				{
				  // valid arg values
				  if (0 == digitCount)
					{
					  _definition.Append ('%');
					}
				  _definition.Append (c);
				  argIdx = argIdx*10 + (c - '0');
				  if (argIdx > _numArgs)
					{
					  return kAppendArgRange;
					}
				  continue;
				}
			  else
				{
				  return kAppendBadArg;
				}
			}
		}

	  else
		{
		  _definition.Append (c);
		}
    }
  return kAppendNoError;
}
Example #12
0
void QChemInput::readEfpFragmentSection(TextStream& textStream)
{
   // Check for an existing list from the $molecule section
   Data::EfpFragmentList* efps(0);
   QList<Data::EfpFragmentList*> lists = m_dataBank.findData<Data::EfpFragmentList>();
   if (lists.isEmpty()) {
      efps = new Data::EfpFragmentList;
      m_dataBank.append(efps);
   }else {
      efps = lists.last();
   }

   QString msg("Invalid $efp_fragments format on line ");
   QStringList tokens;
   bool ok, allOk;
   int count(1);

   while (!textStream.atEnd()) {
      tokens = textStream.nextLineAsTokens();

      if (tokens.size() == 1 && tokens[0].contains("$end", Qt::CaseInsensitive)) {
         break;

      }else if (tokens.size() < 7) {
         Data::EfpFragment* efp(0);
         if (count <= efps->size()) {
            efp = efps->at(count-1);
         }else {
            efp = new Data::EfpFragment;
            efps->append(efp);
         }
         efp->setName(tokens[0]);
 
      }else {
         allOk = true;
         QString name(tokens[0]);
         double x, y, z, a, b, c;
         if (allOk) x = tokens[1].toDouble(&ok);  allOk = allOk && ok;
         if (allOk) y = tokens[2].toDouble(&ok);  allOk = allOk && ok;
         if (allOk) z = tokens[3].toDouble(&ok);  allOk = allOk && ok;
         if (allOk) a = tokens[4].toDouble(&ok);  allOk = allOk && ok;
         if (allOk) b = tokens[5].toDouble(&ok);  allOk = allOk && ok;
         if (allOk) c = tokens[6].toDouble(&ok);  allOk = allOk && ok;

         if (allOk) {
            efps->append(new Data::EfpFragment(name, qglviewer::Vec(x,y,z), a, b, c));
         }else {
            m_errors.append(msg += QString::number(textStream.lineNumber()));
         }
      }
      ++count;
   }
}
Example #13
0
void DisplayList::dump(TextStream& ts) const
{
    TextStream::GroupScope group(ts);
    ts << "display list";

    size_t numItems = m_list.size();
    for (size_t i = 0; i < numItems; ++i) {
        TextStream::GroupScope scope(ts);
        ts << i << " " << m_list[i].get();
    }
    ts.startGroup();
    ts << "size in bytes: " << sizeInBytes();
    ts.endGroup();
}
String counterValueForElement(Element* element)
{
    // Make sure the element is not freed during the layout.
    RefPtr<Element> elementRef(element);
    element->document()->updateLayout();
    TextStream stream;
    bool isFirstCounter = true;
    // The counter renderers should be children of :before or :after pseudo-elements.
    if (RenderObject* before = element->pseudoElementRenderer(BEFORE))
        writeCounterValuesFromChildren(stream, before, isFirstCounter);
    if (RenderObject* after = element->pseudoElementRenderer(AFTER))
        writeCounterValuesFromChildren(stream, after, isFirstCounter);
    return stream.release();
}
Example #15
0
char *
Downloader::GetResponseText (const char *partname, gint64 *size)
{
	LOG_DOWNLOADER ("Downloader::GetResponseText (%s, %p)\n", partname, size);

	TextStream *stream;
	char buffer[4096];
	GByteArray *buf;
	struct stat st;
	ssize_t nread;
	char *data;
	char *path;
	
	if (!(path = GetDownloadedFilename (partname)))
		return NULL;
	
	if (g_stat (path, &st) == -1) {
		g_free (path);
		return NULL;
	}
	
	if (st.st_size > 0) {
		stream = new TextStream ();
		
		if (!stream->OpenFile (path, true)) {
			delete stream;
			g_free (path);
			return NULL;
		}
		
		g_free (path);
		
		buf = g_byte_array_new ();
		while ((nread = stream->Read (buffer, sizeof (buffer))) > 0)
			g_byte_array_append (buf, (const guint8 *) buffer, nread);
		
		*size = buf->len;
		
		g_byte_array_append (buf, (const guint8 *) "", 1);
		data = (char *) buf->data;
		
		g_byte_array_free (buf, false);
		delete stream;
	} else {
		data = g_strdup ("");
		*size = 0;
	}
	
	return data;
}
Example #16
0
    void testConstructFromStream(){
        TextStream stream;
        stream.writeLine( "MasterFeder=1" );
        stream.writeLine( "MasterPanpot=2" );
        stream.writeLine( "MasterMute=3" );
        stream.writeLine( "OutputMode=4" );
        stream.writeLine( "Tracks=1" );
        stream.writeLine( "Feder0=5" );
        stream.writeLine( "Panpot0=6" );
        stream.writeLine( "Mute0=7" );
        stream.writeLine( "Solo0=8" );
        stream.setPointer( -1 );

        std::string lastLine = "";
        Mixer mixer( stream, lastLine );

        CPPUNIT_ASSERT_EQUAL( (std::size_t)1, mixer.slave.size() );
        CPPUNIT_ASSERT_EQUAL( 1, mixer.masterFeder );
        CPPUNIT_ASSERT_EQUAL( 2, mixer.masterPanpot );
        CPPUNIT_ASSERT_EQUAL( 3, mixer.masterMute );
        CPPUNIT_ASSERT_EQUAL( 4, mixer.outputMode );
        CPPUNIT_ASSERT_EQUAL( 5, mixer.slave[0].feder );
        CPPUNIT_ASSERT_EQUAL( 6, mixer.slave[0].panpot );
        CPPUNIT_ASSERT_EQUAL( 7, mixer.slave[0].mute );
        CPPUNIT_ASSERT_EQUAL( 8, mixer.slave[0].solo );
    }
bool ExternalCharges::parse(TextStream& textStream) 
{
   int max(INT_MAX);
   bool allOk(true), isDouble;
   bool maxSet(false), invalidFormat(false);
   double x, y, z, q;
   QStringList tokens;
   Data::PointChargeList* charges(new Data::PointChargeList);

   while (!textStream.atEnd() && charges->size() < max) {
      tokens = textStream.nextLineAsTokens();
      if (tokens.size() >= 4) {
         x = tokens[0].toDouble(&isDouble);  allOk = allOk && isDouble;
         y = tokens[1].toDouble(&isDouble);  allOk = allOk && isDouble;
         z = tokens[2].toDouble(&isDouble);  allOk = allOk && isDouble;
         q = tokens[3].toDouble(&isDouble);  allOk = allOk && isDouble;

         if (allOk) {
            charges->append(new Data::PointCharge(q, qglviewer::Vec(x,y,z)));
         }else {
            invalidFormat = true;
            break;
         }
      }else if (tokens.size() >= 1) {
         if (tokens.first().contains("$end", Qt::CaseInsensitive) || maxSet) {
            break;
         }else {
            max = tokens[0].toInt(&maxSet);
         }
      }
   } 

   if (maxSet && charges->size() != max) {
      if (invalidFormat) {
         QString msg("Invalid format on line ");
         m_errors.append(msg += QString::number(textStream.lineNumber()));
      }else {
         m_errors.append("End of stream encountered");
      }
      delete charges;
   }else if (charges->isEmpty()) {
      m_errors.append("No charges found");
      delete charges;
   }else {
      m_dataBank.append(charges);
   }

   return m_errors.isEmpty();
}
Example #18
0
int main (int argc, const char* argv[])
{
	if (argc != 2) {
		printf ("pass in an ASX file to parse.\n");
		return -1;
	}

	TextStream *ts = new TextStream ();

	printf ("opening the file: %s\n", argv [1]);
	ts->OpenFile (argv [1], true);

	AsxParserInternal *asx = new AsxParserInternal (ts);
	asx->run ();
}
Example #19
0
//------------------------------------------------------------------------------
//!
bool
DFNoiseImageNode::dumpCustom( TextStream& os, StreamIndent& indent ) const
{
   os << indent << "type = " << _type << "," << nl;
   switch( _type )
   {
      case TYPE_CELL:
      case TYPE_PERLIN:
         break;
      case TYPE_PERLIN_FILTERED:
         os << indent << "perfilwidth = " << _perFil._width << "," << nl;
         break;
      case TYPE_VORONOI:
         os << indent << "jitter = " << _vor._jitter << "," << nl;
         break;
      case TYPE_FBM:
         os << indent << "fbmwidth = " << _fbm._width << "," << nl;
         os << indent << "octaves = " << _fbm._octaves << "," << nl;
         os << indent << "lacunarity = " << _fbm._lacunarity << "," << nl;
         os << indent << "gain = " << _fbm._gain << "," << nl;
         break;
      default:
         break;
   }
   return os.ok();
}
Example #20
0
//------------------------------------------------------------------------------
//!
bool
DFMappingNode::dumpCustom( TextStream& os, StreamIndent& indent ) const
{
   os << indent << "scale = " << _scale << "," << nl;
   os << indent << "offset = " << VMFmt( _offset ) << "," << nl;
   return os.ok();
}
String counterValueForElement(Element* element)
{
    // Make sure the element is not freed during the layout.
    RefPtr<Element> elementRef(element);
    element->document()->updateLayout();
    TextStream stream;
    bool isFirstCounter = true;
    // The counter renderers should be children of anonymous children
    // (i.e., :before or :after pseudo-elements).
    if (RenderObject* renderer = element->renderer()) {
        for (RenderObject* child = renderer->firstChild(); child; child = child->nextSibling()) {
            if (child->isAnonymous())
                writeCounterValuesFromChildren(stream, child, isFirstCounter);
        }
    }
    return stream.release();
}
Example #22
0
void PovRay::readNextDeclaration(TextStream& textStream, Data::PovRay* povray)
{
   // looks for '#declare TextureName = '
   const QRegExp declare("^#declare\\s+(\\S+)\\s?="); 

   QString line(textStream.nextLine());
   if (!line.contains(declare)) line = textStream.seek(declare);

   if (!textStream.atEnd() && declare.indexIn(line) > -1) {
      QString name(declare.cap(1));
      // remove the initial IQmol_Texture_
      name.remove(0,14);
      name.replace("_", " ");
      line = textStream.nextBlock();
      povray->addTexture(name,line);
   }
}
Example #23
0
//------------------------------------------------------------------------------
//!
bool
DFDrawCircleNode::dumpCustom( TextStream& os, StreamIndent& indent ) const
{
   os << indent << "color="  << VMFmt(_color)  << "," << nl;
   os << indent << "center=" << VMFmt(_center) << "," << nl;
   os << indent << "radius=" << VMFmt(_radius) << "," << nl;
   return os.ok();
}
Example #24
0
const char*
AsxTokenizer::read_quoted_string (char start)
{
	clear_buffer_str ();

	char c = read_char ();
	while (!stream->Eof () && c != start) {
		g_string_append_c (buffer, c);
		c = read_char ();
	} 

	if (stream->Eof ()) {
		
	}

	return buffer->str;
}
Example #25
0
//------------------------------------------------------------------------------
//!
bool
DFDrawRectNode::dumpCustom( TextStream& os, StreamIndent& indent ) const
{
   os << indent << "color="  << VMFmt(_color)  << "," << nl;
   os << indent << "center=" << VMFmt(_center) << "," << nl;
   os << indent << "size="   << VMFmt(_size)   << "," << nl;
   return os.ok();
}
Example #26
0
void BitmapImage::dump(TextStream& ts) const
{
    Image::dump(ts);

    ts.dumpProperty("type", m_source.filenameExtension());

    if (isAnimated()) {
        ts.dumpProperty("frame-count", m_frameCount);
        ts.dumpProperty("repetitions", m_repetitionCount);
        ts.dumpProperty("current-frame", m_currentFrame);
    }
    
    if (m_solidColor)
        ts.dumpProperty("solid-color", m_solidColor.value());
    
    m_source.dump(ts);
}
Example #27
0
String externalRepresentation(RenderObject* o)
{
    if (!o)
        return String();

    TextStream ts;
#if ENABLE(SVG)
    writeRenderResources(ts, o->document());
#endif
    if (o->view()->frameView())
        o->view()->frameView()->layout();
    RenderLayer* l = o->layer();
    if (l) {
        writeLayers(ts, l, l, IntRect(l->xPos(), l->yPos(), l->width(), l->height()));
        writeSelection(ts, o);
    }
    return ts.release();
}
String externalRepresentation(Frame* frame, RenderAsTextBehavior behavior)
{
    frame->document()->updateLayout();

    RenderObject* o = frame->contentRenderer();
    if (!o)
        return String();

    TextStream ts;
#if ENABLE(SVG)
    writeRenderResources(ts, o->document());
#endif
    if (o->hasLayer()) {
        RenderLayer* l = toRenderBox(o)->layer();
        writeLayers(ts, l, l, IntRect(l->x(), l->y(), l->width(), l->height()), 0, behavior);
        writeSelection(ts, o);
    }
    return ts.release();
}
Example #29
0
bool Cube::parse(TextStream& textStream)
{
   // Header information
   textStream.skipLine(2);

   int nAtoms(parseGridAxes(textStream));
   if (nAtoms == 0) {
      QString msg("Incorrect format on line ");
      msg += QString::number(textStream.lineNumber());
      msg += "\nExpected: <int>  <double>  <double>  <double>";
      m_errors.append(msg);
      return false;
   }

   if (!parseCoordinates(textStream, nAtoms)) return false;
   parseGridData(textStream);

   return m_errors.isEmpty();
}
Example #30
0
String LocalFrame::layerTreeAsText(LayerTreeFlags flags) const
{
    TextStream textStream;
    textStream << localLayerTreeAsText(flags);

    for (Frame* child = tree().firstChild(); child; child = child->tree().traverseNext(this)) {
        if (!child->isLocalFrame())
            continue;
        String childLayerTree = toLocalFrame(child)->localLayerTreeAsText(flags);
        if (!childLayerTree.length())
            continue;

        textStream << "\n\n--------\nFrame: '";
        textStream << child->tree().uniqueName();
        textStream << "'\n--------\n";
        textStream << childLayerTree;
    }

    return textStream.release();
}