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


C++ NameSpace类代码示例

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


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

示例1: ReturnStatus

ReturnStatus
FileMetaDAO::isdir(const std::string &path)
{
	Channel* pDataChannel = ChannelManager::getInstance()->Mapping(m_BucketId);
	NameSpace *DataNS = pDataChannel->m_DataNS;

	
    int rt = 0;

	FileAttr st;
    rt = DataNS->Stat(path.c_str(), &st);

    if (0 == rt) {
        if (MU_DIRECTORY == st.m_Type) {
            return ReturnStatus(MU_SUCCESS);

        } else {
            ERROR_LOG("path %s, not directory", path.c_str());
            return ReturnStatus(MU_FAILED, NOT_DIRECTORY);
        }
    }

    int error = errno;

    ERROR_LOG("path %s, stat() error, %s", path.c_str(), strerror(error));

    if (ENOENT == error || ENOTDIR == error) {
        return checkPrefix(path);

    } else {
        return ReturnStatus(MU_FAILED, MU_UNKNOWN_ERROR);
    }
}
开发者ID:Thirdhuku,项目名称:CloudStore,代码行数:33,代码来源:FileMetaDAO.cpp

示例2: HELPER

bool MultiNameSpace::writeToNameServer(PortWriter& cmd,
                                       PortReader& reply,
                                       const ContactStyle& style) {
    NameSpace *ns = HELPER(this).getOne();
    if (!ns) return false;
    return ns->writeToNameServer(cmd,reply,style);
}
开发者ID:JoErNanO,项目名称:yarp,代码行数:7,代码来源:MultiNameSpace.cpp

示例3: open

void
FileMetaDAO::addFileSizeToDelta(const std::string &path, uint64_t *pDelta)
{
	Channel* pDataChannel = ChannelManager::getInstance()->Mapping(m_BucketId);
	NameSpace *DataNS = pDataChannel->m_DataNS;
	
    int rt = 0;
    Args fd;

    // read file size
    
    fd = DataNS->Open(path.c_str(), O_RDONLY);

    if (false == fd.valid) {
        ERROR_LOG("path %s, open() error, %s", path.c_str(), strerror(errno));
        return ;
    }

    //int fd = rt;

    FileAttr attr;

    rt = DataNS->readn(&fd, &attr, sizeof(attr));
    DataNS->Close(&fd);

    if (sizeof(attr) != rt) {
        ERROR_LOG("path %s, readn() error", path.c_str());
        return ;
    }

    *pDelta += attr.m_Size;
}
开发者ID:Thirdhuku,项目名称:CloudStore,代码行数:32,代码来源:FileMetaDAO.cpp

示例4: scan

 void scan() {
     // reset flags
     _localOnly = true;
     _usesCentralServer = false;
     _serverAllocatesPortNumbers = true;
     // now scan each namespace
     for (int i=0; i<(int)spaces.size(); i++) {
         NameSpace *ns = spaces[i];
         if (!ns) continue;
         // if any namespace is nonlocal, combination is nonlocal
         if (!ns->localOnly()) _localOnly = false;
         // if any namespace uses a central server, combination also does
         if (ns->usesCentralServer()) _usesCentralServer = true;
         // if any namespace doesn't allocate port numbers, combination
         // cannot be relied on to do so either
         if (!ns->serverAllocatesPortNumbers()) {
             _serverAllocatesPortNumbers = false;
         }
         // if any namespace lacks informed connections, combination
         // cannot be relied on to be informed either
         if (!ns->connectionHasNameOfEndpoints()) {
             _connectionHasNameOfEndpoints = false;
         }
     }
 }
开发者ID:BRKMYR,项目名称:yarp,代码行数:25,代码来源:MultiNameSpace.cpp

示例5: assert

ReturnStatus
FileMetaDAO::getDir(const std::string &path, std::list<PDEntry> *pEntryList)
{
    assert(pEntryList);

    Channel* pDataChannel = ChannelManager::getInstance()->Mapping(m_BucketId);
	NameSpace *DataNS = pDataChannel->m_DataNS;

    int rt = 0;
    int error = 0;
    std::string entryName;
    Args st;

    rt = DataNS->OpenDir(path.c_str(), &st);

    if (false == st.valid) {
        error = errno;

        ERROR_LOG("path %s, opendir() error, %s.",
                  path.c_str(), strerror(errno));

        if (ENOTDIR == error) {
            return ReturnStatus(MU_FAILED, NOT_DIRECTORY);

        } else if (ENOENT == error) {
            return checkPrefix(path);
        }
    }

    Dirent dirent;

    while(DataNS->ReadDirNext(&st, &dirent)){
        entryName = dirent.filename;

        // omit "." and ".."
        // omit user info file in user root dir
        if (entryName == DENTRY_CURRENT_DIR
            || entryName == DENTRY_PARENT_DIR
            || entryName == USER_INFO_FILE_NAME) {
            continue;
        }

        PDEntry ent;
        ent.m_Name = entryName;

        if (MU_DIRECTORY == dirent.filetype) {
            ent.m_Type = MU_DIRECTORY;

        } else {
            ent.m_Type = MU_REGULAR_FILE;
        }

        pEntryList->push_back(ent);
    }


    return ReturnStatus(MU_SUCCESS);
}
开发者ID:Thirdhuku,项目名称:CloudStore,代码行数:58,代码来源:FileMetaDAO.cpp

示例6: SYNTAX_ERROR

/**
 * Parses the keyword "class" from the given token stack
 */
int CodeParser::parseKeyword_Class( Scope* scope, TokenStack* stack ) {
	Class* classdef;
	const char* name;
	Token* t;

	// validate incoming scope
	if( scope->getScopeType() != NAMESPACE_SCOPE ) {
		SYNTAX_ERROR( "Classes cannot be defined in this scope", stack->last() );
		return -1;
	}

	// the next token must be the identifier
	if( !( name = state->getIdentifierName( stack, "class" ) ) ) {
		return -2;
	}

	// get the name space
	NameSpace* ns = (NameSpace*)scope;
	printf( "class '%s' in namespace '%s' modifiers = %s\n", name, ns->getName(), toBinary( modifiers ) );

	// TODO check for inheritance! multiple inheritance?
	// - class MyChild extends MyParent { ... }
	// - class StrobeLamp extends Lamp, Strobe { ... }

	// create the class
	classdef = new Class( name, ns->getName(), ns, modifiers );
	this->modifiers = 0;

	// add the name space to the state
	if( !ns->addClass( classdef ) ) {
		char* error = new char[256];
		sprintf( error, "Class '%s' already exists in namespace '%s'\n", name, ns->getName() );
		SYNTAX_ERROR( error, stack->last() );
		delete error;
		return -4;
	}

	// the next element must be a code block
	if( !stack->hasNext() || !( t = stack->peek() ) || ( t->getType() != tok::CODE_BLOCK ) ) {
		SYNTAX_ERROR( "unexpected token", t );
		return -5;
	}

	// process the code block
	int errorCode = parse( classdef, ((ComplexToken*)t)->getChildren() );

	// register the class
	state->addClass( classdef );

	// reset the class-level counters
	state->resetCounters();
	return errorCode;
}
开发者ID:ldaniels528,项目名称:cortex,代码行数:56,代码来源:CodeParser.cpp

示例7: queryName

 Contact queryName(const ConstString& name) {
     activate();
     for (int i=0; i<(int)spaces.size(); i++) {
         NameSpace *ns = spaces[i];
         if (!ns) continue;
         if (ns->getNameServerName()==name) {
             return ns->getNameServerContact();
         }
         Contact result = ns->queryName(name);
         if (result.isValid()) return result;
     }
     return Contact();
 }
开发者ID:JoErNanO,项目名称:yarp,代码行数:13,代码来源:MultiNameSpace.cpp

示例8: getNSIndex

bool ApexResourceProvider::checkResource(ResID nameSpace, const char* name)
{
	/* Return true is named resource has known non-null pointer */
	uint32_t nsIndex = getNSIndex(nameSpace);
	if (nsIndex < mNameSpaces.size())
	{
		NameSpace* ns = mNameSpaces[nsIndex];
		ResID id = ns->getOrCreateID(name, mResources[ns->getID()].name);
		PX_ASSERT(id < mResources.size());
		return checkResource(id);
	}
	return false;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:13,代码来源:ApexResourceProvider.cpp

示例9: queryName

 Contact queryName(const char *name) {
     activate();
     for (int i=0; i<(int)spaces.size(); i++) {
         NameSpace *ns = spaces[i];
         if (!ns) continue;
         if (ns->getNameServerName()==name) {
             return ns->getNameServerContact();
         }
         //printf("Query from %s\n", spaces[i]->getNameServerName().c_str());
         Contact result = ns->queryName(name);
         //printf("Got %s\n", result.toString().c_str());
         if (result.isValid()) return result;
     }
     return Contact();
 }
开发者ID:paulfitz,项目名称:yarp,代码行数:15,代码来源:MultiNameSpace.cpp

示例10: getDelegate

bool SubscriberOnSql::welcome(const ConstString& port, int activity) {
    mutex.wait();

    NameSpace *ns = getDelegate();
    if (ns) {
        NestedContact nc(port);
        if (nc.getNestedName().size()>0) {
            NameStore *store = getStore();
            if (store!=NULL) {
                Contact node = store->query(nc.getNodeName());
                Contact me = store->query(port);
                if (node.isValid() && me.isValid()) {
                    if (activity>0) {
                        ns->registerAdvanced(me,store);
                    } else {
                        ns->unregisterAdvanced(port,store);
                    }
                }
            }
        }
    }

    char *msg = NULL;
    char *query;
    if (activity>0) {
        query = sqlite3_mprintf("INSERT OR IGNORE INTO live (name,stamp) VALUES(%Q,DATETIME('now'))", 
                                port.c_str());
    } else {
        // Port not responding.  Mark as non-live.
        if  (activity==0) {
            query = sqlite3_mprintf("DELETE FROM live WHERE name=%Q AND stamp < DATETIME('now','-30 seconds')", 
                                    port.c_str());
        } else {
            // activity = -1 -- definite dodo
            query = sqlite3_mprintf("DELETE FROM live WHERE name=%Q", 
                                    port.c_str());
        }
    }
    if (verbose) {
        printf("Query: %s\n", query);
    }
    bool ok = true;
    int result = sqlite3_exec(SQLDB(implementation), query, 
                              NULL, NULL, &msg);
    if (result!=SQLITE_OK) {
        ok = false;
        if (msg!=NULL) {
            fprintf(stderr,"Error: %s\n", msg);
            sqlite3_free(msg);
        }
    }
    sqlite3_free(query);
    mutex.post();

    if (activity>0) {
        hookup(port);
    } else if (activity<0) {
        breakdown(port);
    }
    return ok;
}
开发者ID:JoErNanO,项目名称:yarp,代码行数:61,代码来源:SubscriberOnSql.cpp

示例11: whereDelegate

 Contact whereDelegate()
 {
     if (!space) {
         return Contact();
     }
     return space->getNameServerContact();
 }
开发者ID:jgvictores,项目名称:yarp,代码行数:7,代码来源:yarpserver.cpp


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