Beispiel #1
0
bool Databases::buildMap(const dBase &db, Common::StringMap &map) const {
	int fLanguage = findField(db, "Langage", dBase::kTypeString);
	int fGroup    = findField(db, "Nom"    , dBase::kTypeString);
	int fSection  = findField(db, "Section", dBase::kTypeString);
	int fKeyword  = findField(db, "Motcle" , dBase::kTypeString);
	int fText     = findField(db, "Texte"  , dBase::kTypeString);

	if ((fLanguage < 0) || (fGroup < 0) || (fSection < 0) || (fKeyword < 0) || (fText < 0))
		return false;

	const Common::Array<dBase::Record> &records = db.getRecords();

	Common::Array<dBase::Record>::const_iterator record;
	for (record = records.begin(); record != records.end(); ++record) {
		Common::String key;

		key += db.getString(*record, fLanguage) + ":";
		key += db.getString(*record, fGroup   ) + ":";
		key += db.getString(*record, fSection ) + ":";
		key += db.getString(*record, fKeyword );

		map.setVal(key, db.getString(*record, fText));
	}

	return true;
}
Beispiel #2
0
void initialiseString() {
    FieldBlock *count = NULL, *value, *offset;

    string_class = findSystemClass0(SYMBOL(java_lang_String));
    registerStaticClassRef(&string_class);

    if(string_class != NULL) {
        count = findField(string_class, SYMBOL(count), SYMBOL(I));
        value = findField(string_class, SYMBOL(value), SYMBOL(array_C));
        offset = findField(string_class, SYMBOL(offset), SYMBOL(I));
    }

    /* findField doesn't throw an exception... */
    if((count == NULL) || (value == NULL) || (offset == NULL)) {
        jam_fprintf(stderr, "Error initialising VM (initialiseString)\n");
        exitVM(1);
    }

    count_offset = count->offset;
    value_offset = value->offset;
    offset_offset = offset->offset;

    /* Init hash table and create lock */
    initHashTable(hash_table, HASHTABSZE, TRUE);
}
Beispiel #3
0
Object *classlibThreadPreInit(Class *thread_class, Class *thrdGrp_class) {
    MethodBlock *system_init_mb, *main_init_mb;
    FieldBlock *thread_status_fb, *eetop_fb;
    Object *system, *main, *main_name;

    init_mb_with_name = findMethod(thread_class, SYMBOL(object_init),
                           SYMBOL(_java_lang_ThreadGroup_java_lang_String__V));

    init_mb_no_name = findMethod(thread_class, SYMBOL(object_init),
                         SYMBOL(_java_lang_ThreadGroup_java_lang_Runnable__V));

    thread_status_fb = findField(thread_class, SYMBOL(threadStatus),
                                               SYMBOL(I));

    eetop_fb = findField(thread_class, SYMBOL(eetop), SYMBOL(J));

    system_init_mb = findMethod(thrdGrp_class, SYMBOL(object_init),
                                               SYMBOL(___V));

    main_init_mb = findMethod(thrdGrp_class, SYMBOL(object_init),
                           SYMBOL(_java_lang_ThreadGroup_java_lang_String__V));

    if(init_mb_with_name   == NULL || init_mb_no_name == NULL ||
          system_init_mb   == NULL || main_init_mb    == NULL ||
          thread_status_fb == NULL || eetop_fb        == NULL)
        return NULL;

    CLASS_CB(thread_class)->flags |= JTHREAD;

    thread_status_offset = thread_status_fb->u.offset;
    eetop_offset = eetop_fb->u.offset;

    if((system = allocObject(thrdGrp_class)) == NULL)
        return NULL;

    executeMethod(system, system_init_mb);
    if(exceptionOccurred())
        return NULL;

    if((main = allocObject(thrdGrp_class)) == NULL ||
       (main_name = Cstr2String("main")) == NULL)
        return NULL;

    executeMethod(main, main_init_mb, system, main_name);
    if(exceptionOccurred())
        return NULL;

    return main;
}
Beispiel #4
0
int classlibInitialiseNatives() {
    Class *field_accessor;
    FieldBlock *base_fb = NULL;
    char *dll_path = getBootDllPath();
    char *dll_name = getDllName("java");
    char path[strlen(dll_path) + strlen(dll_name) + 2];

    strcat(strcat(strcpy(path, dll_path), "/"), dll_name);
    sysFree(dll_name);

    if(!resolveDll(path, NULL)) {
        jam_fprintf(stderr, "Error initialising natives: couldn't open "
                            "libjava.so: use -verbose:jni for more "
                            "information\n");
        return FALSE;
    }

    field_accessor = findSystemClass0(SYMBOL(
                         sun_reflect_UnsafeStaticFieldAccessorImpl));

    if(field_accessor != NULL)
        base_fb = findField(field_accessor, SYMBOL(base),
                                            SYMBOL(sig_java_lang_Object));

    if(base_fb == NULL) {
        jam_fprintf(stderr, "Error initialising natives: %s "
                            "missing or malformed\n",
                            SYMBOL(sun_reflect_UnsafeStaticFieldAccessorImpl));
        return FALSE;
    }

    hideFieldFromGC(base_fb);

    return initialiseJVMInterface();
}
Beispiel #5
0
void InputFileText::readData(std::vector<T> &buff, int ncol, long frow, long lrow)
{
	if(!isOpened())
		throw IOException("Error in InputFileText::readData() ", 0);

	int buff_sz = lrow - frow + 1;
	int buff_off = 0;

	fileStream.clear();
	fileStream.seekg(0, std::ios::beg);

	buff.resize(buff_sz);
	for(int i = frow; i < lrow+1; i++) {
		std::string line;
		if(getline(fileStream, line)) {
			int first = 0;
			int last  = 0;
			int colCounter = 0;
			while(colCounter <= ncol && colCounter <= ncols)
			{
				findField(line,first,last,last);
				colCounter++;
			}
			if(colCounter == ncol+1)
			{
				std::istringstream ist(std::string(line,first,last-first));
				ist >> buff[buff_off++];
			}
		}
		else
			throw IOException("InputFileText::readData()", 0);
Beispiel #6
0
void mainThreadSetContextClassLoader(Object *loader) {
    FieldBlock *fb = findField(thread_class, SYMBOL(contextClassLoader),
                                             SYMBOL(sig_java_lang_ClassLoader));
    if(fb != NULL)
        //INST_DATA(main_ee.thread)[fb->offset] = (uintptr_t)loader;
        INST_DATA(main_thread.thread)[fb->offset] = (uintptr_t)loader;
}
Beispiel #7
0
static void buildResultFieldMap(struct genePredReader* gpr)
/* determine indices of fields for current result and fill in the mapping
 * table. */
{
int iCol = 0, iFld;
char *fname;

/* initialize to not used */
for (iFld = 0; iFld < GENEPREDX_NUM_COLS+1; iFld++)
    gpr->queryToFldMap[iFld] = -1;

/* build sparse field map */
while ((fname = sqlFieldName(gpr->sr)) != NULL)
    {
    if (sameString(fname, "bin"))
        {
        if (iCol != 0)
            errAbort("bin column not first column in %s", gpr->table);
        gpr->rowOffset = 1;
        }
    else
        {
        struct field* field = findField(fname);
        if (field != NULL)
            {
            gpr->queryToFldMap[iCol] = field->fldIdx;
            gpr->optFields |= field->optFlag;
            }
        }
    gpr->queryCols++;
    iCol++;
    }
gpr->numFields = optFieldsToNumFields(gpr->optFields);
}
Beispiel #8
0
IFile& IFile::scanField(const std::string&name,std::string&str){
  if(!inMiddleOfField) advanceField();
  if(!*this) return *this;
  unsigned i=findField(name);
  str=fields[i].value;
  fields[i].read=true;
  return *this;
}
Beispiel #9
0
void classlibCacheClassLoaderFields(Class *loader_class) {
    FieldBlock *classes_fb = findField(loader_class, SYMBOL(classes),
                                       SYMBOL(sig_java_util_vector));

    FieldBlock *parent_fb = findField(loader_class, SYMBOL(parent),
                                      SYMBOL(sig_java_lang_ClassLoader));

    if(classes_fb == NULL || parent_fb == NULL) {
        jam_fprintf(stderr, "Expected \"classes\" and/or \"parent\" field "
                            "missing in java.lang.ClassLoader\n");
        exitVM(1);
    }

    hideFieldFromGC(classes_fb);

    ldr_classes_offset = classes_fb->u.offset;
    ldr_parent_offset = parent_fb->u.offset;
}
Beispiel #10
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void PdmObject::addFieldNoDefault(PdmFieldHandle* field, const QString& keyword, PdmUiItemInfo * fieldDescription)
{
    field->setUiItemInfo(fieldDescription);
    field->setKeyword(keyword);
    field->setOwnerObject(this);

    assert(findField(keyword) == NULL);
    m_fields.push_back(field);
}
Beispiel #11
0
/**
* Найти описание поля
*
* Если поля нет, то оно создается
*/
TagHelper AdHocCommand::lookupField(const char *name)
{
	TagHelper field = findField(name);
	if ( field ) return field;
	field = new XmlTag("field");
	field->setAttribute("var", name);
	(*this)["command"]["x"] += (XmlTag*)field;
	return field;
}
Beispiel #12
0
	shared_ptr <T> findFieldValue(const string& fieldName) const
	{
		shared_ptr <headerField> field = findField(fieldName);

		if (field)
			return dynamicCast <T>(field->getValue());
		else
			return null;
	}
Beispiel #13
0
bool Table::removeField(const QString& sFieldName)
{
    int index = findField(sFieldName);
    if( index != -1)
    {
        m_fields.remove(index);
        return true;
    }
    return false;
}
Beispiel #14
0
/**
* Вернуть значение поля
*/
std::string AdHocCommand::getFieldValue(const char *name, const char *default_value)
{
	TagHelper field = findField(name);
	if ( field )
	{
		TagHelper value = field->firstChild("value");
		if ( value ) return value;
	}
	return default_value;
}
Beispiel #15
0
//FIXME
void printStringObject(O obj)
{

    int offset;
    O char_obj;
    FieldBlock_t *fb =
        (FieldBlock_t *) findField(java_lang_String, "value", "[C");
    offset = fb->offset;
    char_obj = *(((O *) obj->data) + offset - 1);
    printf("String:%s\n", (char *) char_obj->data);

}
void SolvedElectrostaticSystem::saveFieldGNUPlot(std::string fileName) {
    if(!fieldFound) findField();
    std::ofstream outputFile;
    outputFile.open(fileName.c_str());
    for(int i=iMin; i<=iMax; i++) {
        for(int j=jMin; j<=jMax; j++) {
            outputFile << i << " " << j << " " << field(i-iMin, j-jMin) << "\n";
        }
        outputFile << "\n";
    }
    outputFile.close();
}
Beispiel #17
0
void initString()
{
    if (java_lang_String == NULL)
        java_lang_String = loadClass("java/lang/String");
    FieldBlock_t *count;
    FieldBlock_t *value;
    FieldBlock_t *offset;

    count = (FieldBlock_t *) findField(java_lang_String, "count", "I");
    value = (FieldBlock_t *) findField(java_lang_String, "value", "[C");
    offset = (FieldBlock_t *) findField(java_lang_String, "offset", "I");

    if ((count == NULL) || (value == NULL) || (offset == NULL))
        throwException("initString error");

    count_offset = count->offset;
    value_offset = value->offset;
    offset_offset = offset->offset;

    inited = TRUE;
}
Beispiel #18
0
int classlibInitialiseJNI() {
    FieldBlock *buffCap_fb, *buffAddr_fb, *rawdata_fb;
    Class *buffer_class;

    /* Cache class and method/fields for JNI 1.4 NIO support */

    buffer_class = findSystemClass0(SYMBOL(java_nio_Buffer));
    buffImpl_class = findSystemClass0(
                         SYMBOL(java_nio_DirectByteBufferImpl_ReadWrite));
    rawdata_class = findSystemClass0(sizeof(uintptr_t) == 4
                                            ? SYMBOL(gnu_classpath_Pointer32)
                                            : SYMBOL(gnu_classpath_Pointer64));

    if(buffer_class == NULL || buffImpl_class == NULL || rawdata_class == NULL)
        return FALSE;

    buffImpl_init_mb = findMethod(buffImpl_class, SYMBOL(object_init),
                      SYMBOL(_java_lang_Object_gnu_classpath_Pointer_III__V));

    buffCap_fb = findField(buffer_class, SYMBOL(cap), SYMBOL(I));
    rawdata_fb = findField(rawdata_class, SYMBOL(data),
                           sizeof(uintptr_t) == 4 ? SYMBOL(I) : SYMBOL(J));
    buffAddr_fb = findField(buffer_class, SYMBOL(address),
                            SYMBOL(sig_gnu_classpath_Pointer));

    if(buffImpl_init_mb == NULL || buffCap_fb == NULL || rawdata_fb == NULL
                                || buffAddr_fb == NULL)
        return FALSE;

    registerStaticClassRef(&buffImpl_class);
    registerStaticClassRef(&rawdata_class);

    buffCap_offset = buffCap_fb->u.offset;
    buffAddr_offset = buffAddr_fb->u.offset;
    rawdata_offset = rawdata_fb->u.offset;

    return TRUE;
}
Beispiel #19
0
int classlibInitialiseNatives() {
  //  printf("classlib\n");
    FieldBlock *pd = findField(java_lang_Class, SYMBOL(pd),
                               SYMBOL(sig_java_security_ProtectionDomain));

  //  printf("%p\n",pd);
    if(pd == NULL) {
        jam_fprintf(stderr, "Expected \"pd\" field missing in "
                            "java.lang.Class\n");
        return FALSE;
    }

    pd_offset = pd->u.offset;
    return TRUE;
}
Beispiel #20
0
int DBTable::findRow( const char* fieldName, const char* val ) 
{
	if (fieldName && fieldName[0] && val && val[0]) 
	{
		int fieldIndex = findField( fieldName );
		if (fieldIndex != -1) 
		{
			for (int rowIndex = 0; rowIndex < m_kRowVector.size(); rowIndex++) 
			{
				const char* cellStr = getCell_S( rowIndex, fieldIndex );
				if (stricmp( cellStr, val ) == 0)
					return rowIndex;
			}
		}
	}
	return -1;
}
Beispiel #21
0
T fieldValue(const Fields& fields, const std::string& name, const T& defaultVal)
{
   Fields::const_iterator pos = findField(fields, name);
   if (pos != fields.end())
   {
      try
      {
         return boost::lexical_cast<T>(pos->second);
      }
      catch(boost::bad_lexical_cast&)
      {
         return defaultVal;
      }
   }
   else // not found, return default
   {
      return defaultVal;
   }
}
Beispiel #22
0
bool fieldValue(const Fields& fields, 
                const std::string& name, 
                const Predicate& validator,
                T* pValue)
{
   Fields::const_iterator pos = findField(fields, name);
   if (pos != fields.end())
   {
      try
      {
         *pValue = boost::lexical_cast<T>(pos->second);
         return validator(*pValue);
      }
      catch(boost::bad_lexical_cast&)
      {
         return false;
      }
   }
   else 
   {
      return false;
   }
}
Beispiel #23
0
void initialiseException() {
    FieldBlock *bcktrce;
    int i;

    ste_class = findSystemClass0(SYMBOL(java_lang_StackTraceElement));
    ste_array_class = findArrayClass(SYMBOL(array_java_lang_StackTraceElement));
    vmthrow_class = findSystemClass0(SYMBOL(java_lang_VMThrowable));
    throw_class = findSystemClass0(SYMBOL(java_lang_Throwable));
    bcktrce = findField(vmthrow_class, SYMBOL(backtrace), SYMBOL(sig_java_lang_Object));
    vmthrow_init_mb = findMethod(ste_class, SYMBOL(object_init),
                         SYMBOL(_java_lang_String_I_java_lang_String_java_lang_String_Z__V));

    if((bcktrce == NULL) || (vmthrow_init_mb == NULL)) {
        jam_fprintf(stderr, "Error initialising VM (initialiseException)\n");
        exitVM(1);
    }

    CLASS_CB(vmthrow_class)->flags |= VMTHROWABLE;
    backtrace_offset = bcktrce->offset;

    registerStaticClassRef(&ste_class);
    registerStaticClassRef(&ste_array_class);
    registerStaticClassRef(&vmthrow_class);
    registerStaticClassRef(&throw_class);

    /* Load and register the exceptions used within the VM.
       These are preloaded to speed up access.  The VM will
       abort if any can't be loaded */

    for(i = 0; i < MAX_EXCEPTION_ENUM; i++) {
        exceptions[i] = findSystemClass0(symbol_values[exception_symbols[i]]);
        registerStaticClassRef(&exceptions[i]);
    }

    inited = TRUE;
}
Beispiel #24
0
void AnyType::getItem(double *item, string field){
	int ind=findField(field);
	*item=doubleItem[ind];
}
Beispiel #25
0
void detachThread(Thread *thread) {
    Object *group, *excep;
    //ExecEnv *ee = thread->ee;
    //Object *jThread = ee->thread;
    Object *jThread = thread->thread;
    Object *vmthread = (Object*)INST_DATA(jThread)[vmthread_offset];

    /* Get the thread's group */
    group = (Object *)INST_DATA(jThread)[group_offset];

    /* If there's an uncaught exception, call uncaughtException on the thread's
       exception handler, or the thread's group if this is unset */
    if((excep = exceptionOccurred())) {
        FieldBlock *fb = findField(thread_class, SYMBOL(exceptionHandler),
                                                 SYMBOL(sig_java_lang_Thread_UncaughtExceptionHandler));
        Object *thread_handler = fb == NULL ? NULL : (Object *)INST_DATA(jThread)[fb->offset];
        Object *handler = thread_handler == NULL ? group : thread_handler;

        MethodBlock *uncaught_exp = lookupMethod(handler->classobj, SYMBOL(uncaughtException),
                                                 SYMBOL(_java_lang_Thread_java_lang_Throwable__V));

        if(uncaught_exp) {
            clearException();
            DummyFrame dummy;
            executeMethod(&dummy, handler, uncaught_exp, jThread, excep);
        } else
            printException();
    }

    /* remove thread from thread group */
    DummyFrame dummy;
    executeMethod(&dummy, group, (CLASS_CB(group->classobj))->method_table[rmveThrd_mtbl_idx], jThread);

    /* set VMThread ref in Thread object to null - operations after this
       point will result in an IllegalThreadStateException */
    INST_DATA(jThread)[vmthread_offset] = 0;

    /* Remove thread from the ID map hash table */
    deleteThreadFromHash(thread);

    /* Disable suspend to protect lock operation */
    disableSuspend(thread);

    /* Grab global lock, and update thread structures protected by
       it (thread list, thread ID and number of daemon threads) */
    pthread_mutex_lock(&lock);

    /* remove from thread list... */
    if((thread->prev->next = thread->next))
        thread->next->prev = thread->prev;

    /* One less live thread */
    threads_count--;

    /* Recycle the thread's thread ID */
    freeThreadID(thread->id);

    /* Handle daemon thread status */
    if(!INST_DATA(jThread)[daemon_offset])
        non_daemon_thrds--;

    pthread_mutex_unlock(&lock);

    /* notify any threads waiting on VMThread object -
       these are joining this thread */
    objectLock(vmthread);
    objectNotifyAll(vmthread);
    objectUnlock(vmthread);

    /* It is safe to free the thread's ExecEnv and stack now as these are
       only used within the thread.  It is _not_ safe to free the native
       thread structure as another thread may be concurrently accessing it.
       However, they must have a reference to the VMThread -- therefore, it
       is safe to free during GC when the VMThread is determined to be no
       longer reachable. */
//    sysFree(ee->stack);
    //sysFree(ee);

    /* If no more daemon threads notify the main thread (which
       may be waiting to exit VM).  Note, this is not protected
       by lock, but main thread checks again */

    if(non_daemon_thrds == 0) {
        /* No need to bother with disabling suspension
         * around lock, as we're no longer on thread list */
        pthread_mutex_lock(&exit_lock);
        pthread_cond_signal(&exit_cv);
        pthread_mutex_unlock(&exit_lock);
    }

    TRACE("Thread 0x%x id: %d detached from VM\n", thread, thread->id);
}
Beispiel #26
0
void initialiseThreadStage2(InitArgs *args) {
    Object *java_thread;
    Class *thrdGrp_class;
    MethodBlock *run, *remove_thread;
    FieldBlock *group, *priority, *root, *threadId;
    FieldBlock *vmThread = NULL, *thread = NULL;
    FieldBlock *vmData, *daemon, *name;

    /* Load thread class and register reference for compaction threading */
    thread_class = findSystemClass0(SYMBOL(java_lang_Thread));
    registerStaticClassRef(&thread_class);

    if(thread_class != NULL) {
        vmThread = findField(thread_class, SYMBOL(vmThread), SYMBOL(sig_java_lang_VMThread));
        daemon = findField(thread_class, SYMBOL(daemon), SYMBOL(Z));
        name = findField(thread_class, SYMBOL(name), SYMBOL(sig_java_lang_String));
        group = findField(thread_class, SYMBOL(group), SYMBOL(sig_java_lang_ThreadGroup));
        priority = findField(thread_class, SYMBOL(priority), SYMBOL(I));
        threadId = findField(thread_class, SYMBOL(threadId), SYMBOL(J));

        init_mb = findMethod(thread_class, SYMBOL(object_init),
                             SYMBOL(_java_lang_VMThread_java_lang_String_I_Z__V));
        run = findMethod(thread_class, SYMBOL(run), SYMBOL(___V));

        vmthread_class = findSystemClass0(SYMBOL(java_lang_VMThread));
        CLASS_CB(vmthread_class)->flags |= VMTHREAD;

        /* Register class reference for compaction threading */
        registerStaticClassRef(&vmthread_class);

        if(vmthread_class != NULL) {
            thread = findField(vmthread_class, SYMBOL(thread), SYMBOL(sig_java_lang_Thread));
            vmData = findField(vmthread_class, SYMBOL(vmData), SYMBOL(I));
        }
    }

    /* findField and findMethod do not throw an exception... */
    if((init_mb == NULL) || (vmData == NULL) || (run == NULL) || (daemon == NULL) ||
       (name == NULL) || (group == NULL) || (priority == NULL) || (vmThread == NULL) ||
       (thread == NULL) || (threadId == NULL))
        goto error;

    vmthread_offset = vmThread->offset;
    thread_offset = thread->offset;
    vmData_offset = vmData->offset;
    daemon_offset = daemon->offset;
    group_offset = group->offset;
    priority_offset = priority->offset;
    threadId_offset = threadId->offset;
    name_offset = name->offset;
    run_mtbl_idx = run->method_table_index;

    /* Initialise the Java-level thread objects for the main thread */
    java_thread = initJavaThread(&main_thread, FALSE, "main");

    /* Main thread is now sufficiently setup to be able to run the thread group
       initialiser.  This is essential to create the root thread group */
    thrdGrp_class = findSystemClass(SYMBOL(java_lang_ThreadGroup));

    root = findField(thrdGrp_class, SYMBOL(root), SYMBOL(sig_java_lang_ThreadGroup));

    addThread_mb = findMethod(thrdGrp_class, SYMBOL(addThread),
                                             SYMBOL(_java_lang_Thread_args__void));

    remove_thread = findMethod(thrdGrp_class, SYMBOL(removeThread),
                                              SYMBOL(_java_lang_Thread_args__void));

    /* findField and findMethod do not throw an exception... */
    if((root == NULL) || (addThread_mb == NULL) || (remove_thread == NULL))
        goto error;

    rmveThrd_mtbl_idx = remove_thread->method_table_index;

    /* Add the main thread to the root thread group */
    INST_DATA(java_thread)[group_offset] = root->static_value;
    {
        DummyFrame dummy;
        executeMethod(&dummy, ((Object*)root->static_value), addThread_mb, java_thread);
    }

    // dyn
    INST_DATA(java_thread)[vmthread_offset] = 0;

    /* Setup signal handling.  This will be inherited by all
       threads created within Java */
    initialiseSignals();

    /* Create the signal handler thread.  It is responsible for
       catching and handling SIGQUIT (thread dump) and SIGINT
       (user-termination of the VM, e.g. via Ctrl-C).  Note it
       must be a valid Java-level thread as it needs to run the
       shutdown hooks in the event of user-termination */
    createVMThread("Signal Handler", dumpThreadsLoop);

    return;

error:
    jam_fprintf(stderr, "Error initialising VM (initialiseMainThread)\nCheck "
                        "the README for compatible versions of GNU Classpath\n");
    printException();
    exitVM(1);
}
/*
  After loading XML building, following operations should be done:
  - refresh IDPool
  - refresh connections between primitives
*/
void
globalContainer::refreshPrimitives()
{
  LBFloor *helpFloor;
  LField *helpField;
  LBWindow *helpWindow;
  lbpassage *helpPassage;


  if(floorsTree->hasChild())
    helpFloor = (LBFloor*)floorsTree -> child;
  else
    return;

  while(1)
    {
      reserveID(helpFloor -> giveID());

      //if helpFlor has any child, search children to find field's window with ID
      if(helpFloor->hasChild())
	{
	  helpField = (LField*)helpFloor->child;

	  while(1)
	    {
	      reserveID(helpField->giveID());

	      //check if any wall has window with ID
	      for(int cntW = 0; cntW < 4; cntW++)
		{
		  if(helpField->windowTree[cntW]->hasChild())
		    {
		      helpWindow = (LBWindow*)helpField->windowTree[cntW]->child;
		      
		      while(1)
			{
			  reserveID(helpWindow->giveID());
			  
			  if(!helpWindow -> isLast())
			    helpWindow = (LBWindow*)(helpWindow -> next);
			  else
			    break;
			}
		    }

		  if(helpField->passageTree[cntW]->hasChild())
		    {
		      helpPassage = (lbpassage*)helpField->passageTree[cntW]->child;

		      while(1)
			{
			  reserveID(helpPassage->giveID());
			  /*
			    check with what primitive passage has connecion and
			    set adequate *destObject
			  */
			  {
			    LBStairs *destStairs = 
			      findStairs(helpPassage->destObjectID);

			    LField *destField = 
			      findField(helpPassage->destObjectID);

			    if(destStairs != NULL)
			      helpPassage -> destObject = (LObject*)destStairs;
			    else
			      helpPassage -> destObject = (LObject*)destField;
			    }
			  
			  if(!helpPassage -> isLast())
			    helpPassage = (lbpassage*)(helpPassage -> next);
			  else
			    break;
			}
		    }
		}//for cntW
	      
	      if(! helpField -> isLast())
		helpField = (LField*)(helpField -> next);
	      else
		break;//floor searched
	    }
	}
      if(! helpFloor -> isLast())
	helpFloor = (LBFloor*)(helpFloor -> next);
      else
	break;
    }


  LBStairs *helpStairs;

  if(stairsTree->hasChild())
    {
      helpStairs = (LBStairs*)stairsTree->child;
      while(1)
	{
	  reserveID(helpStairs->giveID());      

	  {//connections
	    helpStairs->connBottom = findField(helpStairs->connBottomID);
	    helpStairs->connTop = findField(helpStairs->connTopID);
	  }

	  if(! helpStairs -> isLast())
	    helpStairs = (LBStairs*)(helpStairs -> next);
	  else
	    break;
	}
    }
}
void FlatFileExecStreamImpl::open(bool restart)
{
    if (restart) {
        releaseResources();
    }
    SingleOutputExecStream::open(restart);

    if (!restart) {
        bufferLock.allocatePage();
        uint cbPageSize = bufferLock.getPage().getCache().getPageSize();
        pBufferStorage = bufferLock.getPage().getWritableData();
        pBuffer->setStorage((char*)pBufferStorage, cbPageSize);
    }
    pBuffer->open();
    pBuffer->read();
    next = pBuffer->getReadPtr();
    isRowPending = false;
    nRowsOutput = nRowErrors = 0;
    lastResult.reset();

    if (header) {
        FlatFileRowDescriptor headerDesc;
        for (uint i = 0; i < rowDesc.size(); i++) {
            headerDesc.push_back(
                FlatFileColumnDescriptor(
                    FLAT_FILE_MAX_COLUMN_NAME_LEN));
        }
        headerDesc.setLenient(lenient);
        if (mapped) {
            headerDesc.setUnbounded();
        }
        pParser->scanRow(
            pBuffer->getReadPtr(), pBuffer->getSize(), headerDesc, lastResult);
        pBuffer->setReadPtr(lastResult.next);
        if (lastResult.status != FlatFileRowParseResult::NO_STATUS) {
            logError(lastResult);
            try {
                checkRowDelimiter();
            } catch (FennelExcn e) {
                reason = e.getMessage();
            }
            throw FennelExcn(
                FennelResource::instance().flatfileNoHeader(
                    dataFilePath, reason));
        }

        // Generate mapping from text file columns to output columns.
        // Match names in the header with output field names. Names in
        // the header are always trimmed.
        if (mapped) {
            if (! lenient) {
                throw FennelExcn(
                    FennelResource::instance()
                    .flatfileMappedRequiresLenient());
            }

            pParser->stripQuoting(lastResult, true);
            uint nFields = lastResult.getReadCount();
            int found = 0;

            VectorOfUint columnMap;
            columnMap.resize(nFields);
            for (uint i = 0; i < nFields; i++) {
                char *n = lastResult.getColumn(i);
                if (n == NULL) {
                    columnMap[i] = MAXU;
                } else {
                    std::string name(
                        n,
                        lastResult.getColumnSize(i));
                    columnMap[i] = findField(name);
                    if (!isMAXU(columnMap[i])) {
                        found++;
                    }
                }
            }
            if (found == 0) {
                throw FennelExcn(
                    FennelResource::instance().flatfileNoMappedColumns(
                        std::string(" "),
                        std::string(" ")));
            }
            rowDesc.setMap(columnMap);
        }
    }

    done = false;
}
Beispiel #29
0
void AnyType::getItem(long long *item, string field){
	int ind=findField(field);
	*item=longLongItem[ind];
}
Beispiel #30
0
void AnyType::getItem(bool *item, string field){
	int ind=findField(field);
	*item=boolItem[ind];
}