Exemplo n.º 1
0
String AsString(double x, int digits)
{
	if(IsNull(x)) return Null;
	if(fabs(x) >= 1e15)
		return FormatDoubleExp(x, tabs(digits), digits < 0 ? FD_ZEROS : 0);
	return FormatDoubleFix(x, tabs(digits), digits < 0 ? FD_ZEROS : 0);
}
Exemplo n.º 2
0
void entertag(psd_file_t f, int level, int len, struct dictentry *parent,
			  struct dictentry *d, int resetpos)
{
	psd_bytes_t savepos = ftello(f);
	int oneline = d->tag[0] == '-';
	char *tagname = d->tag + oneline;

	if(xml){
		// check parent's one-line-ness, because what precedes our <TAG>
		// belongs to our parent.
		fprintf(xml, "%s<%s>", parent->tag[0] == '-' ? " " : tabs(level), tagname);
		if(!oneline)
			fputc('\n', xml);
	}

	d->func(f, level+1, len, d); // parse contents of this datum

	if(xml){
		fprintf(xml, "%s</%s>", oneline ? "" : tabs(level), tagname);
		// if parent's not one-line, then we can safely newline after our tag.
		fputc(parent->tag[0] == '-' ? ' ' : '\n', xml);
	}

	if(resetpos)
		fseeko(f, savepos, SEEK_SET);
}
Exemplo n.º 3
0
static void save(MenuItem *item, FILE *fp, int indent)
{
	unsigned int i;
	if (! item) return;
	tabs(fp, indent);
	fprintf(fp, "\"%s\"", item->title);
	
	switch (item->action)
	{
		case MA_NONE:
			fprintf(fp, "\n");
			tabs(fp, indent);
			fprintf(fp, "{\n");
			tabs(fp, indent);
			fprintf(fp, "}\n");
			break;
		case MA_NEW_MENU:
			fprintf(fp, "\n");
			tabs(fp, indent);
			fprintf(fp, "{\n");
			for (i=0; i<item->num_children; i++)
			{
				save(item->children[i], fp, indent+1);
			}
			tabs(fp, indent);
			fprintf(fp, "}\n");
			break;
		case MA_LAUNCH:
			fprintf(fp, "=\"%s\"\n", item->launch);
			break;
		default:
			break;
	}
}
Exemplo n.º 4
0
void LLXmlTreeParser::startElement(const char* name, const char **atts) 
{
	if( mDump )
	{
		llinfos << tabs() << "startElement " << name << llendl;
		
		S32 i = 0;
		while( atts[i] && atts[i+1] )
		{
			llinfos << tabs() << "attribute: " << atts[i] << "=" << atts[i+1] << llendl;
			i += 2;
		}
	}

	LLXmlTreeNode* child = CreateXmlTreeNode( std::string(name), mCurrent );

	S32 i = 0;
	while( atts[i] && atts[i+1] )
	{
		child->addAttribute( atts[i], atts[i+1] );
		i += 2;
	}

	if( mCurrent )
	{
		mCurrent->addChild( child );

	}
	else
	{
		llassert( !mRoot );
		mRoot = child;
	}
	mCurrent = child;
}
Exemplo n.º 5
0
void  Ctrl::ScrollRefresh(const Rect& r, int dx, int dy)
{
	GuiLock __;
	if(!IsOpen() || !IsVisible() || r.IsEmpty()) return;
	int tdx = tabs(dx), tdy = tabs(dy);
	if(dx) WndInvalidateRect(RectC(dx >= 0 ? r.left : r.right - tdx, r.top - tdy, tdx, r.Height()));
	if(dy) WndInvalidateRect(RectC(r.left - tdx, dy >= 0 ? r.top : r.bottom - tdy, r.Width(), tdy));
}
Exemplo n.º 6
0
void code_while_loop::fprint(std::ostream &dest, int depth)
{
	condition->fprint(dest, depth);
	dest << tabs(depth) << "while (?)\n";
	dest << tabs(depth) << "{\n" << tabs(depth);
	theloop->fprint(dest, depth+1);
	dest << tabs(depth) << "}\n";
}
Exemplo n.º 7
0
static void ir_alphaids(psd_file_t f, int level, int len, struct dictentry *parent){
	if(xml){
		fprintf(xml, "%s<LENGTH>%d</LENGTH>\n", tabs(level), get4B(f));
		len -= 4;
		for(; len >= 4; len -= 4)
			fprintf(xml, "%s<ID>%d</ID>\n", tabs(level), get4B(f));
	}
}
/* print an individual fitness record */
void print_individual_fitness( const individual_fitness* i_fit, int tablevel ) {
	tabs( tablevel );
	printf( "<Individual Fitness Record>\n" );
	tabs( tablevel + 1 );
	printf("Fitness: %d\n", i_fit->fitness );
	print_individual( i_fit->individual, tablevel + 1 );
	tabs( tablevel );
	printf( "</Individual Fitness Record>\n" );
}
Exemplo n.º 9
0
void  Ctrl::ScrollRefresh(const Rect& r, int dx, int dy)
{
	sCheckGuiLock();
	GuiLock __; // Beware: Even if we have ThreadHasGuiLock ASSERT, we still can be the main thread!
	LLOG("ScrollRefresh " << r << " " << dx << " " << dy);
	if(!IsOpen() || !IsVisible() || r.IsEmpty()) return;
	int tdx = tabs(dx), tdy = tabs(dy);
	if(dx) WndInvalidateRect(RectC(dx >= 0 ? r.left : r.right - tdx, r.top - tdy, tdx, r.Height()));
	if(dy) WndInvalidateRect(RectC(r.left - tdx, dy >= 0 ? r.top : r.bottom - tdy, r.Width(), tdy));
}
Exemplo n.º 10
0
	void ActionDefinition::addElement(ElementDefinition *element, int tab)
	{
		if(tab > 0 && tabs().count() > 0)
		{
			if(tab < tabs().count())
				element->setTab(tab);
			else
				qWarning("Trying to add an element with an incorrect tab number");
		}

		mElements.append(element);
	}
Exemplo n.º 11
0
void Block::print(ostream& os, int indent, bool debug) const {
	os << "{";
	os << endl;
	for (auto& instruction : instructions) {
		os << tabs(indent + 1);
		instruction->print(os, indent + 1, debug);
		os << endl;
	}
	os << tabs(indent) << "}";
	if (debug) {
		os << " " << types;
	}
}
Exemplo n.º 12
0
void scope::printExit() {
  // Close this scope
  dbg.ownerAccessing();
  dbg << "\t\t\t"<<tabs(dbg.blockDepth()+1)<<"</td></tr>\n";
  dbg << "\t\t\t"<<tabs(dbg.blockDepth()+1)<<"</table>\n";
  /*if(blockIndex==0) {
    dbg << "\t\t\t"<<tabs(dbg.blockDepth())<<"</td></tr>\n";
    dbg << "\t\t\t"<<tabs(dbg.blockDepth())<<"</table>\n";
  }*/
  //dbg << "\t\t\t"<<tabs(dbg.blockDepth())<<"</td></tr>\n";
  //dbg << "\t\t\t"<<tabs(dbg.blockDepth())<<"<tr width=\"100%\"><td width=0></td><td width=\"100%\">\n";
  dbg.userAccessing();  
}
Exemplo n.º 13
0
void LLXmlTreeParser::comment(const char *data)
{
	if( mDump )
	{
		llinfos << tabs() << "comment " << data << llendl;
	}
}
void LLXmlTreeParser::endCdataSection()
{
	if( mDump )
	{
		LL_INFOS() << tabs() << "endCdataSection" << LL_ENDL;
	}
}
void LLXmlTreeParser::comment(const char *data)
{
	if( mDump )
	{
		LL_INFOS() << tabs() << "comment " << data << LL_ENDL;
	}
}
Exemplo n.º 16
0
  inline void FileParse::getHead(std::ifstream& fin) {
    if (fin.eof()) return;
    // Create a new head node
    HeadNode *node = new HeadNode;

    // Look for the heading. Ends with ":", or "{". If "{" is encountered, body = true.
    bool body = false;
    getHeading(fin, node->heading, body);

    // Message
    message += (tabs() + "Level " + toStr(level) + ": Heading: [" + node->heading + "]\n");

    // Set node as the current head
    node->parent = currentHead;
    currentHead = node;

    // Look for parameters
    bool newLine = passSpaces(fin);
    
    // Get the parameters - adds them to the current head node
    if (!fin.eof() && !newLine && !body)
      body = getParameters(fin);

    ++level;
    if (body && !fin.eof()) getBody(fin);
    --level;

    // Add this node to the parent node
    node->parent->subHeads.push_back(node);

    // Return to parent node
    currentHead = node->parent;
  }
Exemplo n.º 17
0
bool NdbInfo::load_hardcoded_tables(void)
{
  {
    Table tabs("tables", 0);
    if (!tabs.addColumn(Column("table_id", 0, Column::Number)) ||
        !tabs.addColumn(Column("table_name", 1, Column::String)) ||
        !tabs.addColumn(Column("comment", 2, Column::String)))
      return false;

    BaseString hash_key = mysql_table_name(tabs.getName());
    if (!m_tables.insert(hash_key.c_str(), tabs))
      return false;
    if (!m_tables.search(hash_key.c_str(), &m_tables_table))
      return false;
  }

  {
    Table cols("columns", 1);
    if (!cols.addColumn(Column("table_id", 0, Column::Number)) ||
        !cols.addColumn(Column("column_id", 1, Column::Number)) ||
        !cols.addColumn(Column("column_name", 2, Column::String)) ||
        !cols.addColumn(Column("column_type", 3, Column::Number)) ||
        !cols.addColumn(Column("comment", 4, Column::String)))
      return false;

    BaseString hash_key = mysql_table_name(cols.getName());
    if (!m_tables.insert(hash_key.c_str(), cols))
      return false;
    if (!m_tables.search(hash_key.c_str(), &m_columns_table))
      return false;
  }

  return true;
}
Exemplo n.º 18
0
void LLXmlTreeParser::processingInstruction(const char *target, const char *data)
{
	if( mDump )
	{
		llinfos << tabs() << "processingInstruction " << data << llendl;
	}
}
Exemplo n.º 19
0
		void OutputFile::print_line(const std::string& line, size_t tab_num)
		{
			auto s = tabs(tab_num + current_tab_num_) + line  + "\n";
			const char* str = s.c_str();
			int str_size = static_cast<int>(s.size());
			char* buf = nullptr;
			int buf_size = 0;
			while(stream_->Next((void**)&buf, &buf_size))
			{
				if(buf_size > 0)
				{
					auto size = buf_size >= str_size ? str_size : buf_size;
					memcpy(buf, str, size);
					str += size;
					buf_size -= size;
					str_size -= size;

					if(str_size == 0)
					{
						if(buf_size > 0)
						{
							stream_->BackUp(buf_size);
						}
						break;
					}
				}
			}
		}
Exemplo n.º 20
0
static void ir_colorsamplers(psd_file_t f, int level, int len, struct dictentry *parent){
	const char *indent = tabs(level);
	long v = get4B(f), n = get4B(f);
	union { float f; int32_t i; } x, y;
	int space;
	struct colour_space *sp;

	if(xml){
		fprintf(xml, "%s<VERSION>%ld</VERSION>\n", indent, v);
		while(n--){
			fprintf(xml, "%s<SAMPLER>\n", indent);
			if(v >= 3)
				fprintf(xml, "\t%s<VERSION>%d</VERSION>\n", indent, get2B(f)); // doc incorrectly says 4 byte
			y.i = get4B(f);
			x.i = get4B(f);
			if(v == 1)
				fprintf(xml, "\t%s<X>%g</X> <Y>%g</Y>\n", indent, x.i/32., y.i/32.); // undocumented fixed point factor
			else
				fprintf(xml, "\t%s<X>%g</X> <Y>%g</Y>\n", indent, x.f, y.f);
			space = get2B(f);
			if( (sp = find_colour_space(space)) )
				fprintf(xml, "\t%s<COLORSPACE> <%s/> </COLORSPACE>\n", indent, sp->name);
			else
				fprintf(xml, "\t%s<COLORSPACE>%d</COLORSPACE>\n", indent, space);
			if(v >= 2)
				fprintf(xml, "\t%s<DEPTH>%d</DEPTH>\n", indent, get2B(f));
			fprintf(xml, "%s</SAMPLER>\n", indent);
		}
	}
}
Exemplo n.º 21
0
void layerblendmode(psd_file_t f, int level, int len, struct blend_mode_info *bm){
	struct dictentry *d;
	const char *indent = tabs(level);

	if(xml && KEYMATCH(bm->sig, "8BIM")){
		fprintf(xml, "%s<BLENDMODE OPACITY='%g' CLIPPING='%d'>\n",
				indent, bm->opacity/2.55, bm->clipping);
		findbykey(f, level+1, bmdict, bm->key, len, 1);
		if(bm->flags & 1) fprintf(xml, "%s\t<TRANSPARENCYPROTECTED />\n", indent);
		if(bm->flags & 2) fprintf(xml, "%s\t<HIDDEN />\n", indent);
		if((bm->flags & (8|16)) == (8|16))  // both bits set
			fprintf(xml, "%s\t<PIXELDATAIRRELEVANT />\n", indent);
		fprintf(xml, "%s</BLENDMODE>\n", indent);
	}
	if(!xml){
		d = findbykey(f, level+1, bmdict, bm->key, len, 1);
		VERBOSE("  blending mode: sig='%c%c%c%c' key='%c%c%c%c'(%s) opacity=%d(%d%%) clipping=%d(%s)\n\
    flags=%#x(transp_prot%s visible%s bit4valid%s pixel_data_irrelevant%s)\n",
				bm->sig[0],bm->sig[1],bm->sig[2],bm->sig[3],
				bm->key[0],bm->key[1],bm->key[2],bm->key[3],
				d ? d->desc : "???",
				bm->opacity, (bm->opacity*100+127)/255,
				bm->clipping, bm->clipping ? "non-base" : "base",
				bm->flags, BITSTR(bm->flags&1), BITSTR(bm->flags&2), BITSTR(bm->flags&8), BITSTR(bm->flags&16) );
	}
Exemplo n.º 22
0
void LLXmlTreeParser::endCdataSection()
{
	if( mDump )
	{
		llinfos << tabs() << "endCdataSection" << llendl;
	}
}
Exemplo n.º 23
0
struct dictentry *findbykey(psd_file_t f, int level, struct dictentry *parent,
							char *key, int len, int resetpos)
{
	struct dictentry *d;

	for(d = parent; d->key; ++d)
		if(KEYMATCH(key, d->key)){
			char *tagname = d->tag + (d->tag[0] == '-');
			//fprintf(stderr, "matched tag %s\n", d->tag);
			if(d->func)
				entertag(f, level, len, parent, d, resetpos);
			else{
				// there is no function to parse this block.
				// because tag is empty in this case, we only need to consider
				// parent's one-line-ness.
				if(xml){
					if(parent->tag[0] == '-')
						fprintf(xml, " <%s /> <!-- not parsed --> ", tagname);
					else
						fprintf(xml, "%s<%s /> <!-- not parsed -->\n", tabs(level), tagname);
				}
			}
			return d;
		}
	return NULL;
}
Exemplo n.º 24
0
 static DateTimePeriod indexToPeriod(int tabIndex)
 {
     auto allTabs = tabs();
     CVF_ASSERT(tabIndex < (int)allTabs.size());
     DateTimePeriod timePeriod = allTabs[tabIndex];
     return timePeriod;
 }
Exemplo n.º 25
0
static void function (char const * colors [], unsigned count, flag_t flags) 

{ 
	if (_anyset (flags, (OFFSET_HTML | OFFSET_PAGE))) 
	{ 
		html (colors, count, flags); 
	} 
	else if (_anyset (flags, (OFFSET_TEXT))) 
	{ 
		tabs (flags); 
	} 
	else if (_anyset (flags, (OFFSET_EFSU))) 
	{ 
		efsu (flags); 
	} 
	else if (_anyset (flags, (OFFSET_FOLD))) 
	{ 
		fold (flags); 
	} 
	else if (_anyset (flags, (OFFSET_ZERO))) 
	{ 
		zero (flags); 
	} 
	else 
	{ 
		text (flags); 
	} 
	return; 
} 
void LLXmlTreeParser::processingInstruction(const char *target, const char *data)
{
	if( mDump )
	{
		LL_INFOS() << tabs() << "processingInstruction " << data << LL_ENDL;
	}
}
Exemplo n.º 27
0
// Adds an image to the output with the given extension and returns the path of this image
// so that the caller can write to it.
string dbgStream::addImage(string ext)
{
        ostringstream imgFName; imgFName << imgPath << "/image_" << numImages << "." << ext;
        buf.ownerAccessing();
        *(this) << "\t\t\t"<<tabs(buf.funcs.size()+1)<<"<img src="<<imgFName.str()<<">\n";
        buf.userAccessing();
        return imgFName.str();
}
Exemplo n.º 28
0
	tstring XMLFileSerializer::WriteFile(XMLContainer & container)
	{
		tstringstream strstrResult;
		strstrResult << _T("<?xml version=\"1.0\" encoding=\"UTF-8\"?>") << std::endl;
		uint32 tabs(0);
		WriteChild(strstrResult, container, tabs);

		return strstrResult.str();
	}
Exemplo n.º 29
0
void LLXmlTreeParser::defaultData(const char *s, int len)
{
	if( mDump )
	{
		std::string str;
		if (s) str = std::string(s, len);
		llinfos << tabs() << "defaultData " << str << llendl;
	}
}
void LLXmlTreeParser::defaultData(const char *s, int len)
{
	if( mDump )
	{
		std::string str;
		if (s) str = std::string(s, len);
		LL_INFOS() << tabs() << "defaultData " << str << LL_ENDL;
	}
}