⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 directorymap.cpp

📁 嵌入式系统开发 TOPPERS and JSP Kernel Release 1.3 TOPPERS = Toyohashi Open Platform for Embedded Real-Tim
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* *  TOPPERS/JSP Kernel *      Toyohashi Open Platform for Embedded Real-Time Systems/ *      Just Standard Profile Kernel *  *  Copyright (C) 2000-2002 by Embedded and Real-Time Systems Laboratory *                              Toyohashi Univ. of Technology, JAPAN *  *  惧淡螟侯涪荚は·Free Software Foundation によって给山されている  *  GNU General Public License の Version 2 に淡揭されている掘凤か·笆 *  布の(1)×(4)の掘凤を塔たす眷圭に嘎り·塑ソフトウェア∈塑ソフトウェ *  アを猖恃したものを崔むˉ笆布票じ∷を蝗脱ˇ剩澜ˇ猖恃ˇ浩芹邵∈笆布· *  网脱と钙ぶ∷することを痰浸で钓满するˉ *  (1) 塑ソフトウェアをソ〖スコ〖ドの妨で网脱する眷圭には·惧淡の螟侯 *      涪山绩·この网脱掘凤および布淡の痰瘦沮惮年が·そのままの妨でソ〖 *      スコ〖ド面に崔まれていることˉ *  (2) 塑ソフトウェアを浩网脱材墙なバイナリコ〖ド∈リロケ〖タブルオブ *      ジェクトファイルやライブラリなど∷の妨で网脱する眷圭には·网脱 *      に燃うドキュメント∈网脱荚マニュアルなど∷に·惧淡の螟侯涪山绩· *      この网脱掘凤および布淡の痰瘦沮惮年を非很することˉ *  (3) 塑ソフトウェアを浩网脱稍材墙なバイナリコ〖ドの妨または怠达に寥 *      み哈んだ妨で网脱する眷圭には·肌のいずれかの掘凤を塔たすことˉ *    (a) 网脱に燃うドキュメント∈网脱荚マニュアルなど∷に·惧淡の螟侯 *        涪山绩·この网脱掘凤および布淡の痰瘦沮惮年を非很することˉ *    (b) 网脱の妨轮を·侍に年める数恕によって·惧淡螟侯涪荚に鼠桂する *        ことˉ *  (4) 塑ソフトウェアの网脱により木儡弄または粗儡弄に栏じるいかなる禄 *      巢からも·惧淡螟侯涪荚を倘勒することˉ *  *  塑ソフトウェアは·痰瘦沮で捏丁されているものであるˉ惧淡螟侯涪荚は· *  塑ソフトウェアに簇して·その努脱材墙拉も崔めて·いかなる瘦沮も乖わ *  ないˉまた·塑ソフトウェアの网脱により木儡弄または粗儡弄に栏じたい *  かなる禄巢に簇しても·その勒扦を砷わないˉ *  *  @(#) $Id: directorymap.cpp,v 1.3 2002/04/05 08:48:31 takayuki Exp $ */// $Header: /home/CVS/configurator/directorymap.cpp,v 1.3 2002/04/05 08:48:31 takayuki Exp $#include "directorymap.h"#include "except.h"#include <stdarg.h>#include <typeinfo>#ifdef _MSC_VER  #pragma warning(disable:4786)#endifusing namespace std;int Directory::defaultflag = Directory::NOTHING;Directory::Directory(const Directory & src){    parent = 0;    flag = defaultflag;    defaultflag &= ~DESTRUCT;    type = src.type;    switch(type)    {    case LITERAL:        content.literal = new string(*src.content.literal);        break;    default:        content = src.content;        break;    }}Directory::~Directory(void){	if(parent != 0)	{		parent->erase(myself);		parent = 0;	}}void Directory::_clear(void){	switch(this->getType())	{	case LITERAL:		delete content.literal;		break;	case OBJECT:		delete content.instance;		break;	default:		break;	}	type = UNKNOWN;	content.pointer = 0;}Directory * Directory::_find(bool automatic_creation, const string & path){    string::size_type top, tail, length;    string work;    Directory::iterator scope;    Directory * node = this;    length = path.length();    top = 0;    if(path[0] == '/')    {        while(node->getParent() != 0)            node = node->getParent();        top = 1;    }    do {        tail = path.find_first_of('/', top);        if(tail == string::npos)            work = path.substr(top);        else            work = path.substr(top, tail-top);		if(work.compare(".") == 0 || work.compare("..") == 0)		{			if(work.size() > 1 && node->getParent() != 0)				node = node->getParent();		}else		{			scope = node->begin();			while(scope != node->end())			{				if(work.compare((*scope).first) == 0)					break;				scope ++;			}			if(scope == node->end())			{				if(!automatic_creation)					return 0;				node = node->addChild(work, new Directory);			}else				node = (*scope).second;		}        top = tail + 1;    } while( tail != string::npos && top < length );    return node;}Directory * Directory::_find(bool automatic_creation, const char * key, va_list vl){    Directory::iterator scope;    Directory * node = this;    if(*key == '/' && *(key+1) == '\x0')    {        while(node->getParent() != 0)            node = node->getParent();		if(vl == 0)			return node;        key = va_arg(vl, const char *);    }    do {        scope = node->begin();        while(scope != node->end())        {            if((*scope).first.compare(key) == 0)                break;            scope ++;        }        if(scope == node->end())        {            if(!automatic_creation)                return 0;            node = node->addChild(key, new Directory);        }else            node = (*scope).second;		if(vl != 0)	        key = va_arg(vl, const char *);		else			break;    } while( key != 0 );    return node;}Directory & Directory::operator =(void * _pointer){	if(this->getType() != UNKNOWN && this->getType() != POINTER)		_clear();	type = POINTER;	content.pointer = _pointer;	return *this;}Directory & Directory::operator =(long _value){	if(this->getType() != UNKNOWN && this->getType() != INTEGER)		_clear();	type = INTEGER;	content.value = _value;	return *this;}Directory & Directory::operator =(const string & _literal){	if(this->getType() != UNKNOWN && this->getType() != LITERAL)		_clear();	type = LITERAL;	content.literal = new string(_literal);	return *this;}Directory & Directory::operator =(const char * _constliteral){	if(this->getType() != UNKNOWN && this->getType() != CONSTLITERAL)		_clear();	type = CONSTLITERAL;	content.const_literal = _constliteral;	return *this;}Directory & Directory::operator =(Garbage * _instance){	if(this->getType() != UNKNOWN)		_clear();	type = OBJECT;	content.instance = _instance;	return *this;}void * Directory::operator new(size_t sz){	defaultflag |= DESTRUCT;	return malloc(sz);	}Directory::operator const long(void) const{	if( type == UNKNOWN )		Exception("Bad cast exception","稍赖キャスト毋嘲");	return content.value;}void * Directory::operator * (void) const{	if( type == UNKNOWN )		Exception("Bad cast exception","稍赖キャスト毋嘲");	return content.pointer;}void Directory::_erase(void){	iterator scope;	_clear();	parent = 0;	scope = begin();	while(scope != end())	{		(*scope).second->_erase();		scope ++;	}	map<string,Directory*>::clear();	if((flag & DESTRUCT) != 0)		delete this;}Directory::iterator Directory::erase(iterator it){    iterator result;	Directory * scope = (*it).second;	scope->_erase();    if((result = it) == begin())      result ++;    else      result --;    map<string, Directory*>::erase(it);	return result;}void Directory::disconnect(void){	if(parent != 0)	{		parent->map<string,Directory*>::erase(myself);		parent = 0;	}}Directory * Directory::getNext(void) const{	if(parent == 0)		return 0;	iterator scope;	scope = myself;	scope ++;	if(scope == parent->end())		return 0;	return (*scope).second;}Directory * Directory::getPrev(void) const{	if(parent == 0 && myself == parent->begin())		return 0;	reverse_iterator scope;		scope = parent->rbegin();	while(scope != parent->rend() && (*scope).second != (*myself).second)		scope ++;	scope ++;	return scope != parent->rend() ? (*scope).second : 0;}bool Directory::changeKey(const string & _key){	Directory * _parent;	if( _key.size() == 0)		return false;	_parent = parent;	disconnect();	_parent->addChild(_key, this);	return true;}void Directory::drawTree(ostream * out, int level, string * link){	iterator scope;	iterator scope2;	if(level == 0)		link = new string;	else		*out << (*link).substr(0, (level-1)*3) << " +-";	*out << '[' << getKey() << ']';    switch(type)    {    case POINTER:        out->setf(ios::hex);        *out << " : PTR [" << content.pointer << "]";        break;    case INTEGER:        out->setf(ios::dec);        *out << " : INT [" << content.value << "]";        break;    case LITERAL:        *out << " : STR [" << *content.literal << "]";        break;    case CONSTLITERAL:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -