当前位置: 首页>>代码示例>>C++>>正文


C++ TextInput::readSymbol方法代码示例

本文整理汇总了C++中TextInput::readSymbol方法的典型用法代码示例。如果您正苦于以下问题:C++ TextInput::readSymbol方法的具体用法?C++ TextInput::readSymbol怎么用?C++ TextInput::readSymbol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextInput的用法示例。


在下文中一共展示了TextInput::readSymbol方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

void Vector2::deserialize(TextInput& t) {
    t.readSymbol("(");
    x = (float)t.readNumber();
    t.readSymbol(",");
    y = (float)t.readNumber();
    t.readSymbol(")");
}
开发者ID:Akenyshka,项目名称:MythCore,代码行数:7,代码来源:Vector2.cpp

示例2:

bool GPUProgram::BindingTable::consumeSymbol(TextInput& ti, const std::string& s) {
    Token t = ti.peek();
    if (symbolMatch(t, s)) {
        ti.readSymbol(s);
        return true;
    } else {
        return false;
    }
}
开发者ID:luaman,项目名称:g3d-cpp,代码行数:9,代码来源:GPUProgram.cpp

示例3: toGLType

GLenum Shader::ShaderProgram::getDeclarationType(TextInput& ti, bool& uniform) {
    uniform = false;
    if (ti.peek().type() == Token::SYMBOL) {
        bool readyForType = false;
        String s = ti.peek().string();
        //Parse all qualifiers before the type: 
        while (! readyForType) {
            if (isQualifier(s)) {
                uniform = (uniform || (s == "uniform"));
                ti.readSymbol(s);
                s = ti.peek().string();
            } else if (s == "layout") {
                //This should properly parse through all possible layout inputs
                //http://www.opengl.org/registry/doc/GLSLangSpec.4.30.6.pdf (pg52)
                ti.readSymbol(s);
                ti.readSymbol("(");
                Token t = ti.read();
                while ((t.type() != Token::SYMBOL) || (t.string() != ")")) {
                    t = ti.read();  
                }
                s = ti.peek().string();
            } else {
                // The next token is not a qualifier of any sort, so it is probably the type, if this is a declaration
                readyForType = true;
            }
        }

        // Read the type
        String variableSymbol = ti.readSymbol();

        // check for unsigned int, short, long long, etc
        if (variableSymbol == "unsigned") {
            while (toGLType(variableSymbol + " " + ti.peek().string()) != GL_NONE) {
                variableSymbol += " " + ti.readSymbol();
            }
        }
        // If the variableSymbol is not a valid type, then this is not a variable declaration, and GL_NONE will be returned
        // Checking for not being a declaration cannot be done earlier, as a declaration could have no qualifiers
        return toGLType(variableSymbol);
    } else {
        return GL_NONE;
    }
}
开发者ID:elfprince13,项目名称:G3D10,代码行数:43,代码来源:Shader_ShaderProgram.cpp

示例4: deserialize

void XML::deserialize(TextInput& t) {
 begin:
    Token n = t.read();
    m_attribute.clear();
    m_child.clear();
    m_name = "";
    m_value = "";

    if ((n.type() == Token::SYMBOL) && (n.string() == "<")) {
        // Beginning a tag
        
        // Read name
        n = t.read();
        debugAssert(n.type() == Token::SYMBOL);
        bool isComment = 
            (n.string() == "!") && 
            (t.peek().type() == Token::SYMBOL) &&
            (t.peek().string() == "--");

        // ignored tag:        <?xml> or <!xml>
        // comment tag:        <!--   ... -->

        if ((n.string() == "?") || ((n.string() == "!") && ! isComment)) {
            // Ignore this tag
            while (t.hasMore() && ! ((n.type() == Token::SYMBOL) && (n.string() == ">"))) {
                n = t.read();
            }
            goto begin;
        } else if (isComment) {
            // Ignore until "-->"
            bool prevWasDash = false;
            while (t.hasMore() && ! ((n.type() == Token::SYMBOL) && (n.string() == ">") && prevWasDash)) {
                prevWasDash = (n.type() == Token::SYMBOL) && (n.string() == "--");
                n = t.read();
            }
            goto begin;
        }

        // Keep reading until no colon
        m_name += n.string();
        n = t.read();
        while ((n.type() == Token::SYMBOL) && (n.string() == ":")) {
            //  tag with namespace: <x:y>
            m_name += ":" + t.readSymbol();
            n = t.read();
        }
        
        // Read end of tag/close
        bool done = false;
        while (! done) {
            debugAssert(n.type() == Token::SYMBOL);
            if (n.string() == "/") {
                // empty-element tag:  <foo/>
                // Consume the close tag
                t.readSymbol(">");
                done = true;

            } else if (n.string() == ">") {
                // End of open tag: read children until close tag
                while (! atClose(t, m_name)) {
                    m_child.next().deserialize(t);
                }

                // Read close tag (we wouldn't be here unless it parses correctly)
                while (t.hasMore() && ! (t.readSymbol() == ">")) {}
                
                done = true;
            } else {
                // Attribute pair
                std::string k = n.string();
                t.readSymbol("=");
                std::string v = t.read().string();
                m_attribute.set(k, v);

                // Advance to next
                n = t.read();
            }
        }
    } else {
        // Beginning embedded content.  Read until the end of file or the next tag.
        m_type = VALUE;
        m_value += n.string();

        n = t.peek();
        while (t.hasMore() && ! ((n.type() == Token::SYMBOL) && (n.string() == "<"))) {
            m_value += " " + t.read().string();
            n = t.peek();
        }
    }
}
开发者ID:Blumfield,项目名称:TBCPvP,代码行数:90,代码来源:XML.cpp

示例5: alwaysAssertM

void GPUProgram::BindingTable::parseVariable(TextInput& ti) {
	std::string name;


    // #var float4 osLight :  : c[4] : 1 : 1
    // #var float3 vin.v0 : $vin.POSITION : ATTR0 : 2 : 1

    Token t = ti.peek();
    if (t.type() != Token::SYMBOL) {
		goto abort;
	}
    // get the binding's type
    ti.readSymbol();
    Type type;


    if (! CgType(t.string(), type)) {
        alwaysAssertM(false, std::string("Unsupported type: \"") + t.string() + "\"");
    }
    
    t = ti.peek();
    if (t.type() != Token::SYMBOL) {
		goto abort;
	}
    // read the binding name
    name = ti.readSymbol();

    if (! consumeSymbol(ti, ":")) {
		goto abort;
	}

    // see if it is the vertex or a constant register
    t = ti.peek();

    if (t.type() != Token::SYMBOL) {
		goto abort;
	}

	// Sometimes there is an extra token between the colons
	if (t.string() != ":") {
		ti.readSymbol();
		t = ti.peek();
	}

    if (! consumeSymbol(ti, ":")) {
		goto abort;
	}

    // read the register number
	t = ti.peek();

	if (t.type() != Token::SYMBOL) {
		goto abort;
	}

    // Consume the symbol we just peeked
	ti.readSymbol();

	if (t.string() == "texunit") {
		// We're reading a texture unit

	} else if (t.string() == "c") {
		// We're reading a regular variable; parse the open bracket

		if (! consumeSymbol(ti, "[")) {
			goto abort;
		}

    } else if ((t.type() == Token::SYMBOL) && (t.string() == ":")) {        
        // Unused variable; must be present but is not bound

        Binding binding;
        binding.source = VARIABLE;
        binding.type = type;
        binding.name = name;
        binding.slot = Binding::UNASSIGNED;
        bindingArray.append(binding);
        return;

    } else {

		// Something unexpected happened.
		goto abort;

	}

    t = ti.peek();

    if (t.type() == Token::NUMBER) {
        int slot = iRound(ti.readNumber());
        Binding binding;
        binding.source = VARIABLE;
        binding.type = type;
        binding.name = name;
        binding.slot = slot;
        bindingArray.append(binding);
    }

abort:
	;// Jump here if anything unexpected is encountered during parsing
//.........这里部分代码省略.........
开发者ID:luaman,项目名称:g3d-cpp,代码行数:101,代码来源:GPUProgram.cpp


注:本文中的TextInput::readSymbol方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。