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


C++ Directory::addChild方法代码示例

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


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

示例1: copyFileInDirectory

void CommandPrompt::copyFileInDirectory(string parameters){
	/*
	* Разделя параметрите.
	*/
	queue<string> filePaths = this->getPaths(parameters);

	/*
	* Намира файловете по адрес и ги записва в опашка.
	* Последният адрес е на destination directory.
	*/
	queue<TextFile*> files;
	TextFile* tempFile;
	while (filePaths.size() > 1) {
		tempFile = determinePathAndGetFile(filePaths.front());
		if (tempFile != NULL)
			files.push(tempFile);
		else
			cerr << "File not found!" << endl;
		filePaths.pop();
	}

	/*
	* Намираме адреса на директорията. Ако е NULL връщаме, ако не създаваме копия.
	*/
	Directory* destinationDir = this->determinePathAndGetDir(filePaths.front());
	filePaths.pop();
	if (destinationDir == NULL)
		cerr << "Destination directory not found!" << endl;
	else {
		while (!files.empty()){
			destinationDir->addChild(new TextFile(*files.front()));
			files.pop();
		}
	}
}
开发者ID:mnitchev,项目名称:File-System,代码行数:35,代码来源:CommandPrompt.cpp

示例2: parseOrder

    // オプションノードから割付方法を取得する
enum Common::tagAssignmentOrder Common::parseOrder(OptionParameter::OptionItem item)
{
    Directory node;
    unsigned int i;

    for(i=0;i<item.countParameter();++i)
        node.addChild(item[i]);

    return parseOrder(&node);
}
开发者ID:koban,项目名称:Uzume-Aqua548,代码行数:11,代码来源:parser.cpp

示例3: saveConcatenatedFile

/*
* Помощтна функция, за запазване/въвеждане на файлове.
*/
void CommandPrompt::saveConcatenatedFile(string path, string data){
	/*
	* Ако няма данни и няма подаден адрес за запис връща.
	*/
	if (path.empty() && data.empty())
		return;

	/*
	* Ако няма данни се въвеждат.
	*/
	if (data.empty()) {
		char line[1000];
		string sline;
		while (sline != string(".")) {
			cin.getline(line, 1000);
			sline = line;
			if(sline != ".")
				data += sline;
		}
	}

	/*
	* Ако няма outputFile се извеждат данните, ако има
	* се намира/създава директория и се създава вайл в нея.
	* Наследява промените по големината на директориите.
	*/
	if (path.empty())
		cout << data << endl;
	else {
		string fileName = path;
		Directory* dir = fs.getRoot();
		int pos = path.rfind('/') + 1;
		if (pos - 1 != string::npos) {
			fileName = "";
			while (pos < path.size())
				fileName += path[pos++];
			pos = path.rfind('/');
			path = path.erase(pos, path.size());
			dir = this->createNestedDirectories(path);
		}
		else
			dir = currentDir;
		if (dir->nameAvailable(fileName)) {
			dir->addChild(new TextFile(dir->getFSysPath(),
				fs.getNextNumber(),
				data,
				fileName));
			dir->inheritSize(data.size());
		}
		else {
			dir->findFileByName(fileName)->concatData(data);
			dir->inheritSize(data.size());
		}
	}
}
开发者ID:mnitchev,项目名称:File-System,代码行数:58,代码来源:CommandPrompt.cpp

示例4: ExceptionMessage

Directory * StaticAPI::allocate(Directory & container, const Token & token, const char * id, bool regist)
{
    static unsigned int assignment_count = 0;
    Directory * node;

    if(!(token == Token::IDENTIFIER || token == Token::INTEGER))
        ExceptionMessage("Given token(%) is not suitable for an object identifier.","オブジェクトの識別名として利用できない字句(%)が指定されました") << token << throwException;

    if(regist && (token == Token::INTEGER && token.value <= 0))
        ExceptionMessage("Cannot assign an ID number less or equal to 0.","0以下のID番号を設定することはできません").throwException();


    node = container.findChild(id);
    if(node != 0)
    {
        Directory::iterator scope;

        scope = node->begin();
        while(scope != node->end())
        {
            if((*scope).first.compare(token) == 0)
                ExceptionMessage("Identifier % is already used.","識別名%はすでに利用されています") << token << throwException;
            ++ scope;
        }
    }else
        node = container.addChild(id);

    node = node->addChild(token);
    (*node)["#order"] = assignment_count++;

    if(token == Token::IDENTIFIER)
    {
        if(regist)
        {
            Directory * scope = container.openChild("/","identifier",token.c_str(),NULL);
            if(*scope == Directory::INTEGER)
                *node = scope->toInteger();
        }
    }else
        *node = token.value;

    last = node;
    return node;
}
开发者ID:koban,项目名称:Uzume-Aqua548,代码行数:44,代码来源:parser.cpp

示例5: createLinksInDirectory

/*
* Създава линкове на файловете в подадена директория.
*/
void CommandPrompt::createLinksInDirectory(string parameters){
	stack<string> filePaths;
	string tempPath;
	/*
	* Извлича адресите в стек (защото последния адрес е директория).
	*/
	for (int i = 0; i <= parameters.size(); i++) {
		if (parameters[i] == ' ' || i == parameters.size()) {
			filePaths.push(tempPath);
			tempPath = "";
		}
		else {
			tempPath += parameters[i];
		}
	}

	/*
	* Намира директорията. Ако не я намери извежда грешка и връща.
	*/
	Directory* destinationDir = this->determinePathAndGetDir(filePaths.top());
	filePaths.pop();
	if (destinationDir == NULL) {
		cerr << "Destination directory not found!" << endl;
		return;
	}

	/*
	* Намира файловете по адрес и създава линкове към тях в директорията.
	*/
	TextFile* tempFile;
	while (!filePaths.empty()) {
		tempFile = this->determinePathAndGetFile(filePaths.top());
		if (tempFile == NULL) {
			cerr << "File not found!" << endl;
		}
		else {
			destinationDir->addChild(new SymLink(tempFile, fs.getNextNumber(), destinationDir->getFSysPath()));
		}
		filePaths.pop();
	}
}
开发者ID:mnitchev,项目名称:File-System,代码行数:44,代码来源:CommandPrompt.cpp

示例6: createNestedDirectories

/*
* Определя какъв е адреса и го обхожда име по име.
* Ако намери директория която не съществува я създава.
* @return - търсената директория, ако поради някакви причини не се е създала връща root.
*/
Directory* CommandPrompt::createNestedDirectories(string path) {
	string currentName;
	Directory* result = NULL;
	Directory* tempDir = fs.getRoot();
	if (path.find('/') == string::npos) {
		if ((tempDir = tempDir->findDirByName(path)) == NULL) {
			result = new Directory(currentDir->getFSysPath(),
				fs.getNextNumber(),
				path,
				currentDir);
			currentDir->addChild(result);
			return result;
		}
			return tempDir;
	}
	else {
		for (int i = 0; i <= path.size(); i++) {
			if ((path[i] == '/' || i == path.size()) && !currentName.empty()) {	
				if (tempDir->findDirByName(currentName) == NULL) {
					result = new Directory(tempDir->getFSysPath(),
						fs.getNextNumber(),
						currentName,
						tempDir);
					tempDir->addChild(result);
				}
				tempDir = tempDir->findDirByName(currentName);
				currentName = "";
			}
			else if(path[i] != '/') {
				currentName += path[i];
			}
		}
	}
	if (result == NULL)
		return tempDir;
	return result;
}
开发者ID:mnitchev,项目名称:File-System,代码行数:42,代码来源:CommandPrompt.cpp

示例7: parseStaticAPI

bool ParserComponent::parseStaticAPI(Parser & p, Directory & container, Token token, const string domain)
{
    bool isParseErrorOccured = false;
    map<string, ParseUnit *>::iterator api;
    Directory * node = NULL;

    if(token.type != Token::IDENTIFIER)
        return false;

    StaticAPI::clearLastObject();
    node = container[PARSERESULT].addChild();

    try {
        node->addChild("api",new Directory(token));
        node->addChild("begin",new Directory((long)p.getLogBufferPos(-(int)token.size()-1)));
        if(!domain.empty())
            node->addChild("domain", new Directory(domain));

        api = StaticAPI::container().find(token);
        if(api == StaticAPI::container().end())
        {
            if(ignoreUnknownAPI)
            {
                cerr << Message("%: Unknown static api % was ignored. (skipped)\n","%: 非登録のAPI % は無視されます\n") << p.getStreamLocation() << token;
                do {
                    p.getToken(token);
                }while(token.compare(";") != 0);
                node->addChild("end",new Directory((long)p.getLogBufferPos()));
                (*node) = (long)0;
                return true;
            }
            ExceptionMessage("Static API [%] is not registered in the configurator", "静的API[%]は未登録です") << token << throwException;
        }

        DebugMessage("  StaticAPI [%]\n") << (*api).first;

        p.getToken("(");

        (*api).second->body(token, container, p, domain);

        p.getToken(")");
        p.getToken(";");

        node->addChild("end",new Directory((long)p.getLogBufferPos()));
        (*node) = (long)1;
    }
    catch(Exception & e)
    {
        int offset;
        string work;
        work = p.getStreamLocation() + Message(":[Error] ",":[エラー] ").str() + e.getDetails();
        isParseErrorOccured = true;

        StaticAPI::dropLastObject();
        failCount ++;

        offset = 0;
        token = p.getLastErrorToken();
        while (token != Token::ERROR && token != Token::EOS)
        {
            if( token == ";" )
                break;

                //読み出したトークンが静的APIと同じ名前なら きっとセミコロン忘れ
            api = StaticAPI::container().find(token);
            if(api != StaticAPI::container().end())
            {
                cerr << Message("<The following error must be occured by lack of ';' at the end of previous line>\n","<次のエラーは直前行の';'忘れによる可能性が高いです>\n");
                offset = -(int)token.size();
                p.putBack(token);
                break;
            }

            p.getToken(token);
        }

        node->addChild("end",new Directory((long)p.getLogBufferPos(offset)));
        (*node) = (long)0;

        cerr << work << '\n';

        ExceptionMessage("Fatal error on Static API parsing","静的APIの構文解析に失敗しました").throwException();
    }

    return true;
}
开发者ID:koban,项目名称:Uzume-Aqua548,代码行数:86,代码来源:parser.cpp


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