Beispiel #1
0
IPRangeType IPRange::getType() {
    if (!gottype) {
        type = guessType();
        gottype = true;
    }
    return type;
}
bool AvolitesD4Parser::fillFixtureDef(QLCFixtureDef* fixtureDef)
{
    if (m_documentRoot.isNull())
    {
        m_lastError = "no XML loaded to process";
        return false;
    }

    fixtureDef->setManufacturer(fixtureCompany());
    fixtureDef->setModel(fixtureName());
    fixtureDef->setAuthor(copyright());

    // Parse all channels
    if (!parseChannels(m_documentRoot.namedItem(KD4TagFixture).toElement().namedItem(KD4TagControl).toElement(), fixtureDef))
        return false;

    // Parse all modes
    if (!parseModes(m_documentRoot.namedItem(KD4TagFixture).toElement(), fixtureDef))
        return false;

    fixtureDef->setType(guessType(fixtureDef));

    // TODO TODO TODO
    // Maybe also import preset palettes and macros ?!?!?!?!
    /**
        Can't be done for now, as qxf files don't have any information on preset palettes or macros
        for fixtures, they are automatically generated on the main application maybe in future... **/

    return true;
}
Beispiel #3
0
 inline void setValue(int idx, const QVariant& v)
 {
     Q_ASSERT(idx < _items.size());
     _items[idx].setValue(v);
     KData::ContentType t = guessType(v);
     _types |= t;
 }
Beispiel #4
0
 KDataPrivate(const Quantity * qty, const QVariant& v)
     : _quantity(qty), _types(KData::Undefined)
 {
     Q_ASSERT(_quantity != 0);
     if (v.isValid()) {
         KData::ContentType t = guessType(v);
         _types |= t;
         _items.append(KDataItem(qty->symbol, v, t));
     }
 }
bool FileRetriever::retrieve(Url* url, Config* config, Message* message, Resolver* resolver)
{
    guessType(url);

    int id = 0;
    url->m_statusText = "KO";
    resolver->getOrAdd(url->getUrlString(), &id);

    // create the parser associated with this type of content
    m_parser = Parser::getParserByContent(url, resolver, message, url->m_contentType);

    if (m_parser != 0) {
        if (url->m_contentType.substr(0, 6) == "image/") {
            std::ifstream fis(url->m_urlPath.c_str());
            if (fis != 0) {
                char* buffer;
                size_t size;
                fis.seekg (0, std::ios_base::end);
                size = fis.tellg();
                fis.seekg (0, std::ios_base::beg);
                buffer = new char [size];
                fis.read(buffer, size);
                fis.close();
                m_parser->processData(config, (const unsigned char*) buffer, size);
                delete [] buffer;
                url->m_statusText = "OK";
            }
        }
        else {
            std::ifstream fis(url->m_urlPath.c_str());
            if (fis != 0) {
                while (!fis.eof()) {
                    std::string test;
                    std::getline(fis, test);
                    m_parser->processData(config, (const unsigned char*) test.c_str(), test.length());
                }
                url->m_statusText = "OK";
            }
        }

        if (url->m_statusText != "OK") {
            message->addMessage("Could not open file " + url->m_urlPath, 1);
            url->m_statusText = "Not Found";
            return false;
        }
    }
    else {
        // so message of no handler gets printed
        url->m_statusText = "OK";
    }

    return true;
}
Beispiel #6
0
List<String> JobMessage::arguments() const
{
    if (!isPreprocessed())
        return mArgs;

    assert(mSourceFiles.size() == 1);

    List<String> ret = mArgs;

    const int source = mSourceFiles.front();
    const char* type = guessType(ret[source]);
    if (type) {
        ret.prepend(type);
        ret.prepend("-x");
    }

    ret[source] = "-";
    return ret;
}
Beispiel #7
0
static void returnValue(ParserControl *parm, parseUnion *stateUnion)
{
	parseUnion lvalp ={0};
	CMPIType  t;
	CMPIValue val;
	CMPIInstance *inst;
	ct = localLex((parseUnion*)&stateUnion->xtokReturnValue, parm);
	if(ct == XTOK_RETVALUE) {
		returnValueData(parm, (parseUnion*)&stateUnion->xtokReturnValue.data);
		if(stateUnion->xtokReturnValue.data.type == CMPI_ref) {
			t = CMPI_ref;
			val = str2CMPIValue(t, NULL, &stateUnion->xtokReturnValue.data.ref);
		}
		else if(stateUnion->xtokReturnValue.data.value.type == typeValue_Instance) {
			t = CMPI_instance;
			inst = native_new_CMPIInstance(NULL,NULL);
			setInstNsAndCn(inst,getNameSpaceChars(parm->requestObjectPath),stateUnion->xtokReturnValue.data.value.data.inst->className);
			setInstProperties(inst, &stateUnion->xtokReturnValue.data.value.data.inst->properties);
			val.inst = inst;
		}
		else {
			t = stateUnion->xtokReturnValue.type;
			if (t == CMPI_null) {
				t = guessType(stateUnion->xtokReturnValue.data.value.data.value);
			}
			val = str2CMPIValue(t, stateUnion->xtokReturnValue.data.value.data.value, NULL);
		}
		simpleArrayAdd(parm->respHdr.rvArray, (CMPIValue*)&val, t);
		ct = localLex((parseUnion*)&stateUnion->xtokReturnValue, parm);
		if(ct == ZTOK_RETVALUE) {
		}
		else {
			parseError("ZTOK_RETVALUE", ct, parm);
		}
	}
	else {
		parseError("XTOK_RETVALUE", ct, parm);
	}
}
Beispiel #8
0
///////////////////////////////////////////////////////////////////////////////////////////////////
//parse data schema from node
//src		data node
//dst		schema node
bool XmlSchema::parseNodeStruct(XmlNode* dst, XmlNode* src)
{
	assert(dst != NULL);
	assert(src != NULL);

	NodeIterator nodeIterator;
	AttributeIterator attriIterator;

	for (XmlAttribute* attribute = src->getFirstAttribute(attriIterator);
		attribute != NULL;
		attribute = src->getNextAttribute(attriIterator))
	{
		XmlNode* structure = dst->findChild(attribute->getName());
		if (structure == NULL)
		{
			//first time show up
			structure = dst->addChild(attribute->getName());
			structure->addAttribute(ATTR_TYPE, guessType(attribute->getString()));
			structure->addAttribute(ATTR_ATTRIBUTE, T("true"));
		}
	}

	for (XmlNode* child = src->getFirstChild(nodeIterator);
		  child != NULL;
		  child = src->getNextChild(nodeIterator))
	{
		if (child->getType() != ELEMENT)
		{
			continue;
		}
		XmlNode* structure = dst->findChild(child->getName());
		if (structure == NULL)
		{
			//first time show up
			bool recursive = false;
			const XmlNode* parent = dst;
			while (parent != NULL)
			{
				if (Strcmp(parent->getName(), child->getName()) == 0)
				{
					recursive = true;
					break;
				}
				parent = parent->getParent();
			}
			structure = dst->addChild(child->getName());
			if (recursive)
			{
				structure->addAttribute(ATTR_RECURSIVE, T("true"));
			}
			else if (!child->hasChild() && !child->hasAttribute())
			{
				//simple type, must have a type attribute
				structure->addAttribute(ATTR_TYPE, guessType(child->getString()));
			}
		}
		else if (structure->findAttribute(ATTR_ATTRIBUTE) != NULL)
		{
			//child and attribute can't have same name
			return false;
		}

		XmlAttribute* multiple = structure->findAttribute(ATTR_MULTIPLE);
		if (multiple == NULL || !multiple->getBool())
		{
			NodeIterator iter;
			if (src->findFirstChild(child->getName(), iter) != NULL
				&& src->findNextChild(child->getName(), iter) != NULL)
			{
				if (multiple == NULL)
				{
					multiple = structure->addAttribute(ATTR_MULTIPLE);
				}
				multiple->setBool(true);
			}
		}

		if (!structure->findAttribute(ATTR_RECURSIVE) && (child->hasChild() || child->hasAttribute()))
		{
			parseNodeStruct(structure, child);
		}
	}

	return true;
}
Beispiel #9
0
CMPIValue
str2CMPIValue(CMPIType type, XtokValue val, XtokValueReference * ref,
              char *ns, CMPIStatus *status)
{
  CMPIValue       value;
  CMPIType        t = 0;
  CMPIStatus rc = {CMPI_RC_OK, NULL};

  if (type == 0) {
    type = guessType(val.value);
  }

  if (type & CMPI_ARRAY) {
    /*
     * array type received -- needs special handling 
     */
    int             i,
                    max;
    CMPIValue       v;
    XtokValueArray *arr = (XtokValueArray *) ref;
    XtokValueRefArray *refarr = (XtokValueRefArray *) arr;
    max = arr->next;
    if ((type & CMPI_ref) == CMPI_ref) {
      t = CMPI_ref;
    } else if (type & ~CMPI_ARRAY) {
      t = type & ~CMPI_ARRAY;
    } else {
      /*
       * the guess type can go wrong 
       */
      if (max > 0) {
        t = guessType(arr->values[0].value);
      }
    }
    /*
     * build an array by looping thru the elements 
     */
    value.array = TrackedCMPIArray(max, t, NULL);
    if (value.array != NULL) {
      for (i = 0; i < max; i++) {
        v = str2CMPIValue(t, arr->values[i], refarr->values + i, ns, &rc);
        CMSetArrayElementAt(value.array, i, &v, t);
      }
      return value;
    }
  }

  /* Feature 75543 - set and return status->rc on failures */
  switch (type) {
  case CMPI_char16:
    value.char16 = *val.value;
    break;
  case CMPI_string:
    value.string = sfcb_native_new_CMPIString(val.value, NULL, 0);
    break;
  case CMPI_sint64:
    if (invalid_int(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%lld", &value.sint64);
    break;
  case CMPI_uint64:
    if (invalid_uint(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%llu", &value.uint64);
    break;
  case CMPI_sint32:
    if (invalid_int(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%d", &value.sint32);
    break;
  case CMPI_uint32:
    if (invalid_uint(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%u", &value.uint32);
    break;
  case CMPI_sint16:
    if (invalid_int(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%hd", &value.sint16);
    break;
  case CMPI_uint16:
    if (invalid_uint(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%hu", &value.uint16);
    break;
  case CMPI_uint8:
    if (invalid_uint(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else {
       sscanf(val.value, "%u", &value.uint32);
       value.uint8 = value.uint32;
    }
    break;
  case CMPI_sint8:
    if (invalid_int(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else {
       sscanf(val.value, "%d", &value.sint32);
       value.sint8 = value.sint32;
    }
    break;
  case CMPI_boolean:
    if (invalid_boolean(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else {
       value.boolean = strcasecmp(val.value, "false");
       if (value.boolean)
         value.boolean = 1;
    }
    break;
  case CMPI_real32:
    if (invalid_real(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%f", &value.real32);
    break;
  case CMPI_real64:
    if (invalid_real(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%lf", &value.real64);
    break;
  case CMPI_dateTime:
    value.dateTime =
        sfcb_native_new_CMPIDateTime_fromChars(val.value, NULL);
    break;
  case CMPI_ref:
    getKeyValueTypePtr("ref", NULL, ref, &value, &t, ns);
    break;
  case CMPI_instance:
    value = makeFromEmbeddedObject(val, ns);
    break;
  default:
    mlogf(M_ERROR, M_SHOW, "%s(%d): invalid value %d-%p\n", __FILE__,
          __LINE__, (int) type, val);
    abort();
  }
  return value;
}
Beispiel #10
0
bool JobMessage::canPreprocess() const
{
    return (mSourceFiles.size() == 1 && guessType(mArgs[mSourceFiles.front()]));
}