Ejemplo n.º 1
0
void RDBParser::parseVariables(LazyFetchItem *parent, char *buf)
{
    static const char *unknown = "?";
	
	QString		varName;
	QCString	value;
	int			pos;

    Q_ASSERT(parent);
    if (buf == 0 || strlen(buf) == 0) {
        return;
	}

    if (buf[0] == 0) {
        buf = (char*)unknown;
	}
		
	QRegExp var_re("\\s*([^\\n\\s]+) => ([^\\n]+)");
	QRegExp ref_re("(#<([^:]|::)+:0x[\\da-f]+)\\s*([^=]*)>?");
	QRegExp struct_re("#<struct Struct::(\\w+)");
	
	// Look for 'dataitem => value' pairs. For example:
	// 	a => 1
  	// 	m => #<MyClass:0x30093540 @temp={"z"=>"zed", "p"=>"pee"}, @foobar="hello">
	//
	pos = var_re.search(buf);	
	if (pos != -1) {
		while (pos != -1) {
			varName = var_re.cap(1);
			if (ref_re.search(var_re.cap(2)) != -1) {
				if (var_re.cap(2).contains("=") > 0) {
					value = (ref_re.cap(1) + ">").latin1();
				} else {
					// There are no 'name=value' pairs, as in #<Qt::Color:0x0 #ff0000>
					value = var_re.cap(2).latin1();
				}
			} else if (struct_re.search(var_re.cap(2)) != -1) {
				value = (QString("#<Struct::") + struct_re.cap(1) + ">").latin1();
			} else {
				value = var_re.cap(2).latin1();
			}
			
	        DataType dataType = determineType((char *) var_re.cap(2).latin1());
			
			// 'self' variables don't need to be expandable, as their details are
			// already shown in the current frame. So always make them VALUE_TYPE's.
			if (varName == "self") {
				dataType = VALUE_TYPE;
			}
			
			setItem(parent, varName, dataType, value);
			
			pos  += var_re.matchedLength();
			pos = var_re.search(buf, pos);
		}

		return;
	}
}
Ejemplo n.º 2
0
DumpBuffer::DumpBuffer()
{
  _buffer =NULL;
  _sizeBytes=0;
  _writeOffset = 0;
  _dtype = determineType();  
  _name[0] = '\0';
  _externData =false;
}
Ejemplo n.º 3
0
void PropertyWidget::setProperty(const QString& objectPath,
                                 const QString& name,
                                 const QString& iconName,
                                 const QString& description)
{
    m_name = name;
    m_iconName = iconName;
    m_description = description;
    m_type = determineType(objectPath, iconName);
    setToolTip(description);
    ThemerAgent::maskPropertyWidget(this);
    update();
}
Ejemplo n.º 4
0
std::vector<std::string>
DirectorySearch::findResources (std::string path, std::string extension)
{
    // TODO: Move strings to CONSTANTS
    DIR *directory = nullptr;
    struct dirent *entry = nullptr;
    std::string d_name;
    
    // Add trailing slash for recursion
    if (path.at (path.length () - 1) != '/')
    {
        path += "/";
    }

    directory = opendir (path.c_str ());;
    entry = readdir (directory);

    while ((entry = readdir (directory)))
    {
        d_name = entry->d_name;

        if (d_name != "." && d_name != "..") // do not check dots
        {
            entries entry_type = determineType (path + d_name);

            if (entry_type == entries::DIRECTORY)
            {
                findResources (path + d_name, extension);
            }
            else if (entry_type == entries::FILE)
            {
                if (d_name.find(extension, (d_name.length() - extension.length())) != std::string::npos)
                {
                    files.push_back (path + d_name);
                }
            }
            else // DOT or UNKNOWN
            {
                std::cerr << "Error in DirectorySearch::findResources: UNKNOWN or DOT type fell through." << std::endl;
            }
        }
    }
    
    if (directory != nullptr)
    {
        closedir (directory);
    }
    
    return files;

} // DirectorySearch::findResources
Ejemplo n.º 5
0
DumpBuffer::DumpBuffer(size_t bytes, const char * name)
{
  _buffer = new char[bytes];
  _sizeBytes=bytes;
  _writeOffset = 0;
 
  _dtype = determineType();  
 
  if(name != NULL) strcpy(_name, name);
  else _name[0] = '\0';

  _externData =false;

}
Ejemplo n.º 6
0
string Object::getType()
{
    if (value=="") return "string";
    string temp = determineType(value);
    if (temp == "double")
    {
        if (atoi(value.c_str()) == atof(value.c_str()))
        {
            //value = atoi(value.c_str());
            temp = "int";
        }
    }
    return temp;
}
Ejemplo n.º 7
0
DumpBuffer::DumpBuffer(ifstream& myFile)
{
  _buffer = NULL;
  _sizeBytes=0;
  _writeOffset = 0;
  _name[0] = '\0';

  _dtype = determineType();  
  
  readFromFile(myFile);

  _externData =false;

}
Ejemplo n.º 8
0
void QDriveInfoPrivate::doStat(uint requiredFlags)
{
    if (data->getCachedFlag(requiredFlags))
        return;

    if (!data->getCachedFlag(CachedRootPathFlag)) {
        initRootPath();
        data->setCachedFlag(CachedRootPathFlag);
    }

    if (data->rootPath.isEmpty() || (data->getCachedFlag(CachedValidFlag) && !data->valid))
        return;

    if (!data->getCachedFlag(CachedValidFlag))
        requiredFlags |= CachedValidFlag; // force drive validation


    uint bitmask = 0;

    bitmask = CachedFileSystemNameFlag | CachedNameFlag |
              CachedReadOnlyFlag | CachedReadyFlag | CachedValidFlag;
    if (requiredFlags & bitmask) {
        getVolumeInfo();
        if (data->valid && !data->ready)
            bitmask = CachedValidFlag;
        data->setCachedFlag(bitmask);

        if (!data->valid)
            return;
    }

    bitmask = CachedDeviceFlag;
    if (requiredFlags & bitmask) {
        data->device = getDevice(data->rootPath);
        data->setCachedFlag(bitmask);
    }

    bitmask = CachedBytesTotalFlag | CachedBytesFreeFlag | CachedBytesAvailableFlag;
    if (requiredFlags & bitmask) {
        getDiskFreeSpace();
        data->setCachedFlag(bitmask);
    }

    bitmask = CachedTypeFlag;
    if (requiredFlags & bitmask) {
        data->type = determineType(data->rootPath);
        data->setCachedFlag(bitmask);
    }
}
Ejemplo n.º 9
0
int 
main( int argc, char ** argv)
{
	char option;
	
	if( argc < 2 ) 
		exitUsage(argv[0]);

   if( argv[1][0] != '-' &&argv[1][0] != '/' ) 
   	exitUsage(argv[0]);
		
   option = argv[1][1];
	
   if (!(option == 'u' || option == 'd' || option == 't' || option =='h' )) {
      exitUsage(argv[0]);
   }

	if( !((option == 't' && argc == 3)||(option !='t' && argc==4)||( option =='h' ))) {
      exitUsage(argv[0]);
	}
   switch( option )
	{
		case 'd':
			translateToDos(argv[2], argv[3]);
			break;
		case 'u':	
			translateToUnix(argv[2], argv[3]);
			break;
		case 'm':	
/*			translateToMacintosh(argv[i+2]); */
			break;
		case 'h':
			exitUsage(argv[0]);
			break;
	   default:
			determineType(argv[2]); 
			break;
   }
   return 0;	
}
Ejemplo n.º 10
0
void splitCommand(char* cmd, int len){
	//splits the command and determines type
	char word[len];
	int counter = 0;
	int j, k;
	for(j = 0; j < len; ++j){
		char c = cmd[j];
		printf("c:\t%c\n", c);
		if (c == ' '){
			//determine word type
			determineType(word);
			//clear word
			for (k = 0; k < counter; k++)
				word[k] = 0;
			counter = 0;
		} else {
			//add char to word
			word[counter] = c;
			counter = counter + 1;
		}
		//determine word type: cmd, arg, pipe etc
		printf("word:\t%s\n", word);
	}
}
Ejemplo n.º 11
0
DumpWrapper<T>::DumpWrapper(ifstream& myFile): DumpBuffer(myFile)
{
  _dtype = determineType();  

}
Ejemplo n.º 12
0
DumpWrapper<T>::DumpWrapper(size_t sizeBytes, const char * name ): DumpBuffer(sizeBytes,name) 
{
  _dtype = determineType();  
}
	const SceneElement::Type& SceneElement::getType() const
	{
		if (mType == UNDETERMINED) mType = determineType();

		return mType;
	}
Ejemplo n.º 14
0
JsonTValue<T>::JsonTValue(const T& val) {
	determineType();
	_value = val;
}
Ejemplo n.º 15
0
JsonTValue<T>::JsonTValue() {
	determineType();
}
Ejemplo n.º 16
0
DumpWrapper<T>::DumpWrapper(DumpBuffer& other, WrapType type ): DumpBuffer(other, type)
{
  _dtype = determineType();   
}
Ejemplo n.º 17
0
void RDBParser::parseExpandedVariable(VarItem *parent, char *buf)
{
	DataType	dataType;
	int			pos;
	QString		varName;
	QCString	value;
	QRegExp 	ppref_re("(#<([^:]|::)+:0x[\\da-f]+)([^\\n>]*)(>?)");
    
	switch (parent->dataType()) {
    case REFERENCE_TYPE:
	{
		// Look for a reference type which has been printed via a 'pp' command, to
		// expand its sub items on multiple lines. For example:
		//     #<MyClass:0x30093540
		//		@foobar="hello",
		//		@sleeper=#<Thread:0x3008fd18 sleep>,
		//		@temp={"z"=>"zed", "p"=>"pee"}>
		//
		QRegExp ppvalue_re("\\s*([^\\n\\s=]+)=([^\\n]+)[,>]");

		pos = ppref_re.search(buf);
		if (pos != -1) {
			if (ppref_re.cap(4) != "") {
				// The value is all on one line, so match against name=value 
				// pairs which can't have commas in their values
				ppvalue_re = QRegExp("\\s*([^\\s=]+)=([^,>]+)([,>])");
			}

			pos = ppvalue_re.search(buf, pos);
					
			while (pos != -1) {
				varName = ppvalue_re.cap(1);
				
				if (ppref_re.search(ppvalue_re.cap(2)) != -1) {
					if (ppvalue_re.cap(2).contains("=") > 0) {
						value = (ppref_re.cap(1) + ">").latin1();
					} else {
						// There are no 'name=value' pairs, as in #<Qt::Color:0x0 #ff0000>
						value = ppvalue_re.cap(2).latin1();
					}
				} else {
					value = ppvalue_re.cap(2).latin1();
				}
				
				dataType = determineType((char *) ppvalue_re.cap(2).latin1());
				setItem(parent, varName, dataType, value);
				
				pos += ppvalue_re.matchedLength();
				pos = ppvalue_re.search(buf, pos);
			}
			
		}
		return;
	}
	
    case ARRAY_TYPE:
	{
		// Look for a array type which has been printed via a 'pp' command, to
		// expand its sub items. For example:
		//		[0]="hello"
		//		[1]=#"goodbye"
		//
		QRegExp pparray_re("\\s*([^=]+)=([^\\n]+)\\n");
		
		pos = pparray_re.search(buf);
			
		while (pos != -1) {
			varName = pparray_re.cap(1);
			
			if (ppref_re.search(pparray_re.cap(2)) != -1) {
				value = (ppref_re.cap(1) + ">").latin1();
			} else {
				value = pparray_re.cap(2).latin1();
			}
				
			DataType dataType = determineType((char *) pparray_re.cap(2).latin1());
			setItem(parent, varName, dataType, value);
				
			pos += pparray_re.matchedLength();
			pos = pparray_re.search(buf, pos);
		}
					
		return;
	}
	
    case HASH_TYPE:
	{
		// Look for a hash type which has been printed via a 'pp' command, to
		// expand its sub items. For example:
		//		["greeting"]="hello"
		//		["farewell"]="goodbye"
		//
		QRegExp pphash_re("\\s*(\\[[^\\]]+\\])=([^\\n]+)\\n");
		pos = pphash_re.search(buf);
		
		while (pos != -1) {
			varName = pphash_re.cap(1);
			value = pphash_re.cap(2).latin1();
	        DataType dataType = determineType(value.data());
			setItem(parent, varName, dataType, value);
			
			pos += pphash_re.matchedLength();
			pos = pphash_re.search(buf, pos);
		}
		
		return;
	}
	
    case STRUCT_TYPE:
	{
		// Look for a reference type which has been printed via a 'pp' command, to
		// expand its sub items. For example:
		//     #<Struct::Customer
		//		@foobar="hello",
		//		@sleeper=#<Thread:0x3008fd18 sleep>,
		//		@temp={"z"=>"zed", "p"=>"pee"}>
		//
		QRegExp ppstruct_re("(#<Struct::\\w+)\\s([^\\n>]*)(>?)");
		QRegExp ppvalue_re("\\s*([^\\n\\s=]+)=([^\\n]+)[,>]");
	
		pos = ppstruct_re.search(buf);
		if (pos != -1) {
			if (ppstruct_re.cap(3) != "" && ppvalue_re.search(ppstruct_re.cap(0)) != -1) {
				// The line ends with a '>', but we have this case now..
				// If there is only one instance variable, pp puts everything
				// on a single line:
				//     #<Struct::Customer @foobar="hello">
				// So search for '@foobar="hello"', to use as the
				// first name=value pair
				pos = 0;
			} else {
				// Mltiple lines with name=value pairs:
				//     #<Struct::Customer
				//		@foobar="hello",
				pos = ppvalue_re.search(buf, pos);
			}
					
			while (pos != -1) {
				varName = ppvalue_re.cap(1);
				value = ppvalue_re.cap(2).latin1();
				dataType = determineType(value.data());
				setItem(parent, varName, dataType, value);
				
				pos += ppvalue_re.matchedLength();
				pos = ppvalue_re.search(buf, pos);
			}
			
		}
		return;
	}
			
    case STRING_TYPE:
	{
		// Look for a long String which has been printed via a 'pp' command, to
		// show it as a sequence of 12 bytes slices in hex. For example:
		//		[0..11]=0x89504e470d0a1a0a0000000d
		//		[12..23]=0x494844520000001600000016
		//
		QRegExp ppstring_re("\\s*(\\[[^\\]]+\\])=([^\\n]+)\\n");
		pos = ppstring_re.search(buf);
		
		while (pos != -1) {
			varName = ppstring_re.cap(1);
			value = ppstring_re.cap(2).latin1();
	        DataType dataType = determineType(value.data());
			setItem(parent, varName, dataType, value);
			
			pos += ppstring_re.matchedLength();
			pos = ppstring_re.search(buf, pos);
		}
		
		return;
	}
		
	default:
		Q_ASSERT(false);
	}
	
	return;
}
Ejemplo n.º 18
0
// Takens in a token, then updates our linkedlist/pointer stuff accordingly
Value* addToken(char* current, int size, Value* head, Value** linkedListIterator) {
    char type = determineType(current, size);

    Value* tempValue = (Value*)malloc(sizeof(Value));
    assign(tempValue); //POINTER LIST
    ConsCell* tempCons = (ConsCell*)malloc(sizeof(ConsCell));
    assign(tempCons); //POINTER LIST
    Value* carValue = (Value*)malloc(sizeof(Value));
    assign(carValue); //POINTER LIST
    tempCons->car = carValue;

   switch (type)
    {
      case 'a':
        tempCons->car->uni.boolValue = (!strcmp(current, "#t") || !strcmp(current, "true")) ? 1 : 0;
        tempCons->car->type = 0;
        break;
      case 'b':
        tempCons->car->uni.intValue = atoi(current);
        tempCons->car->type = 1;
        break;
      case 'c':
        tempCons->car->uni.floatValue = atof(current);
        tempCons->car->type = 3;
        break;
      case 'd': case 'p':
        tempCons->car->uni.symbol = current;
        tempCons->car->type = 4;
        break;
      case 'e':
        tempCons->car->uni.stringValue = current;
        tempCons->car->type = 5;
        break;
      case 'f':
        tempCons->car->uni.open = *current;
        tempCons->car->type = 6;
        break;
      case 'g':
        tempCons->car->uni.close = *current;
        tempCons->car->type = 7;
        break;
      case 'q':
        tempCons->car->uni.quote = *current;
        tempCons->car->type = 2;
        break;
      case 'z': case 't': default:
        printf("SYNTAX ERROR\n");
        exit(0);
    }
    
    tempValue->type = 8;
    tempValue->uni.cons = tempCons;
     
    // If we're not at the first token, then set the cdr of the previous token to be this new value.
    if (*linkedListIterator != NULL) {
      (*linkedListIterator)->uni.cons->cdr = tempValue; 
    }

    // tempval is the token we're adding. if first node, set currentVal to be tempVal.
    *linkedListIterator = tempValue;

    // If we're at the first token, set the head.
    if (head == NULL) {
      head = tempValue;
    }

 // Then update the curValue (or, if we were at the first token, just set the curValue to the first token)
    return head;
}