コード例 #1
0
ファイル: parser.cpp プロジェクト: fishman/virtualdub
void TreeParser::ParseFile(const char *fname) {
	int c;

	PushFile(fname);

	while((c = Next()) != EOF) {
		if (c == '<') {
			TreeNode *p = ParseTag();
			if (p && !p->mbIsText) {
				if (!mpDocument->mpRoot)
					mpDocument->mpRoot = p;
				else
					error("multiple high-level tags detected (first is <%s>, second is <%s>)", mpDocument->mpRoot->mName.c_str(), p->mName.c_str());
			}
		}
	}
}
コード例 #2
0
ファイル: Utility.c プロジェクト: sharelatex/chktex
int PushFileName(const char *Name, struct Stack *stack)
{
    FILE *fh = NULL;
    static char NameBuf[BUFSIZ];

    if (Name && stack)
    {
        if (LocateFile(Name, NameBuf, ".tex", &TeXInputs))
        {
            if ((fh = fopen(NameBuf, "r")))
            {
                return (PushFile(NameBuf, fh, stack));
            }
        }
        PrintPrgErr(pmNoTeXOpen, Name);
    }
    return (FALSE);
}
コード例 #3
0
ファイル: imagewidget.cpp プロジェクト: JustFFunny/WorkSpace
ImageWidget::ImageWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ImageWidget)
{
    ui->setupUi(this);
    QSettings settings;
    ip = settings.value("wlanIP").toString();
    port = settings.value("sPort").toInt();

    playlist = ui->tableWidget;
    //设置只能选择单行
    playlist->setSelectionMode(QAbstractItemView::SingleSelection);
    playlist->setSelectionBehavior(QAbstractItemView::SelectRows);
    //设置不显示网格
    playlist->setShowGrid(false);
    //禁止修改内容
    playlist->setEditTriggers(QAbstractItemView::NoEditTriggers);

    connect(ui->pushButton_in, SIGNAL(clicked()), this, SLOT(PushFile()));
    connect(ui->pushButton_out, SIGNAL(clicked()), this, SLOT(PullFile()));

    android = new AndroidAPK();

    imageLabel  = ui->label;
    imageLabel->setAlignment(Qt::AlignCenter);
    image = new QImage();

    socket = new QTcpSocket();

    loadSize = 10*1024;

    currentNum = -1;
    imageCount = 0;
    imageCount = getImagetCount();
    if(imageCount > 0)
    {
        ui->msg_label->setText(tr("All: %1").arg(QString::number(imageCount)));
        currentNum = 0;
        ui->progressBar->setMaximum(imageCount-1);
        ui->progressBar->setValue(currentNum);
        GetImageInfo(currentNum);
    }
}
コード例 #4
0
ファイル: parser.cpp プロジェクト: fishman/virtualdub
// parse_tag
//
// Assumes that starting < has already been parsed.
TreeNode *TreeParser::ParseTag() {
	TreeNode& tag = *AllocNode();
	bool closed = false;
	int c;

	tag.mbIsControl = false;
	tag.mbIsText = false;

	c = NextRequired();
	if (isspace(c))
		do {
			c = NextRequired();
		} while(isspace(c));

	if (c=='?' || c=='!') {
		tag.mbIsText = true;
		tag.mbIsControl = true;
		tag.mName = "<";
		tag.mName += c;

		int bracket_count = 1;
		do {
			c = NextRequired();
			tag.mName += c;

			if (c == '<')
				++bracket_count;
			else if (c == '>')
				--bracket_count;
		} while(bracket_count);
		return &tag;
	} else if (c == '/') {
		tag.mName += c;
		c = NextRequired();
	}

	do {
		tag.mName += tolower(c);
		c = NextRequired();
	} while(istagchar(c));

	if (tag.mName[0] == '/')
		closed = true;

	// backwards compatibility
	std::string::size_type pos = 0;
	if (closed)
		pos = 1;

	if (!tag.mName.compare(pos, 2, "w:"))
		tag.mName.replace(pos, 2, "lina:");

	while(c != '>') {
		if (c == '/' || c=='?') {
			closed = true;
			c = NextRequired();
		} else if (istagchar(c)) {
			tag.mAttribs.push_back(TreeAttribute());
			TreeAttribute& att = tag.mAttribs.back();

			do {
				att.mName += tolower(c);
				c = NextRequired();
			} while(istagchar(c));

			while(isspace(c))
				c = NextRequired();

			att.mbNoValue = true;

			if (c == '=') {
				att.mbNoValue = false;
				do {
					c = NextRequired();
				} while(isspace(c));

				if (c == '"') {
					c = NextRequired();
					while(c != '"') {
						att.mValue += c;
						c = NextRequired();
					}
					c = NextRequired();
				} else {
					do {
						att.mValue += c;
						c = NextRequired();
					} while(istagchar(c));
				}
			}

		} else if (isspace(c)) {
			c = NextRequired();
		} else
			unexpected(c);
	}

	if (!closed) {
		c = NextRequired();
		for(;;) {
			TreeNode *p;
			if (c == '<') {
				p = ParseTag();

				if (p && !p->mName.empty() && p->mName[0] == '/') {
					if ((std::string("/") + tag.mName) != p->mName)
						error("closing tag <%s> doesn't match opening tag <%s> on line %d", p->mName.c_str(), tag.mName.c_str(), tag.mLineno);
					break;
				}
				c = NextRequired();
			} else {
				p = ParseInline(c);
			}

			if (p)
				tag.mChildren.push_back(p);
		}
	}

	// Check for a macro or include and whisk it away if so.

	if (tag.mName == "lina:macro") {
		const TreeAttribute *a = tag.Attrib("name");

		if (!a)
			error("macro definition must have NAME attribute");

		mpDocument->mMacros[a->mValue] = &tag;

		return NULL;
	} else if (tag.mName == "lina:include") {
		const TreeAttribute *a = tag.Attrib("file");

		if (!a)
			error("<lina:include> must specify FILE");

		PushFile(a->mValue.c_str());

		return NULL;
	}

	return &tag;
}