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


C++ FindName函数代码示例

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


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

示例1: doRval

struct ExprRes *  doRval(char * name)  { 
   struct ExprRes *res;
   struct SymEntry * e;
   if( global ){
       e = FindName(locTable, name);
       if( !e) {
           e = FindName(table, name);
       }
   }
   else {
       e = FindName(table, name);
               }
   if (!e) {
		WriteIndicator(GetCurrentColumn());
		WriteMessage("Undeclared variable");
        exit(1); //doing something stupid like "print ln;" will cause me to segfault if we don't quit
   }
  struct Vtype * vtype = ((struct Vtype *)e->Attributes);



  res = (struct ExprRes *) malloc(sizeof(struct ExprRes));
  res->Reg = AvailTmpReg();
  
  if ( vtype->Local == 0 ){
         res->Instrs = GenInstr(NULL,"lw",TmpRegName(res->Reg),name,NULL); 
  }
  else {
      res->Instrs = GenInstr(NULL, "lw", TmpRegName(res->Reg), RegOff(vtype->StackIndex, "$sp"), NULL);
  }
  
  res->Type = vtype->Type;
  return res;
}
开发者ID:tyman7,项目名称:compiler,代码行数:34,代码来源:Semantics.c

示例2: memset

void FName::NameManager::InitBuckets ()
{
	Inited = true;
	memset (Buckets, -1, sizeof(Buckets));

	// Register built-in names. 'None' must be name 0.
	for (size_t i = 0; i < countof(PredefinedNames); ++i)
	{
		assert((0 == FindName(PredefinedNames[i], true)) && "Predefined name already inserted");
		FindName (PredefinedNames[i], false);
	}
}
开发者ID:Edward850,项目名称:zdoom,代码行数:12,代码来源:name.cpp

示例3: doArrayAssign

struct InstrSeq * doArrayAssign( char * name, struct ExprRes * index, struct ExprRes * val){
    struct SymEntry *e;
    if( global ){
        e = FindName(locTable, name);
        if( !e){
            e = FindName(table, name);
        }
    }
    else{
        e = FindName(table, name);
    }
    struct Vtype * vtype = ((struct Vtype *)e->Attributes);
    struct InstrSeq * code;
    int reg = AvailTmpReg();
    char * buffer;
    if (!e){
        WriteIndicator(GetCurrentColumn());
        WriteMessage("Undeclared variable");
    }
    if(index->Type != TYPE_INT){
        TypeError();
    }
    else if( val->Type != -1 && ((vtype->Type ==  TYPE_BOOLARR &&  val->Type != TYPE_BOOL) || (vtype->Type == TYPE_INTARR && val->Type != TYPE_INT ))){
        TypeError();
    }
    buffer = RegOff(0, TmpRegName(reg));
    code = val->Instrs;
    AppendSeq(code, index->Instrs);
    // change for locality later
    if (! vtype->Local){
        AppendSeq( code, GenInstr( NULL, "la", TmpRegName(reg), name, NULL));
         
    }
    else {
        AppendSeq(code, GenInstr(NULL, "addi", TmpRegName(reg), "$sp", Imm(vtype->StackIndex)));
    }
    
    
    
    AppendSeq( code, GenInstr( NULL, "mul", TmpRegName(index->Reg), TmpRegName(index->Reg), "4"));
    AppendSeq( code, GenInstr(NULL, "add", TmpRegName(reg), TmpRegName(reg), TmpRegName(index->Reg)));
    AppendSeq( code, GenInstr(NULL, "sw", TmpRegName(val->Reg), buffer, NULL));
    ReleaseTmpReg(val->Reg);
    ReleaseTmpReg(index->Reg);
    ReleaseTmpReg(reg);
    free(val);
    free(index);

    return code;
    
}
开发者ID:tyman7,项目名称:compiler,代码行数:51,代码来源:Semantics.c

示例4: DbgLogMediaTypeInfo

void DbgLogMediaTypeInfo(DWORD type, DWORD level, const CMediaType* pmt)
{
	DbgLogInfo(type, level,
		TEXT(" MediaType Info : %s %s %s %s SampleSize=%ld"),
			FindName(g_MediaTypes, &pmt->majortype),
			FindName(g_MediaSubTypes, &pmt->subtype),
			(pmt->bFixedSizeSamples 
				? TEXT("FixedSamples")
				: TEXT("NotFixedSamples")),
			(pmt->bTemporalCompression
				? TEXT("TemporalCompression")
				: TEXT("NotTemporalCompression")),
			pmt->lSampleSize);
}
开发者ID:Harurow,项目名称:DSFilters,代码行数:14,代码来源:Utils.cpp

示例5: FindName

CSrResourceFolder* CSrResourceHandler::GetScriptsFolder (void)
{
	CSrResourceBase* pBasePath = FindName("scripts\\source\\");
	if (pBasePath == NULL || !pBasePath->IsFolder()) return NULL;

	return (CSrResourceFolder *) pBasePath;
}
开发者ID:Purr4me,项目名称:TES5Edit-GoogleCode,代码行数:7,代码来源:srresourcehandler.cpp

示例6: GetName

HRESULT GetName(const NamedGuid* pTable, LPTSTR pszString, int cchBuf,
				const GUID *pGuid)
{
	ASSERT(pTable);
	ASSERT(pszString);
	ASSERT(pGuid);

	if (cchBuf < 1) {
		return E_INVALIDARG;
	}

	HRESULT hr = E_FAIL;

	pszString[0] = TEXT('\0');

	const LPCTSTR pName = FindName(pTable, pGuid);
	if (pName) 	{
		if (_tcscpy_s(pszString, cchBuf, pName) == 0) {
			return S_OK;
		}
	}

	if (FAILED(hr)) {
		hr = StringFromGUID2(*pGuid, pszString, cchBuf);
	}

	return hr;
}
开发者ID:Harurow,项目名称:DSFilters,代码行数:28,代码来源:Utils.cpp

示例7:

static struct NamedObj *searchns(pUtility UtilBase, struct NamedObj *object, struct NameSpace *ns, STRPTR search)
{
	struct NamedObj *ret;
	if (!search)
	{
		if (object->no_Non.non_Node.ln_Succ) return object;
		return NULL;
	}

	if ((ns->ns_Flags & NSB_CASE) != 0)
	{
		 ret = (struct NamedObj *)FindName((struct List *)object->no_Non.non_Node.ln_Pred, search);
		 return ret;
	}
	
	ForeachNode(object, ret)
	{
		if (Stricmp((const char*)search, (const char*)ret->no_Non.non_Node.ln_Name) == 0)
		{
			if (ret->no_Non.non_Node.ln_Succ) return ret;
			return NULL;
		}
	}
	return NULL;
}
开发者ID:cycl0ne,项目名称:poweros_x86,代码行数:25,代码来源:name.c

示例8: time_of_find_name

double time_of_find_name(char *Last)
{
	struct timespec t_start, t_end;
        uint64_t nsec1 = 0;
        uint64_t nsec2 = 0;
        uint64_t elapsed_nsec = 0;

        PhoneBook *pb_found;

        clock_gettime(CLOCK_MONOTONIC, &t_start);
        nsec1 = ((uint64_t)(t_start.tv_sec) * 1000000000LL + t_start.tv_nsec);

        pb_found = FindName(Last, pb);

        clock_gettime(CLOCK_MONOTONIC, &t_end);
        nsec2 = (uint64_t)(t_end.tv_sec) * 1000000000LL + t_end.tv_nsec;
        elapsed_nsec = nsec2 - nsec1;

        if(pb_found != NULL)
        {
                printf("%s found ",Last);
        }
        else
                printf("%s not found\n",Last);

        //printf("used time :%.3f sec\n",(double)elapsed_nsec/1000000000.0);

        return (double)elapsed_nsec/1000000000.0;
}
开发者ID:musicguitar,项目名称:phonebook_opt,代码行数:29,代码来源:pb_opt2.c

示例9: main

int main(void)
{
	PhoneBook *pb[DATA];
    int i = 0;

    clock_t start_time, end_time;

	pb[i] = (PhoneBook*) malloc(sizeof(PhoneBook));
	strncpy(pb[i]->LastName, "aaa", sizeof("aaa"));
	// strncpy(pb[i]->LastName, "pjay", sizeof("pjay"));
    while (i++ < DATA) {
    	pb[i] = (PhoneBook*) malloc(sizeof(PhoneBook));
    	strncpy(pb[i]->LastName, "aaa", sizeof("aaa"));
    	pb[i-1]->pNext = pb[i];
    } 
    strncpy(pb[DATA - 1]->LastName, "pjay", sizeof("pjay"));
    
    printf("%ld Byte * %d = %ld KByte\n", sizeof(PhoneBook), DATA, (sizeof(PhoneBook) * DATA)/1024);

    start_time = clock();
    PhoneBook *getPb = FindName("pjay", pb[0]);
    end_time = clock();

    printf("%f microsec\n", (float)(end_time - start_time));

    if (getPb != NULL) {
    	printf("%s\n", getPb->LastName);
    }

    return 0;
}
开发者ID:PJayChen,项目名称:Optimizing-Program-Example,代码行数:31,代码来源:main.c

示例10: L_WB_PutDiskObject

// Patched PutDiskObject()
BOOL __asm __saveds L_WB_PutDiskObject(
	register __a0 char *name,
	register __a1 struct DiskObject *diskobj)
{
	struct LibData *data;
	struct MyLibrary *libbase;
	BOOL result,magic=0;

	// Get library
	if (!(libbase=(struct MyLibrary *)FindName(&((struct ExecBase *)*((ULONG *)4))->LibList,"dopus5.library")))
		return 0;

	// Get data pointer
	data=(struct LibData *)libbase->ml_UserData;

	// See if icon type is set to inverse magic
	if (diskobj->do_Magic==(USHORT)~WB_DISKMAGIC)
	{
		// Fix it
		diskobj->do_Magic=WB_DISKMAGIC;

		// Set magic flag, which will stop us sending notification
		magic=1;
	}

	// Write icon
	result=L_WriteIcon(name,diskobj,libbase);

	// Succeeded?
	if (result && !magic) icon_notify(data,name,0,0);

	return result;
}
开发者ID:MrZammler,项目名称:opus_magellan,代码行数:34,代码来源:icons.c

示例11: L_WB_DeleteDiskObject

// Patched DeleteDiskObject()
BOOL __asm __saveds L_WB_DeleteDiskObject(register __a0 char *name)
{
	struct LibData *data;
	struct MyLibrary *libbase;
	BOOL result;
	char *full_name;

	// Get library
	if (!(libbase=(struct MyLibrary *)FindName(&((struct ExecBase *)*((ULONG *)4))->LibList,"dopus5.library")))
		return 0;

	// Get data pointer
	data=(struct LibData *)libbase->ml_UserData;

	// Get full name
	full_name=icon_fullname(data,name);

	// Write icon
	result=L_DeleteIcon(name,libbase);

#define DOSBase (data->dos_base)

	// Succeeded?
	if ((result || IoErr()==ERROR_OBJECT_NOT_FOUND) && full_name)
		icon_notify(data,full_name,INF_FULLNAME,1);

#undef DOSBase

	// Free full name buffer
	FreeVec(full_name);
	return result;
}
开发者ID:MrZammler,项目名称:opus_magellan,代码行数:33,代码来源:icons.c

示例12: column

/** @param type :: Data type of the column.
    @param name :: Column name.
    @return A shared pointer to the created column (will be null on failure).
*/
API::Column_sptr TableWorkspace::addColumn(const std::string &type,
                                           const std::string &name) {
  API::Column_sptr c;
  if (type.empty()) {
    g_log.error("Empty string passed as type argument of createColumn.");
    return c;
  }
  if (name.empty()) {
    g_log.error("Empty string passed as name argument of createColumn.");
    return c;
  }
  // Check that there is no column with the same name.
  auto ci = std::find_if(m_columns.begin(), m_columns.end(), FindName(name));
  if (ci != m_columns.end()) {
    g_log.error() << "Column with name " << name << " already exists.\n";
    return c;
  }
  try {
    c = API::ColumnFactory::Instance().create(type);
    m_columns.push_back(c);
    c->setName(name);
    resizeColumn(c.get(), rowCount());
  } catch (Kernel::Exception::NotFoundError &e) {
    g_log.error() << "Column of type " << type << " and name " << name
                  << " has not been created.\n";
    g_log.error() << e.what() << '\n';
    return c;
  }
  return c;
}
开发者ID:Mantid-Test-Account,项目名称:mantid,代码行数:34,代码来源:TableWorkspace.cpp

示例13: main

int main()
{
	int n;
	int index;
	int edges;
	int first, second;
	int counter;
	char tmp[MAX_LENGTH];
	double tr;

	counter = 0;
	do
	{
		counter++;
		scanf("%d", &n);
		if(!n)
			break;

		for(index=1; index<=n; index++)
			scanf("%s", names[index]);

		scanf("%d",&index);
		for(edges=0; edges<index; edges++)
		{
			scanf("%s", tmp);
			eArr[edges].x = FindName(tmp, n);
			scanf("%lf", &eArr[edges].rate);
			scanf("%s", tmp);
			eArr[edges].y = FindName(tmp, n); 
		}

#if DEBUG
		ShowEdges(edges);
#endif 

		printf("Case %d: ", counter);
		if(Bellman_Ford(edges) < 0)
			printf("Yes\n");
		else
			printf("No\n");

	}while(1);

	return 0;
}
开发者ID:UsuallyGO,项目名称:POJ,代码行数:45,代码来源:2240.c

示例14: FindName

/// Gets the shared pointer to a column.
API::Column_sptr TableWorkspace::getColumn(const std::string &name) {
  auto ci = std::find_if(m_columns.begin(), m_columns.end(), FindName(name));
  if (ci == m_columns.end()) {
    std::string str = "Column " + name + " does not exist.\n";
    g_log.error(str);
    throw std::runtime_error(str);
  }
  return *ci;
}
开发者ID:Mantid-Test-Account,项目名称:mantid,代码行数:10,代码来源:TableWorkspace.cpp

示例15: D

sem_t *sem_open(const char *name, int oflag, mode_t mode, unsigned int value)
{
    sem_t *sem;

    D(bug("%s(%s, %d, %u, %u)\n", __FUNCTION__, name, oflag, mode, value));

    pthread_once(&once_control, _Init_Semaphore);

    if (name == NULL)
    {
        errno = EINVAL;
        return SEM_FAILED;
    }

    ObtainSemaphore(&sema_sem);
    sem = (sem_t *)FindName(&semaphores, (STRPTR)name);
    if (sem != NULL)
    {
        if ((oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
        {
            ReleaseSemaphore(&sema_sem);
            errno = EEXIST;
            return SEM_FAILED;
        }
    }
    else
    {
        if (!(oflag & O_CREAT))
        {
            ReleaseSemaphore(&sema_sem);
            errno = ENOENT;
            return SEM_FAILED;
        }
        
        sem = malloc(sizeof(sem_t));
        if (sem == NULL)
        {
            ReleaseSemaphore(&sema_sem);
            errno = ENOMEM;
            return SEM_FAILED;
        }

        if (sem_init(sem, 0, value))
        {
            free(sem);
            ReleaseSemaphore(&sema_sem);
            return SEM_FAILED;
        }
        // TODO: this string should be duplicated
        sem->node.ln_Name = (char *)name;
        AddTail(&semaphores, (struct Node *)sem);
    }
    ReleaseSemaphore(&sema_sem);

    return sem;
}
开发者ID:michalsc,项目名称:AROS,代码行数:56,代码来源:semaphore.c


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