示例#1
0
/* static */
QIcon UIIconPool::iconSet(const QString &strNormal,
                          const QString &strDisabled /* = QString() */,
                          const QString &strActive /* = QString() */)
{
    /* Prepare fallback icon: */
    static QIcon nullIcon;

    /* Prepare icon: */
    QIcon icon;

    /* Add 'normal' pixmap: */
    AssertReturn(!strNormal.isEmpty(), nullIcon);
    addName(icon, strNormal, QIcon::Normal);

    /* Add 'disabled' pixmap (if any): */
    if (!strDisabled.isEmpty())
        addName(icon, strDisabled, QIcon::Disabled);

    /* Add 'active' pixmap (if any): */
    if (!strActive.isEmpty())
        addName(icon, strActive, QIcon::Active);

    /* Return icon: */
    return icon;
}
示例#2
0
void Monster::you(MsgType type, const string& param) const {
  string msg, msgNoSee;
  switch (type) {
    case MsgType::ARE: msg = creature->getTheName() + " is " + param; break;
    case MsgType::YOUR: msg = creature->getTheName() + "'s " + param; break;
    case MsgType::FEEL: msg = creature->getTheName() + " looks " + param; break;
    case MsgType::FALL_ASLEEP: msg = (creature->getTheName() + " falls asleep") + (param.size() > 0 ? " on the " + param : ".");
                               msgNoSee = "You hear snoring."; break;
    case MsgType::WAKE_UP: msg = creature->getTheName() + " wakes up."; break;
    case MsgType::DIE: msg = creature->getTheName() + " is killed!"; break;
    case MsgType::TELE_APPEAR: msg = creature->getTheName() + " appears out of nowhere!"; break;
    case MsgType::TELE_DISAPPEAR: msg = creature->getTheName() + " suddenly disappears!"; break;
    case MsgType::BLEEDING_STOPS: msg = creature->getTheName() + "'s bleeding stops."; break;
    case MsgType::DIE_OF: msg = creature->getTheName() +
                          " dies" + (param.empty() ? string(".") : " of " + param); break;
    case MsgType::FALL_APART: msg = creature->getTheName() + " falls apart."; break;
    case MsgType::MISS_ATTACK: msg = creature->getTheName() + addName(" misses", param); break;
    case MsgType::MISS_THROWN_ITEM: msg = param + " misses " + creature->getTheName(); break;
    case MsgType::MISS_THROWN_ITEM_PLURAL: msg = param + " miss " + creature->getTheName(); break;
    case MsgType::HIT_THROWN_ITEM: msg = param + " hits " + creature->getTheName(); break;
    case MsgType::HIT_THROWN_ITEM_PLURAL: msg = param + " hit " + creature->getTheName(); break;
    case MsgType::ITEM_CRASHES: msg = param + " crashes on " + creature->getTheName(); break;
    case MsgType::ITEM_CRASHES_PLURAL: msg = param + " crash on " + creature->getTheName(); break;
    case MsgType::GET_HIT_NODAMAGE: msg = "The " + param + " is harmless."; break;
    case MsgType::COLLAPSE: msg = creature->getTheName() + " collapses."; break;
    case MsgType::FALL: msg = creature->getTheName() + " falls on the " + param; break;
    case MsgType::TRIGGER_TRAP: msg = creature->getTheName() + " triggers something."; break;
    case MsgType::PANIC: msg = creature->getTheName() + " panics."; break;
    case MsgType::RAGE: msg = creature->getTheName() + " is enraged."; break;
    case MsgType::SWING_WEAPON: msg = creature->getTheName() + " swings " + creature->getGender().his() + " " +
                                    param; break;
    case MsgType::THRUST_WEAPON: msg = creature->getTheName() + " thrusts " + creature->getGender().his() + " " +
                                 param; break;
    case MsgType::KICK: msg = creature->getTheName() + addName(" kicks", param); break;
    case MsgType::BITE: msg = creature->getTheName() + addName(" bites", param); break;
    case MsgType::PUNCH: msg = creature->getTheName() + addName(" punches", param); break;
    case MsgType::CRAWL: msg = creature->getTheName() + " is crawling"; break;
    case MsgType::STAND_UP: msg = creature->getTheName() + " is back on " + creature->getGender().his() + " feet ";
                            break;
    case MsgType::TURN_INVISIBLE: msg = creature->getTheName() + " disappears!"; break;
    case MsgType::TURN_VISIBLE: msg = creature->getTheName() + " appears out of nowhere!"; break;
    case MsgType::DROP_WEAPON: msg = creature->getTheName() + " drops " + creature->getGender().his() + " " + param;
                               break;
    case MsgType::ENTER_PORTAL: msg = creature->getTheName() + " disappears in the portal."; break;
    case MsgType::HAPPENS_TO: msg = param + " " + creature->getTheName(); break;
    case MsgType::BURN: msg = creature->getTheName() + " burns in the " + param; msgNoSee = "You hear a horrible shriek"; break;
    case MsgType::DROWN: msg = creature->getTheName() + " drowns in the " + param; msgNoSee = "You hear a loud splash" ;break;
    case MsgType::SET_UP_TRAP: msg = creature->getTheName() + " sets up the trap"; break;
    case MsgType::KILLED_BY: msg = creature->getTheName() + " is killed by " + param; break;
    case MsgType::TURN: msg = creature->getTheName() + " turns into " + param; break;
    case MsgType::BREAK_FREE: msg = creature->getTheName() + " breaks free from " + param; break;
    case MsgType::PRAY: msg = creature->getTheName() + " prays to " + param; break;
    case MsgType::SACRIFICE: msg = creature->getTheName() + " makes a sacrifice to " + param; break;
    case MsgType::HIT: msg = creature->getTheName() + addName(" hits", param); break;
    default: break;
  }
  if (!msg.empty())
    creature->monsterMessage(msg, msgNoSee);
}
示例#3
0
Take::Take(Console *console)
  : NonActiveCommand(console)
{
  addName("podnies");
  addName("podnieś");
  addName("wez");
  addName("weź");
  addName("zabierz");
}
示例#4
0
    // Return true if the line is successfully processed without errors
    // If cont is true, then groupName must be set to the continuation group name
    bool AclReader::processGroupLine(tokList& toks, const bool cont) {
        const unsigned toksSize = toks.size();

        if (contFlag) {
            gmCitr citr = groups.find(groupName);
            for (unsigned i = 0; i < toksSize; i++) {
                if (isValidGroupName(toks[i])) {
                    if (toks[i] == groupName) {
                        QPID_LOG(debug, "ACL: Line: " << lineNumber
                            << ", Ignoring recursive sub-group \"" << toks[i] << "\".");
                        continue;
                    } else if (groups.find(toks[i]) == groups.end()) {
                        errorStream << ACL_FORMAT_ERR_LOG_PREFIX << "Line : " << lineNumber
                            << ", Sub-group \"" << toks[i] << "\" not defined yet.";
                        return false;
                    }
                } else if (!isValidUserName(toks[i])) return false;
                addName(toks[i], citr->second);
            }
        } else {
            const unsigned minimumSize = (cont ? 2 : 3);
            if (toksSize < minimumSize) {
                errorStream << ACL_FORMAT_ERR_LOG_PREFIX << "Line : " << lineNumber
                    << ", Insufficient tokens for group definition.";
                return false;
            }
            if (!isValidGroupName(toks[1])) {
                errorStream << ACL_FORMAT_ERR_LOG_PREFIX << "Line : " << lineNumber
                    << ", Group name \"" << toks[1] << "\" contains illegal characters.";
                return false;
            }
            gmCitr citr = addGroup(toks[1]);
            if (citr == groups.end()) return false;
            for (unsigned i = 2; i < toksSize; i++) {
                if (isValidGroupName(toks[i])) {
                    if (toks[i] == groupName) {
                        QPID_LOG(debug, "ACL: Line: " << lineNumber
                            << ", Ignoring recursive sub-group \"" << toks[i] << "\".");
                        continue;
                    } else if (groups.find(toks[i]) == groups.end()) {
                        errorStream << ACL_FORMAT_ERR_LOG_PREFIX << "Line : " << lineNumber
                            << ", Sub-group \"" << toks[i] << "\" not defined yet.";
                        return false;
                    }
                } else if (!isValidUserName(toks[i])) return false;
                addName(toks[i], citr->second);
            }
        }
        return true;
    }
示例#5
0
void Monster::you(MsgType type, const vector<string>& param) {
  string msg;
  switch (type) {
    case MsgType::SWING_WEAPON:
      msg = getCreature()->getName().the() + " swings " + getCreature()->getAttributes().getGender().his() + " " + param.at(0); break;
    case MsgType::THRUST_WEAPON:
      msg = getCreature()->getName().the() + " thrusts " + getCreature()->getAttributes().getGender().his() + " " + param.at(0); break;
    case MsgType::KICK: msg = getCreature()->getName().the() + addName(" kicks", param.at(0)); break;
    case MsgType::PUNCH: msg = getCreature()->getName().the() + addName(" punches", param.at(0)); break;
    default: you(type, param.at(0)); return;
  }
  if (param.size() > 1)
    msg += " " + param[1];
  if (!msg.empty())
    getCreature()->monsterMessage(msg);
}
示例#6
0
static void processIC_H( char *fname )
{
    char *p;
    char *ok;
    char *ic_start;
    unsigned ic_idx;

    file = fname;
    line = 0;
    ic_idx = NO_IDX;
    for(;;) {
        ok = fgets( buff, sizeof(buff), ic_h );
        if( ok == NULL ) break;
        ++line;
        p = skipSpace( buff );
        if( memcmp( p, "//", 2 ) == 0 ) {
            continue;
        }
        ic_start = strstr( p, "IC(" );
        if( ic_start != NULL ) {
            p = skipNonSpace( ic_start );
            p = skipSpace( p );
            ic_idx = whatICAmI( p );
            continue;
        }
        if( ic_idx != NO_IDX ) {
            if( buff[0] == '#' ) {
                addName( icPreProcTable, ic_idx, buff );
            }
        }
    }
}
示例#7
0
// for configuring object with save data
void Item::deserialize(std::istream &in)
{
    std::string input;          // input buffer
    
    // get names
    std::getline(in, input);    // heading
    std::getline(in, input);    // realName
    while (input != "##ENDITEMNAMES##")
    {
        addName(input);
        std::getline(in, input);
    }
    
    // get description
    std::getline(in, input);
    desc = input;
    
    // get size
    std::getline(in, input);
    size = std::atoi(input.c_str());
    
    // get weight
    std::getline(in, input);
    weight = std::atoi(input.c_str());
}
示例#8
0
bool  parserCls::factor(void)
{ EtokenType lTt1 = getTokenType();bool bb1 = true ;
  tokenContainCls lTc1 =getCurToken() ,lTc2;bool seeUnary= false;


  if( (lTt1 == Plus) || (lTt1==Minus) || (lTt1 == Not) )
  { if(lTt1== Plus)	 lTc1.type = UnaryPlus;
	 else if(lTt1== Minus) lTc1 . type = UnaryMinus;
	 lTc2=lTc1;getToken();lTt1=getTokenType();
	 lTc1=getCurToken();seeUnary=true;
  }
  switch(lTt1){
	 case OrdNumber:case SciNumber:case Array :
	addOperand() ;exprFound = true ;needOperand = false ;getToken();
	 break ;
	 case String :
		 if(seeUnary)
	 {errorUnary(lTc2 ,1);bb1 = false;break ;}
		 addOperand();exprFound=true;needOperand=false ;getToken();
	 break ;
	 case Name : exprFound = true ;needOperand=false;getToken();
	if(getTokenType() == Lparen ) bb1=addFunction(lTc1);
	else   addName(lTc1) ;
	 break ;
	 case Lparen :recursiveLparen() ;break ;
	 case Rparen :if(seeUnary)
		 {errorUnary(lTc2 , 2);bb1 = false ;break ;}
	 break ;
	 default :if(needOperand)	 errorFactor();
	  bb1 = false ;
	 break ;
  }
  if(seeUnary && bb1)	addOperator(lTc2);
  return bb1 ;
}
示例#9
0
void GFolderSerializer::startFile(const char* szFilename)
{
	// File indicator
	*m_pPos = 'f';
	m_pPos++;
	m_size--;
	addName(szFilename);

	// The file size
	m_pInStream = new std::ifstream();
	unsigned long long size = 0;
	try
	{
		m_pInStream->exceptions(std::ios::badbit | std::ios::failbit);
		m_pInStream->open(szFilename, std::ios::binary);
		m_pInStream->seekg(0, std::ios::end);
		size = m_pInStream->tellg();
		m_pInStream->seekg(0, std::ios::beg);
	}
	catch(const std::exception e)
	{
		throw Ex("Error opening file: ", szFilename);
	}
	memcpy(m_pPos, &size, sizeof(unsigned long long));
	m_pPos += sizeof(unsigned long long);
	m_size -= sizeof(unsigned long long);
	m_remaining = (size_t)size;

	// The file
	continueFile();
}
示例#10
0
int fbtBuildInfo::getLengths(fbtBuildStructs& struct_builders)
{


	makeBuiltinTypes();

	fbtBuildStructs::Iterator bit = struct_builders.iterator();
	while (bit.hasMoreElements())
	{
		fbtBuildStruct& bs = bit.getNext();
		bs.m_structId = addType(bs.m_name, 0);

		m_strc.push_back(bs.m_structId);
		m_strc.push_back((FBTint16)bs.m_data.size());

		m_alloc.m_strc += (sizeof(FBTtype) * 2);


		fbtVariables::Iterator it = bs.m_data.iterator();
		while (it.hasMoreElements())
		{
			fbtVariable& cvar = it.getNext();

			cvar.m_typeId = addType(cvar.m_type, 0);
			cvar.m_nameId = addName(cvar.m_name);

			m_strc.push_back(cvar.m_typeId);
			m_strc.push_back(cvar.m_nameId);

			m_alloc.m_strc += (sizeof(FBTtype) * 2);
		}
	}

	return getTLengths(struct_builders);
}
/*------------------------------------------------------------------------------------
---------------------------------addName2---------------------------------------------
------------------------------------------------------------------------------------*/
void  NameSearchable::addName(int fintname, int findex, int fend)		//adds an int 'name', a desired index, and a vector index
{
	std::string tmpString = "Unnamed" + intToString(fintname) + ".";	//make a name out of the int (23 -> "Unnamed23.") the '.' is to prevent multiple copies 
																		//from having confusing names (e.g. add 2 then 2 again, you get "Unnamed2." and "Unnamed2.2"
																		//rather than "Unnamed2" and "Unnamed22"

	addName(tmpString, findex, fend);									//then add the name using the string-ified int
}
示例#12
0
static void scanSource( char *fname )
{
    char *mask_id;
    char *ok;
    char *t;
    char *p;
    char *s;
    char c;
    int begin_found;
    unsigned ic_idx;

    file = fname;
    line = 0;
    begin_found = 0;
    mask_id = NULL;
    for(;;) {
        ok = fgets( buff, sizeof(buff), src_c );
        if( ok == NULL ) break;
        ++line;
        if( begin_found ) {
            t = strstr( buff, "// ICMASK END" );
            if( t != NULL ) {
                begin_found = 0;
                continue;
            }
            p = skipSpace( buff );
            if( memcmp( p, "case", 4 ) == 0 ) {
                p = skipNonSpace( p );
                p = skipSpace( p );
                if( memcmp( p, "IC_", 3 ) == 0 ) {
                    ic_idx = whatICAmI( p );
                    addName( icMaskTable, ic_idx, mask_id );
                }
            }
        } else {
            t = strstr( buff, "// ICMASK BEGIN" );
            if( t != NULL ) {
                p = skipNonSpace( t );
                p = skipSpace( p );
                p = skipNonSpace( p );
                p = skipSpace( p );
                p = skipNonSpace( p );
                p = skipSpace( p );
                s = p;
                p = skipMacroName( p );
                c = *p;
                *p = '\0';
                mask_id = strdup( s );
                *p = c;
                begin_found = 1;
            }
        }
    }
    if( begin_found ) {
        fail( "// ICMASK BEGIN found without matching // ICMASK END\n" );
    }
}
示例#13
0
文件: layout.cpp 项目: jonco3/dynamic
Layout* Layout::maybeAddName(Name name, bool& existing)
{
    if (hasName(name)) {
        existing = true;
        return this;
    }

    existing = false;
    return addName(name);
}
BeddingTypeLegendItem::BeddingTypeLegendItem(QGraphicsItem* p, BeddingType* t, int w, int h)
: PatternLegendItem(p, w, h),
_beddingType(t) {
    ProfileLogger* app = (static_cast<ProfileLogger*> (QApplication::instance()));
    QBrush b = app->getBrushFromFileName(app->getSettings()->getLithologiesPatternPath(), t->getFileName());

    addPattern(b);
    addId(t->getId());
    addName(t->getName());
}
示例#15
0
 void AclReader::addName(const std::string& name, nameSetPtr groupNameSet) {
     gmCitr citr = groups.find(name);
     if (citr != groups.end()) {
         // This is a previously defined group: add all the names in that group to this group
         groupNameSet->insert(citr->second->begin(), citr->second->end());
     } else {
         // Not a known group name
         groupNameSet->insert(name);
         addName(name);
     }
 }
LithologyLegendItem::LithologyLegendItem(QGraphicsItem* parent, Lithology* l, int width, int height)
: PatternLegendItem(parent, width, height),
_lithology(l) {

    ProfileLogger* app = (static_cast<ProfileLogger*> (QApplication::instance()));
    QBrush b = app->getBrushFromFileName(app->getSettings()->getLithologiesPatternPath(), l->getFileName());

    addPattern(b);
    addId(l->getId());
    addName(l->getName());
}
示例#17
0
int main (void) {
  /* program to coordinate the menu options and calls the requested function */

  struct node * first = NULL;   /* pointer to the first list item */
  char option[strMax];          /* user response to menu selection */

  printf ("Program to Maintain a List of Names\n");

  while (1) {
    /* print menu options */
    printf ("Options available\n");
    printf ("I - Insert a name (from the keyboard) into the list\n");
    printf ("P - Print the names on the list\n");
    printf ("F - Read a sequence of names from a file onto the list\n");
    printf ("R - Remove duplicate names (leaving only the first occurence)\n");
    printf ("D - Duplicate each node\n");
    printf ("Q - Quit\n");

    /* determine user selection */
    printf ("Enter desired option: ");
    scanf ("%s", option);
    
    switch (option[0])
      { case 'I':
        case 'i': 
          addName(&first);
          break;
        case 'P':
        case 'p': 
          print(first);
          break;
        case 'F':
        case 'f': 
          addNamesFromFile(&first);
          break;
        case 'R':
        case 'r': 
          removeDuplicates(first);
          break;
        case 'D': 
        case 'd': 
          duplicate(first);
          break;
        case 'Q':
        case 'q':
          printf ("Program terminated\n");
          return 0;
          break;
        default: printf ("Invalid Option - Try Again!\n");
          continue;
      }
  }
}
示例#18
0
/* static */
QIcon UIIconPool::iconSetOnOff(const QString &strNormal, const QString strNormalOff,
                               const QString &strDisabled /* = QString() */, const QString &strDisabledOff /* = QString() */,
                               const QString &strActive /* = QString() */, const QString &strActiveOff /* = QString() */)
{
    /* Prepare fallback icon: */
    static QIcon nullIcon;

    /* Prepare icon: */
    QIcon icon;

    /* Add 'normal' on/off pixmaps: */
    AssertReturn(!strNormal.isEmpty(), nullIcon);
    addName(icon, strNormal, QIcon::Normal, QIcon::On);
    AssertReturn(!strNormalOff.isEmpty(), nullIcon);
    addName(icon, strNormalOff, QIcon::Normal, QIcon::Off);

    /* Add 'disabled' on/off pixmaps (if any): */
    if (!strDisabled.isEmpty())
        addName(icon, strDisabled, QIcon::Disabled, QIcon::On);
    if (!strDisabledOff.isEmpty())
        addName(icon, strDisabledOff, QIcon::Disabled, QIcon::Off);

    /* Add 'active' on/off pixmaps (if any): */
    if (!strActive.isEmpty())
        addName(icon, strActive, QIcon::Active, QIcon::On);
    if (!strActiveOff.isEmpty())
        addName(icon, strActiveOff, QIcon::Active, QIcon::Off);

    /* Return icon: */
    return icon;
}
示例#19
0
    void  DataDescriptor::parseDescriptor()
    {
        int index = 0;
        forEach([this, index](const char* name, const char* type, int size) mutable
        {
            // check if it is array
            int array_size = 1;
            const char* p = name;
            const char* bracket = strchr(name, '[');
            size_t namelen = strlen(name);

            if (name == NULL)
            {
                LOGE("UniformBlock: SYNTAX ERROR: expecting uniform name\n");
                return;
            }
            if (bracket)                // parse array size in brackets
            {
                namelen = bracket - name;
                array_size = 0;
                p += (bracket - name) + 1;
                while (std::isdigit(*p))
                {
                    int v = *p - '0';
                    array_size = array_size * 10 + v;
                    ++p;
                }
            }
            DataEntry entry;
            short byteSize = calcSize(type);

            entry.Type = makeShaderType(type, byteSize);
            byteSize *= array_size;     // multiply by number of array elements
            entry.IsSet = false;
            entry.Count = array_size;
            entry.NotUsed = false;
            entry.IsInt =  strstr(type,"int") != nullptr;
            entry.IsMatrix = type[0] == 'm';
            entry.Index = index++;
            entry.Offset = mTotalSize;
            entry.Size = byteSize;

            if (*name == '!')           // ! indicates entry not used by shader
            {
                entry.NotUsed = true;
                ++name;
            }
            addName(name, namelen, entry);
            mLayout.push_back(entry);
            mTotalSize += entry.Size;
        });
    }
示例#20
0
void GFolderSerializer::startDir(const char* szDirName)
{
	// File indicator
	*m_pPos = 'd';
	m_pPos++;
	m_size--;
	addName(szDirName);

	// Create the GDirList
	if(chdir(szDirName) != 0)
		throw Ex("Failed to change dir to ", szDirName);
	m_dirStack.push(new GDirList());
	m_state = 3; // continue reading dir
}
示例#21
0
varInfo *RcreateUVar(char *n, symbol **pp, int type)
{  symbol   *p;
   varInfo  *v;

   if (findName((*pp),n))
      return(NULL);
   else
   {  p      = addName(pp,n);		/* add name to tree */
      v      = newVar();		/* get new variable packet */
      p->val = (char *)v;
      presetVal(v,type);		/* preset values based on type */
   }
   return(v);
}
示例#22
0
文件: 1414.cpp 项目: Otrebus/timus
int main()
{
    char input[100];
    nodes[0].word = true;
    addName("sun");
    while(gets(input))
    {
        if(input[0] == '?')
        {
            int i = 1;
            while(input[i] == ' ') // Skip whitespace
                i++;
            printNames(input+i);
        }
        else
        {
            int i = 1;
            while(input[i] == ' ')
                i++;
            addName(input+i);
        }
    }
}
示例#23
0
/**
	Charge la liste de noms depuis un element XML. Cet element est sense etre
	le parent d'un element "names", qui contient lui meme les "name".
	Les noms precedemment contenus dans la liste ne sont pas effaces mais
	peuvent etre ecrases.
	@param xml_element L'element XML a analyser
	@param xml_options A set of options related to XML parsing.
	@see getXmlOptions()
*/
void NamesList::fromXml(const QDomElement &xml_element, const QHash<QString, QString> &xml_options) {
	QHash<QString, QString> xml_opt = getXmlOptions(xml_options);
	// parcourt les enfants "names" de l'element XML
	for (QDomNode node = xml_element.firstChild() ; !node.isNull() ; node = node.nextSibling()) {
		QDomElement names = node.toElement();
		if (names.isNull() || names.tagName() != xml_opt["ParentTagName"]) continue;
		// parcourt les petits-enfants "name"
		for (QDomNode n = names.firstChild() ; !n.isNull() ; n = n.nextSibling()) {
			QDomElement name = n.toElement();
			if (name.isNull() || name.tagName() != xml_opt["TagName"]) continue;
			addName(name.attribute(xml_opt["LanguageAttribute"]), name.text());
		}
	}
}
示例#24
0
int main(void){
	FILE *fp;
	
	char name[MAX_LAST_NAME_SIZE];
	fp = fopen("all-names.txt","r");
	PhoneBook *head, *append;
	head = (PhoneBook *) malloc(sizeof(PhoneBook));
	strcpy(head -> LastName, "ben");
	head -> pNext = NULL;
	append = head;

	while(fscanf(fp, "%s", name) != EOF){
		//printf("%s", name);
		append = addName(name, append);
	}
	append = addName("tzuen", append);
//	printBook(head);
//	printf("%p\n", head->pNext);
	
	append = head->pNext;
	int a = &head->LastName;
	int b = &append->LastName;
	int offset = b - a;
//	printf("offset:%d\n",b-a);
	append = head;
	float startTime = 0 , endTime = 0;
        startTime = (float)clock()/CLOCKS_PER_SEC;
        
	findName_3("tzuen", &(append->LastName), offset);
        
        endTime = (float)clock()/CLOCKS_PER_SEC;
        printf("time:%f\n", endTime-startTime);

//	printstruct(head);
	return 0;
}
示例#25
0
void Folder::addChild(string name, int& id)
{
	Node *temp_node;
	string first, last;

	temp_node = lookupID(name);

	if (splitName(name, first, last) && temp_node != NULL)
	{
		if (temp_node->numberOfChildren == 0) //first child
		{
			temp_node->numberOfChildren++;

			temp_node->child = new string *[1];
			temp_node->child[0] = new string[2];

			temp_node->child[0][0] = first;
			temp_node->child[0][1] = last;
		}

		else
		{
			temp_node->numberOfChildren++;

			string **temp = new string* [temp_node->numberOfChildren]; //create temporary multidimensional dynamically allocated array of size numberOfChildren

			for (int i = 0; i < temp_node->numberOfChildren - 1; ++i) //populate array with old data
			{
				temp[i] = new string[2];

				temp[i][0] = temp_node->child[i][0];
				temp[i][1] = temp_node->child[i][1];

				delete[] temp_node->child[i];
			}
			delete temp_node->child; //delete old child array

			temp[temp_node->numberOfChildren - 1] = new string[2]; //assign new child to last array position
			temp[temp_node->numberOfChildren - 1][0] = first;
			temp[temp_node->numberOfChildren - 1][1] = last;

			temp_node->child = temp; //assign temp memory address to node
		}
		addName(true, true, name, "", id);
		cout << "ADDED: " << name << " UID: ID" << setw(3) << setfill('0') << temp_node->id << " <as child>" << endl;
	}
}
示例#26
0
void
QvNode::setName(const QvName &newName)
{
    if (! !(*objName)) {
	removeName(this, objName->getString());
    }
    delete objName;

    const char *str = newName.getString();
    QvBool isBad = 0;

    if (newName.getLength() > 0 &&
	!QvName::isNodeNameStartChar(str[0])) isBad = TRUE;

    int i;
    for (i = 1; i < newName.getLength() && !isBad; i++) {
	isBad = !QvName::isNodeNameChar(str[i]);
    }

    if (isBad) {
	QvString goodString;

	if (!QvName::isNodeNameStartChar(str[0])) {
	    goodString += "_";
	}
	for (i = 0; i < newName.getLength(); i++) {
	    char temp[2];
	    temp[0] = str[i]; temp[1] = '\0';
	    if (!QvName::isNodeNameChar(str[i]))
		goodString += "_";
	    else
		goodString += temp;
	}
#ifdef DEBUG
	QvDebugError::post("QvNode::setName", "Bad characters in"
			   " name '%s'.  Replacing with name '%s'",
			   str, goodString.getString());
#endif       
	objName = new QvName(goodString);
    }
    else {
	objName = new QvName(newName);
    }
    if (! !(*objName)) {
	addName(this, objName->getString());
    }
}
示例#27
0
文件: expr2.cpp 项目: yoosofan/REXX
bool  parserCls::factor(void)
{
  EtokenType lTt1 = getTokenType();
  bool bb1 = true ;
  tokenContainCls lTc1 =getCurToken();

  switch(lTt1)
  {
	 case OrdNumber:
	 case SciNumber:
	 case String :
	 case Array :
		  addOperand() ;

		  exprFound = true ;
		  needOperand = false ;
		noTokenInExpr++;

		  getToken();
	 break ;
	 case Name :

		 exprFound = true ;
		 needOperand = false ;
		 noTokenInExpr++;
		 getToken();
		 if(getTokenType() == Lparen )
			addFunction(lTc1);
		 else
			 addName(lTc1) ;
	 break ;
	 case Lparen :
		addOperator() ;
		recursiveLparen() ;
	 break ;
	 case Rparen :

	 break ;
	 default :
		if(needOperand)
			 errorFactor();
		 bb1 = false ;
	}
  return bb1 ;
}
示例#28
0
void Folder::addSpouse(string name, int& id) //working
{
	Node *temp_node;
	string first, last;

	temp_node = lookupID(name);

	if (splitName(name, first, last))
		if (temp_node != NULL)
		{
			temp_node->spouse[0] = first;
			temp_node->spouse[1] = last;

			addName(true, false, name, temp_node->name[0] + ' ' + temp_node->name[1], id);

			cout << "ADDED: " << name << " UID: ID" << setw(3) << setfill('0') << temp_node->id << " <as spouse>" << endl;
		}
}
示例#29
0
    /**
     * Add an walb device.
     * RETURN:
     *   false when some error occurs.
     */
    bool addNolock(const std::string &wdevName) {
        std::string path = device::getPollingPath(wdevName);
        Fd fd(::open(path.c_str(), O_RDONLY), std::string("addNolock:can't open ") + path);

        if (!addName(wdevName, fd())) return false;

        resetTrigger(fd());

        struct epoll_event ev;
        ::memset(&ev, 0, sizeof(ev));
        ev.events = EPOLLPRI;
        ev.data.fd = fd();
        if (::epoll_ctl(efd_(), EPOLL_CTL_ADD, fd(), &ev) < 0) {
            delName(wdevName, fd());
            return false;
        }
        fd.dontClose();
        return true;
    }
示例#30
0
void MainWindow::newImage()
{
    Canvas * canvas = new Canvas;
    canvas->registerObserver(this);

    bool valideName;

    QString imageName = QInputDialog::getText(this, tr("Name"),
                                              tr("Image Name : "), QLineEdit::Normal,
                                              "", &valideName);
    if(valideName)
    {
        if(!imageName.isEmpty())
        {
            ui->tabWidget->addTab(canvas, imageName);
        }
        else
        {
            ui->tabWidget->addTab(canvas, tr("untitled"));
        }
    }
    else
    {
        return;
    }

    QPoint imageSize;
    imageSize.setX(QInputDialog::getInt(this, tr("Width"), tr("Image width metrics in px")));
    imageSize.setY(QInputDialog::getInt(this, tr("Height"), tr("Image height metrics in px")));

    if(imageSize.x() && imageSize.y())
    {
        canvas->setSceneRect(0, 0, imageSize.x(), imageSize.y());
    }
    else
    {
        canvas->setSceneRect(0, 0, 250, 250);
    }
    canvas->setBackgroundBrush(QBrush(QColor(255, 255, 255)));
    //canvas->addShape(new LineSegment);
    connect((Canvas*)ui->tabWidget->currentWidget(), SIGNAL(addName(QString)), this, SLOT(addedItem(QString)));
}