Exemplo n.º 1
0
// Iterate over names in index, fetch those
// that match the pattern.
void get_names_for_pattern(Index &index,
                           stdVector<stdString> &names,
                           const stdString &pattern)
{
    if (verbose)
        printf("Expanding pattern '%s'\n", pattern.c_str());
    try
    {
        AutoPtr<RegularExpression> regex;
        if (pattern.length() > 0)
            regex.assign(new RegularExpression(pattern.c_str()));
        Index::NameIterator name_iter;
        if (!index.getFirstChannel(name_iter))
            return; // No names
        // Put all names in binary tree
        BinaryTree<stdString> channels;
        do
        {
            if (regex && !regex->doesMatch(name_iter.getName()))
                continue; // skip what doesn't match regex
            channels.add(name_iter.getName());
        }
        while (index.getNextChannel(name_iter));
        // Sorted dump of names
        channels.traverse(add_name2vector, (void *)&names);
    }
    catch (GenericException &e)
    {
        throw GenericException(__FILE__, __LINE__,
                               "Error expanding name pattern '%s':\n%s\n",
                               pattern.c_str(), e.what());
    }
}
Exemplo n.º 2
0
int CSqEzdib::Save( const stdString &sFile )
{_STT();
	
	if ( !m_ezimg || !sFile.length() )
		return 0;
	
	return oss::ezd_save( m_ezimg, oexStrToMb( sqbind::std2oex( sFile ) ).c_str() );
}
Exemplo n.º 3
0
void CGIDemangler::unescape(stdString &text)
{
    size_t total = text.length() + 1;
    MemoryBuffer<char> buf(total);
    memcpy(buf.mem(), text.c_str(), total);
    unescape(buf.mem());
    text = buf.mem();
}
Exemplo n.º 4
0
size_t DataFile::getHeaderSize(const stdString &name,
                               DbrType dbr_type, DbrCount dbr_count,
                               size_t num_samples)
{
    size_t raw_value_size = RawValue::getSize(dbr_type, dbr_count);
    size_t buf_free = num_samples * raw_value_size;
    // 'INFO' + name + '\0' + header info + data buffer
    return 4 + name.length() + 1 +
        sizeof(DataHeader::DataHeaderData) + buf_free;
}
Exemplo n.º 5
0
void CtrlInfo::setNumeric(
    int32_t prec, const stdString &units,
    float disp_low, float disp_high,
    float low_alarm, float low_warn, float high_warn, float high_alarm)
{
    size_t len = units.length();
    size_t size = sizeof(CtrlInfoData) + len;
    _infobuf.reserve(size);
    CtrlInfoData *info = _infobuf.mem();

    info->type = Numeric;
    info->size = size;
    info->value.analog.disp_high  = disp_high;
    info->value.analog.disp_low   = disp_low;
    info->value.analog.low_warn   = low_warn;
    info->value.analog.low_alarm  = low_alarm;
    info->value.analog.high_warn  = high_warn;
    info->value.analog.high_alarm = high_alarm;
    info->value.analog.prec       = prec;
    string2cp (info->value.analog.units, units, len+1);
}
Exemplo n.º 6
0
stdString CSqSQLite::Escape( const stdString &sStr )
{_STT();
	oex::CStr sEsc( sStr.c_str(), sStr.length() );
	sEsc = CSQLite::Escape( sEsc );
	return stdString().assign( sEsc.Ptr(), (stdString::size_type)sEsc.Length() );
}
Exemplo n.º 7
0
// Create text file with spread-sheet formatted data.
void dump_spreadsheet(Index &index,
                      stdVector<stdString> names,
                      epicsTime *start, epicsTime *end,
                      bool raw_time,
                      bool status_text,
                      ReaderFactory::How how, double delta,
                      stdString output_name)
{
    SpreadsheetReader sheet(index, how, delta);
    bool ok = sheet.find(names, start);
    size_t i;
    stdString time, stat, val;
    const RawValue::Data *value;
    FILE *f = stdout;
    AutoFilePtr file;
    if (output_name.length() > 0)
    {
        file.open(output_name.c_str(), "wt");
        if (file)
            f = file;
        else
            throw GenericException(__FILE__, __LINE__,
                                   "Cannot open %s", output_name.c_str());
    }
    fprintf(f, "# Generated by ArchiveExport " ARCH_VERSION_TXT "\n");
    fprintf(f, "# Method: %s\n", ReaderFactory::toString(how, delta));
    fprintf(f, "\n");
    fprintf(f, "# Time                       ");
    if (raw_time)
        fprintf(f, "\tsecs");
    for (i=0; i<sheet.getNum(); ++i)
    {
        if (sheet.found(i))
            fprintf(f, "\t%s [%s]",
                    sheet.getName(i).c_str(),
                    sheet.getInfo(i).getUnits());
        else
            fprintf(f, "\t%s - NOT FOUND",
                    sheet.getName(i).c_str());
        if (status_text)
            fprintf(f, "\t");
    }
    fprintf(f, "\n");
    while (ok)
    {
        if (end && sheet.getTime() >= *end)
            break;
        // '03/23/2004 10:48:48.032899334'
        format_time(sheet.getTime(), time);
        fprintf(f, "%s", time.c_str());
        if (raw_time)
        {
            epicsTimeStamp stamp = sheet.getTime();
            fprintf(f, "\t%lu", (unsigned long)stamp.secPastEpoch);
        }
        for (i=0; i<sheet.getNum(); ++i)
        {
            value = sheet.get(i);
            if (value)
            {
                RawValue::getStatus(value, stat);
                if (RawValue::isInfo(value))
                {
                    fprintf(f, "\t#N/A");
                    if (status_text)
                        fprintf(f, "\t%s", stat.c_str());
                }
                else
                {
                    RawValue::getValueString(
                        val, sheet.getType(i), sheet.getCount(i),
                        value, &sheet.getInfo(i), format, precision);
                    fprintf(f, "\t%s", val.c_str());
                    if (status_text)
                        fprintf(f, "\t%s", stat.c_str());
                }
            }
            else
            {
                fprintf(f, "\t#N/A");
                if (status_text)
                    fprintf(f, "\t<no data>");
            }
        }
        fprintf(f, "\n");
        ok = sheet.next();
    }
}
Exemplo n.º 8
0
void HTMLPage::out(const stdString &line)
{    out(line.c_str(), line.length ());    }
Exemplo n.º 9
0
// Convert string "mm/dd/yyyy" or "mm/dd/yyyy 00:00:00" or
// "mm/dd/yyyy 00:00:00.000000000" into epicsTime
// Result: true for OK
bool string2epicsTime(const stdString &txt, epicsTime &time)
{
    size_t i, tlen = txt.length();
    // number check ("ab/cd/efgh" is caught here)
    for (i=0; i<tlen; ++i)
        if (!strchr("/0123456789 :.", txt[i]))
            return false;
    //  0123456789
    // "mm/dd/yyyy" ?
    if (tlen < 10  ||  txt[2] != '/' || txt[5] != '/')
    {   // Special case for testing
        epicsTimeStamp stamp;
        stamp.secPastEpoch = atoi(txt.c_str());
        stamp.nsec = 0;
        time = stamp;
        return stamp.secPastEpoch <= 1000;
    }
    struct local_tm_nano_sec tm;
    memset(&tm, 0, sizeof(struct local_tm_nano_sec));
    tm.ansi_tm.tm_isdst = -1; /* don't know if daylight saving or not */
    tm.ansi_tm.tm_mon  = (txt[0]-'0')*10 + (txt[1]-'0') - 1;
    tm.ansi_tm.tm_mday = (txt[3]-'0')*10 + (txt[4]-'0');
    tm.ansi_tm.tm_year = (txt[6]-'0')*1000 + (txt[7]-'0')*100 +
                         (txt[8]-'0')*10 + (txt[9]-'0') - 1900;

    //  0123456789012345
    // "mm/dd/yyyy ..." - check the space after the date.
    if (tlen > 10 && txt[10] != ' ')
        return false;
    //  0123456789012345
    // "mm/dd/yyyy 00:00" - check the ':' in the time.
    if (tlen >= 16)
    {
        if (txt[13] != ':')
            return false;
        tm.ansi_tm.tm_hour = (txt[11]-'0')*10 + (txt[12]-'0');
        tm.ansi_tm.tm_min  = (txt[14]-'0')*10 + (txt[15]-'0');
    }
    //  0123456789012345678
    // "mm/dd/yyyy 00:00:00" - are there seconds?
    if (tlen >= 19)
    {
        if (txt[16] != ':')
            return false;
        tm.ansi_tm.tm_sec  = (txt[17]-'0')*10 + (txt[18]-'0');
    }
    //  01234567890123456789012345678
    // "mm/dd/yyyy 00:00:00.000" - are there milli but not nano seconds?
    if (tlen == 23 && txt[19] == '.')
        tm.nSec =
            (txt[20]-'0')*100000000 +
            (txt[21]-'0')*10000000 +
            (txt[22]-'0')*1000000;
    //  01234567890123456789012345678
    // "mm/dd/yyyy 00:00:00.000000000" - are there nano seconds?
    if (tlen == 29 && txt[19] == '.')
        tm.nSec =
            (txt[20]-'0')*100000000 +
            (txt[21]-'0')*10000000 +
            (txt[22]-'0')*1000000 +
            (txt[23]-'0')*100000 +
            (txt[24]-'0')*10000 +
            (txt[25]-'0')*1000 +
            (txt[26]-'0')*100 +
            (txt[27]-'0')*10 +
            (txt[28]-'0');   
    
    time = tm;
    return true;
}