예제 #1
0
void CScmDateTime::setString(const char * pstr)
{
    char const * end;
    cdt.setString(pstr, &end, false);
    char sign = *end;
    if (toupper(sign) == 'Z')
    {
        utcToLocalDelta = 0;
        end++;
    }
    else if ((sign == '-') || (sign == '+'))
    {
        end++;
        int delta = readDigits(end, 2);
        if (*end++ != ':')
            throwError1(JLIBERR_BadlyFormedDateTime, pstr);
        delta = delta * 60 + readDigits(end, 2);
        if (sign == '-')
            delta = -delta;
        utcToLocalDelta = delta;
        cdt.adjustTime(-delta);
    }
    if (*end != 0)
        throwError1(JLIBERR_BadlyFormedDateTime, pstr);
}
예제 #2
0
 ForEachItemIn(i2, expandedOrder)
 {
     IHqlExpression * cur = &expandedOrder.item(i2);
     if (explicitStepped)
     {
         if (!extractCondition(stepArgs, cur))
         {
             StringBuffer s;
             if (cur->getOperator() == no_select)
                 s.append(cur->queryChild(1)->queryName());
             else
                 getExprECL(cur, s);
             throwError1(HQLERR_SteppingNotMatchSortCondition, s.str());
         }
         if (stepArgs.ordinality() == 0)
             break;
     }
     else
     {
         if (!extractCondition(args, cur))
             break;
         foundStepped = true;
     }
     if (compareLhs)
         break;
 }
예제 #3
0
static unsigned readDigits(char const * & str, unsigned numDigits)
{
    unsigned ret = 0;
    while(numDigits--)
    {
        char c = *str++;
        if(!isdigit(c))
            throwError1(JLIBERR_BadlyFormedDateTime, str);
        ret  = ret * 10 + (c - '0');
    }
    return ret;
}
예제 #4
0
void ResourceManager::addManifestFromArchive(IPropertyTree *archive)
{
    if (!archive)
        return;
    if (finalized)
        throwError1(HQLERR_ResourceAddAfterFinalManifest, "MANIFEST");
    ensureManifestInfo();
    Owned<IPropertyTreeIterator> manifests = archive->getElements("AdditionalFiles/Manifest");
    ForEach(*manifests)
    {
        const char *xml = manifests->query().queryProp(NULL);
        Owned<IPropertyTree> manifestSrc = createPTreeFromXMLString(xml);
        Owned<IAttributeIterator> aiter = manifestSrc->getAttributes();
        ForEach (*aiter)
            manifest->setProp(aiter->queryName(), aiter->queryValue());
        StringBuffer manifestDir;
        if (manifestSrc->hasProp("@originalFilename"))
            splitDirTail(manifestSrc->queryProp("@originalFilename"), manifestDir);

        Owned<IPropertyTreeIterator> iter = manifestSrc->getElements("*");
        ForEach(*iter)
        {
            IPropertyTree &item = iter->query();
            if (streq(item.queryName(), "Resource") && item.hasProp("@filename"))
            {
                if (!item.hasProp("@type"))
                    item.setProp("@type", "UNKNOWN");
                const char *filename;
                if (item.hasProp("@originalFilename"))
                    filename = item.queryProp("@originalFilename");
                else
                    filename = item.queryProp("@filename");
                int id;
                if (getDuplicateResourceId(item.queryProp("@type"), NULL, filename, id))
                {
                    item.setPropInt("@id", (int)id);
                    manifest->addPropTree("Resource", LINK(&item));
                }
                else
                {
                    VStringBuffer xpath("AdditionalFiles/Resource[@originalFilename=\"%s\"]", filename);
                    MemoryBuffer content;
                    archive->getPropBin(xpath.str(), content);
                    addCompress(item.queryProp("@type"), content.length(), content.toByteArray(), &item);
                }
            }
            else
                manifest->addPropTree(item.queryName(), LINK(&item));
        }
    }
}
예제 #5
0
void ResourceManager::addManifest(const char *filename)
{
    if (finalized)
        throwError1(HQLERR_ResourceAddAfterFinalManifest, "MANIFEST");
    Owned<IPropertyTree> manifestSrc = createPTreeFromXMLFile(filename);

    StringBuffer dir; 
    splitDirTail(filename, dir);

    ensureManifestInfo();
    Owned<IAttributeIterator> aiter = manifestSrc->getAttributes();
    ForEach (*aiter)
        manifest->setProp(aiter->queryName(), aiter->queryValue());
    Owned<IPropertyTreeIterator> iter = manifestSrc->getElements("*");
    ForEach(*iter)
    {
        IPropertyTree &item = iter->query();
        if (streq(item.queryName(), "Resource") && item.hasProp("@filename"))
        {
            if (!item.hasProp("@type"))
                item.setProp("@type", "UNKNOWN");
            const char *filename = item.queryProp("@filename");
            int id;
            if (getDuplicateResourceId(item.queryProp("@type"), filename, id))
            {
                item.setPropInt("@id", id);
                manifest->addPropTree("Resource", LINK(&item));
            }
            else
            {
                StringBuffer fullpath;
                if (!isAbsolutePath(filename))
                    fullpath.append(dir);
                fullpath.append(filename);

                MemoryBuffer content;
                loadResource(fullpath.str(), content);
                addCompress(item.queryProp("@type"), content.length(), content.toByteArray(), &item);
            }
        }
        else
            manifest->addPropTree(item.queryName(), LINK(&item));
    }
}
예제 #6
0
void ResourceManager::addNamed(const char * type, unsigned len, const void * data, IPropertyTree *manifestEntry, unsigned id, bool addToManifest, bool compressed)
{
    if (id==(unsigned)-1)
        id = nextmfid++;
    if (addToManifest)
    {
        if (finalized)
            throwError1(HQLERR_ResourceAddAfterFinalManifest, type);
        Owned<IPropertyTree> entry=createPTree("Resource");
        entry->setProp("@type", type);
        entry->setPropInt("@id", id);
        if (compressed)
            entry->setPropBool("@compressed", true);
        if (manifestEntry)
            mergePTree(entry, manifestEntry);
        ensureManifestInfo()->addPropTree("Resource", entry.getClear());
    }
    resources.append(*new ResourceItem(type, id, len, data));
}
예제 #7
0
AColumnInfo * CChildLinkedDatasetColumnInfo::lookupColumn(IHqlExpression * search)
{
    throwError1(HQLERR_LookupNotActiveDataset, search->queryName()->str());
    return NULL;
}
예제 #8
0
static void checkChar(char const * & str, char required)
{
    char c = *str++;
    if(c != required)
        throwError1(JLIBERR_BadlyFormedDateTime, str);
}
예제 #9
0
bool FileFormat::restore(IPropertyTree * props)
{
    StringBuffer formatText;
    props->getProp(FPformat, formatText);
    const char * format = formatText.str();

    if (stricmp(format, "blocked")==0)
        type = FFTblocked;
    else if (stricmp(format, "variable")==0)
        type = FFTvariable;
    else if (stricmp(format, "variablebigendian")==0)
        type = FFTvariablebigendian;
    else if (stricmp(format, "csv")==0)
    {
        type = FFTcsv;
        maxRecordSize = props->getPropInt(FPmaxRecordSize, DEFAULT_MAX_CSV_SIZE);
        separate.set(props->queryProp(FPcsvSeparate));
        quote.set(props->queryProp(FPcsvQuote));
        terminate.set(props->queryProp(FPcsvTerminate));
        if (maxRecordSize == 0)
            throwError(DFTERR_MaxRecordSizeZero);
    }
    else if (memicmp(format, "utf", 3) == 0)
    {
        type = FFTutf;
        const char * tail = format + 3;
        if (*tail == '-')
            tail++;
        if (stricmp(tail, "8")==0)
            type = FFTutf8;
        else if (stricmp(tail, "8N")==0)
            type = FFTutf8n;
        else if (stricmp(tail, "16")==0)
            type = FFTutf16;
        else if (stricmp(tail, "16BE")==0)
            type = FFTutf16be;
        else if (stricmp(tail, "16LE")==0)
            type = FFTutf16le;
        else if (stricmp(tail, "32")==0)
            type = FFTutf32;
        else if (stricmp(tail, "32BE")==0)
            type = FFTutf32be;
        else if (stricmp(tail, "32LE")==0)
            type = FFTutf32le;
        else if (*tail)
            throwError1(DFTERR_UnknownUTFFormat, format);
        maxRecordSize = props->getPropInt(FPmaxRecordSize, DEFAULT_MAX_CSV_SIZE);
        separate.set(props->queryProp(FPcsvSeparate));
        quote.set(props->queryProp(FPcsvQuote));
        terminate.set(props->queryProp(FPcsvTerminate));
        rowTag.set(props->queryProp(FProwTag));
        if (maxRecordSize == 0)
            throwError(DFTERR_MaxRecordSizeZero);
    }
    else if ((stricmp(format, "recfmvb")==0)||(stricmp(format, "recfm-vb")==0))
        type = FFTrecfmvb;
    else if ((stricmp(format, "recfmv")==0)||(stricmp(format, "recfm-v")==0))
        type = FFTrecfmv;
    else if (props->hasProp(FPrecordSize))
    {
        type = FFTfixed;
        recordSize = props->getPropInt(FPrecordSize);
    }
    else
        return false;
    return true;
}