本文整理汇总了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;
}
示例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);
}
}
示例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;
}
示例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);
}
示例5: FindName
CSrResourceFolder* CSrResourceHandler::GetScriptsFolder (void)
{
CSrResourceBase* pBasePath = FindName("scripts\\source\\");
if (pBasePath == NULL || !pBasePath->IsFolder()) return NULL;
return (CSrResourceFolder *) pBasePath;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}