コード例 #1
0
		inline void __dumpVariable(Variable* variable)
		{
			switch (variable->type->value)
			{
			case Type::INT8:		stream->write((int)*variable->value<char>());				break;
			case Type::UINT8:		stream->write(*variable->value<unsigned char>());			break;
			case Type::INT16:		stream->write(*variable->value<short>());					break;
			case Type::UINT16:		stream->write(*variable->value<unsigned short>());			break;
			case Type::INT32:		stream->write(*variable->value<int>());						break;
			case Type::UINT32:		stream->write(*variable->value<unsigned int>());			break;
			case Type::INT64:		stream->write(*variable->value<int64_t>());					break;
			case Type::UINT64:		stream->write(*variable->value<uint64_t>());				break;
			case Type::FLOAT:		stream->write(hsprintf("%g", *variable->value<float>()));	break;
			case Type::DOUBLE:		stream->write(hsprintf("%g", *variable->value<double>()));	break;
			case Type::BOOL:		stream->write(*variable->value<bool>());					break;
			case Type::HSTR:		_dump(variable->value<hstr>());								break;
			case Type::HVERSION:	_dump(variable->value<hversion>());							break;
			case Type::HENUM:		_dump(variable->value<henum>());							break;
			case Type::GRECT:		_dump(variable->value<grect>());							break;
			case Type::GVEC2:		_dump(variable->value<gvec2>());							break;
			case Type::GVEC3:		_dump(variable->value<gvec3>());							break;
			case Type::OBJECT:		_dump(variable->value<Serializable>());						break;
			case Type::OBJPTR:		_dump(variable->value<Serializable*>());					break;
			case Type::HARRAY:		__dumpContainer(variable);									break;
			case Type::HMAP:		__dumpContainer(variable);									break;
			default:																			break;
			}
		}
コード例 #2
0
ファイル: TinyXml_Document.cpp プロジェクト: Ryex/libhltypes
TinyXml_Document::TinyXml_Document(chstr filename) : Document(filename), rootNode(NULL)
{
    hstr realFilename = hrdir::normalize(filename);
    hstr data = hresource::hread(this->filename);
    this->document = new TiXmlDocument();
    this->document->Parse(data.c_str());
    if (this->document->Error())
    {
        hstr desc = this->document->ErrorDesc();
        int row = this->document->ErrorRow();
        int col = this->document->ErrorCol();
        if (row != 0)
        {
            desc += hsprintf(" [row %d, column %d]", row, col);
            harray<hstr> lines = data.split("\n");
            if (lines.size() >= row) // just in case!
            {
                desc += "\n----------------------------------------------------------\n";
                desc += lines[row - 1].trim();
                desc += "\n----------------------------------------------------------";
            }
        }
        throw XMLException(hsprintf("An error occcured parsing XML file '%s': %s", realFilename.c_str(), desc.c_str()), NULL);
    }
}
コード例 #3
0
static char *mmcblk_diskname(struct gendisk *disk, int major, int minor)
{
    static char diskname[16];
    char *ptr = diskname;

    ptr += hsprintf(ptr, "%s", disk->name);
    if (major != -1)
        ptr += hsprintf(ptr, "%d", major);
    if (minor != -1)
        ptr += hsprintf(ptr, "p%d", minor);

    return diskname;
};
コード例 #4
0
ファイル: Document.cpp プロジェクト: AprilAndFriends/hltypes
	void Document::_parse()
	{
		if (this->data == NULL)
		{
			if (this->fromResource)
			{
				hresource resource;
				resource.open(this->filename);
				this->_setup(resource, hrdir::normalize(this->filename));
			}
			else
			{
				hfile file;
				file.open(this->filename);
				this->_setup(file, hdir::normalize(this->filename));
			}
		}
		this->document = new rapidxml::xml_document<char>();
		try
		{
			RAPIDXML_DOCUMENT->parse<rapidxml::parse_validate_closing_tags | rapidxml::parse_no_string_terminators | rapidxml::parse_no_data_nodes>(this->data);
		}
		catch (rapidxml::parse_error& e)
		{
			hstr desc = e.what() + hstr(" [") + e.where<char>() + "]";
			delete RAPIDXML_DOCUMENT;
			this->document = NULL;
			throw XMLException(hsprintf("An error occcured parsing XML file '%s': %s", this->realFilename.cStr(), desc.cStr()), NULL);
		}
	}
コード例 #5
0
static void update_target_profile(struct platform_info *pinfo)
{
	struct board_private *priv = pinfo->private_data;
	char *ptr = target_name;

	ptr += hsprintf(ptr, "%s", priv->board_name ? : "Armadillo-800 EVA");
	if (strlen(CONFIG_PROFILE_NAME))
		hsprintf(ptr, "/%s", CONFIG_PROFILE_NAME);
}
コード例 #6
0
		inline void __dumpContainerVariableStart(Variable* variable)
		{
			if (variable->type->value == Type::HARRAY || variable->type->value == Type::HMAP)
			{
				harray<hstr> types;
				foreach (Type*, it, variable->type->subTypes)
				{
					types += hsprintf("%02X", (*it)->value);
				}
				if (variable->containerSize > 0)
				{
					OPEN_NODE(hsprintf("Container sub_types=\"%s\"", types.joined(',').cStr()));
				}
				else
				{
					WRITE_NODE(hsprintf("Container sub_types=\"%s\"", types.joined(',').cStr()));
				}
			}
コード例 #7
0
ファイル: Viewport.cpp プロジェクト: boisei0/arcreator
	VALUE Viewport::rb_initialize(int argc, VALUE* argv, VALUE self)
	{
		if (argc != 1 && argc != 4)
		{
			rb_raise(rb_eArgError, hsprintf("Wrong number of arguments: %d for 1 or 4", argc).c_str());
		}
		RB_SELF2CPP(Viewport, viewport);
		viewport->initialize(argc, argv);
		return self;
	}
コード例 #8
0
ファイル: Utility.cpp プロジェクト: borisblizzard/liteser
	void _checkVersion(unsigned char major, unsigned char minor)
	{
		if (major != _LS_VERSION_MAJOR)
		{
			throw Exception(hsprintf("Liteser Read Error! Version mismatch: expected %d.%d, got %d.%d",
				_LS_VERSION_MAJOR, _LS_VERSION_MINOR, major, minor));
		}
		if (minor < _LS_VERSION_MINOR)
		{
			hlog::warnf(logTag, "Minor version mismatch while loading: expected %d.%d, got %d.%d",
				_LS_VERSION_MAJOR, _LS_VERSION_MINOR, major, minor);
		}
	}
コード例 #9
0
static void armadillo8x0_setup_console(struct platform_info *pinfo)
{
	char console[128];
	int ret;
	int autoboot = armadillo8x0_is_autoboot(pinfo);

#if defined(CONFIG_CMD_SETENV)
	ret = get_param_value("console", console, 128);
	if (ret == 0 && strcmp(console, "none") == 0)
		if (!autoboot)
			ret = 1;
	if (ret)
#endif
		hsprintf(console, "%s", CONFIG_DEFAULT_CONSOLE);

	/* we must set up to STANDARD_CONSOLE to match our hardware.
	   FIXME: this is redundant and just using a side effect of
	   the function to initialize it */
	change_console(CONFIG_STANDARD_CONSOLE);
	ret = change_console(console);
	if (ret && !autoboot)
		change_console(CONFIG_STANDARD_CONSOLE);
}
コード例 #10
0
ファイル: apriluiUtil.cpp プロジェクト: boisei0/arcreator
	hstr grect_to_hstr(grect rect)
	{
		return hsprintf("%f%c%f%c%f%c%f", rect.x, aprilui::SeparatorParameter, rect.y, aprilui::SeparatorParameter, rect.w, aprilui::SeparatorParameter, rect.h);
	}
コード例 #11
0
ファイル: apriluiUtil.cpp プロジェクト: boisei0/arcreator
	hstr gvec2_to_hstr(gvec2 vector)
	{
		return hsprintf("%f%c%f", vector.x, aprilui::SeparatorParameter, vector.y);
	}
コード例 #12
0
	hstr RenderSystem::DisplayMode::toString()
	{
		return hsprintf("%dx%d@%dHz", this->width, this->height, this->refreshRate);
	}
コード例 #13
0
ファイル: bbsedit.c プロジェクト: madoldman/inankai_bbs
int main()
{
        FILE *fp;
        int type=0, i, num, l;
        char userid[80], buf[512], path[512], file[512], board[512], title[80]="";
        //struct shortfile *brd;
        struct fileheader  *x;
        char c;//huangxu@060331
        init_all();
        modify_mode(u_info,EDIT+20000);	//bluetent
        if(!loginok)
                http_fatal("匆匆过客不能修改文章,请先登录");
        strsncpy(board, getparm("board"), 20);
        type=atoi(getparm("type"));
        brd=getbcache(board);
        if(brd==0)
                http_fatal("错误的讨论区!");
        strcpy(board, brd->filename);
        strsncpy(file, getparm("file"), 20);
        if(!has_post_perm(&currentuser, board))
                http_fatal("错误的讨论区或者您无权在此讨论区发表文章");
        x=get_file_ent(board, file);
        if(strstr(file, "..") || strstr(file, "/"))
                http_fatal("错误的参数");
        if(x==0)
                http_fatal("错误的参数");
        if(strcmp(x->owner, currentuser.userid))
                if(!has_BM_perm(&currentuser, board))
                        http_fatal("你无权修改此文章");

        printf("<center>%s -- 修改文章 [使用者: %s]<hr color=green>\n", BBSNAME, currentuser.userid);
        if(type!=0)
                return update_form(board, file);
        printf("<table border=1>\n");
        printf("<tr><td>");
        printf("<tr><td><form method=post action=bbsedit>\n");
        hsprintf(buf, "%s", x->title);
        printf("使用标题: %s 讨论区: %s<br>\n", buf, board);
        printf("本文作者:%s<br>\n", currentuser.userid);
        sprintf(path, "boards/%s/%s", board, file);
        fp=fopen(path, "r");
        if(fp==0)
                http_fatal("文件丢失");
        fseek(fp,0,2);
        l=ftell(fp);
        fseek(fp,0,0);
        for (i=4;l>0&&i>0;l--)//huangxu@060331
        {
        	c=fgetc(fp);
       		if (c==0x0a)
        		i--;
        }
        if (l<=0)  http_fatal("错误的文件");

        printf("<textarea name=text rows=20 cols=80 wrap=physicle>");
        while(1) {
                if(fgets(buf, 500, fp)==0)
                        break;
                        //为什么这些代码无法工作?
                /*for (;i>0;i--)
                {
                	printf("CHAR::%d::",*(buf+44));
                	pbuf++;
                	pbuf=strchr(pbuf,0x0a);
                	if (!pbuf) 
                	{
                		printf("NOTFOUND%d",i);
                		break;
                		}
                		printf("FOUND:%d,Length:%d,str=%s::",pbuf-buf,strlen(buf),buf);
                }*/
                if(!strcasestr(buf, "</textarea>"))
                        printf("%s", buf);
        }
        fclose(fp);
        printf("</textarea>\n");
        printf("<tr><td class=post align=center>\n");
        printf("<input type=hidden name=type value=1>\n");
        printf("<input type=hidden name=board value=%s>\n", board);
        printf("<input type=hidden name=file value=%s>\n", file);
        printf("<input type=submit value=存盘> \n");
        printf("<input type=button value=放弃编辑 onclick=javascript:history.go(-1)></form>\n");
        printf("</table>");
        http_quit();
}
コード例 #14
0
ファイル: Color.cpp プロジェクト: boisei0/arcreator
	VALUE Color::rb_inspect(VALUE self)
	{
		RB_SELF2CPP(Color, color);
		hstr result = hsprintf("(%.1f,%.1f,%.1f,%.1f)", color->red, color->green, color->blue, color->alpha);
		return rb_str_new2(result.c_str());
	}