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


C++ XMLTag::name方法代码示例

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


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

示例1: handleToken

// Return true if the content was handled or is to be ignored.
//      false if the what has been seen is to be accumulated and considered later.
bool handleToken(std::string & text, XMLTag & token) {
        // The start token for the current entry;
    static XMLTag startTag;

        // Flags to indicate whether we are in a entry, entryFree or superentry
        static bool inEntry      = false;
        static bool inEntryFree  = false;
        static bool inSuperEntry = false;

        std::string const &  tokenName = token.name();

        static char const * splitPtr;
        static char const * splitPtr2 = nullptr;
        static std::array<char, 4096> splitBuffer;
    static SWKey tmpKey;
//-- START TAG -------------------------------------------------------------------------
    if (!token.isEndTag()) {

        // If we are not in an "entry" and we see one, then enter it.
        if (!inEntry && !inEntryFree && !inSuperEntry) {
            inEntry      = (tokenName == "entry");
            inEntryFree  = (tokenName == "entryFree");
            inSuperEntry = (tokenName == "superentry");
                        if (inEntry || inEntryFree || inSuperEntry) {
#ifdef DEBUG
                cout << "Entering " << tokenName << endl;
#endif
                startTag    = token;
                text        = "";

                                keyStr = token.attribute("n"); // P5 with linking and/or non-URI chars
                                if (keyStr.empty()) {
                                    keyStr = token.attribute("sortKey"); // P5 otherwise
                                    if (keyStr.empty()) {
                            keyStr = token.attribute("key"); // P4
                                        }
                                }

                return false; // make tag be part of the output
            }
        }
    }

//-- EMPTY and END TAG ---------------------------------------------------------------------------------------------
    else {

        // ENTRY end
        // If we see the end of an entry that we are in, then leave it
        if ((inEntry      && (tokenName == "entry"     )) ||
            (inEntryFree  && (tokenName == "entryFree" )) ||
            (inSuperEntry && (tokenName == "superentry"))) {
#ifdef DEBUG
            cout << "Leaving " << tokenName << endl;
#endif
            // Only one is false coming into here,
            // but all must be on leaving.
            inEntry       = false;
            inEntryFree   = false;
            inSuperEntry  = false;
            text         += token.toString();

                        entryCount++;
#ifdef DEBUG
            cout << "keyStr: " << keyStr << endl;
#endif
                        splitPtr = std::strchr(keyStr.c_str(), '|');
                        if (splitPtr) {
                                std::strncpy (splitBuffer.data(), keyStr.c_str(), splitPtr - keyStr.c_str());
                                splitBuffer[splitPtr - keyStr.c_str()] = 0;
                currentKey->setText(splitBuffer.data());
#ifdef DEBUG
                cout << "splitBuffer: " << splitBuffer.data() << endl;
                cout << "currentKey: " << currentKey->getText() << endl;
#endif
                writeEntry(*currentKey, text);
#if 1
                                while (splitPtr) {
                                    splitPtr += 1;
                                    splitPtr2 = std::strstr(splitPtr, "|");
                                        entryCount++;
                                        if (splitPtr2) {
                        std::strncpy (splitBuffer.data(), splitPtr, splitPtr2 - splitPtr);
                                                splitBuffer[splitPtr2 - splitPtr] = 0;
#ifdef DEBUG
                        cout << "splitBuffer: " << splitBuffer.data() << endl;
                        cout << "currentKey: " << currentKey->getText() << endl;
#endif
                        linkToEntry(currentKey->getText(), splitBuffer.data());
                                            splitPtr = splitPtr2;
                                        }
                                        else {
                        std::strcpy(splitBuffer.data(), splitPtr);
#ifdef DEBUG
                                      cout << "splitBuffer: " << splitBuffer.data() << endl;
                        cout << "currentKey: " << currentKey->getText() << endl;
#endif
                        linkToEntry(currentKey->getText(), splitBuffer.data());
                                                splitPtr = nullptr;
//.........这里部分代码省略.........
开发者ID:swordxx,项目名称:swordxx,代码行数:101,代码来源:tei2mod.cpp


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