本文整理汇总了C++中dyStringNew函数的典型用法代码示例。如果您正苦于以下问题:C++ dyStringNew函数的具体用法?C++ dyStringNew怎么用?C++ dyStringNew使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dyStringNew函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
/* Process command line. */
{
optionInit(&argc, argv, options);
if (argc != 5)
usage();
acceptString = optionVal("A", NULL);
if (acceptString)
{
acceptExtensionsCount = chopByChar(acceptString, ',', NULL, 0);
AllocArray(acceptExtensions, acceptExtensionsCount);
chopByChar(acceptString, ',', acceptExtensions, acceptExtensionsCount);
verbose(1, "accept-option count: %d\n", acceptExtensionsCount);
int i = 0;
for(i=0; i<acceptExtensionsCount; ++i)
{
verbose(2, "accept-option: %s\n", acceptExtensions[i]);
}
}
struct dyString *url = dyStringNew(4096);
struct dyString *outPath = dyStringNew(4096);
dyStringAppend(url, argv[3]);
dyStringAppend(outPath, argv[4]);
if (!paraSync(atoi(argv[1]), atoi(argv[2]), url, outPath, optionExists("newer"), optionExists("progress")))
exit(1);
return 0;
}
示例2: _pf_punt_init
void _pf_punt_init()
/* Initialize punt/catch system. Mostly just redirects the
* errAbort handler. */
{
punter.message = dyStringNew(0);
punter.source = dyStringNew(0);
pushWarnHandler(puntWarnHandler);
pushAbortHandler(puntAbortHandler);
}
示例3: genotypeAndStrainFromKey
void genotypeAndStrainFromKey(char *genotypeKey, struct sqlConnection *conn,
char **retGenotype, char **retStrain)
/* Return dynamically allocated string describing genotype */
{
int key = atoi(genotypeKey);
char *genotype = NULL, *strain = NULL;
if (key > 0)
{
struct dyString *query = dyStringNew(0);
struct dyString *geno = dyStringNew(256);
struct sqlResult *sr;
char **row;
/* Figure out genotype. Create string that looks something like:
* adh:cheap date,antp:+,
* That is a comma separated list gene:allele. */
sqlDyStringPrintf(query,
"select MRK_Marker.symbol,ALL_Allele.symbol "
"from GXD_AlleleGenotype,MRK_Marker,ALL_Allele "
"where GXD_AlleleGenotype._Genotype_key = %s "
"and GXD_AlleleGenotype._Marker_key = MRK_Marker._Marker_key "
"and GXD_AlleleGenotype._Allele_key = ALL_Allele._Allele_key "
, genotypeKey);
sr = sqlGetResultVerbose(conn, query->string);
while ((row = sqlNextRow(sr)) != NULL)
dyStringPrintf(geno, "%s:%s,", row[0], row[1]);
sqlFreeResult(&sr);
genotype = dyStringCannibalize(&geno);
/* Figure out strain */
dyStringClear(query);
sqlDyStringPrintf(query,
"select PRB_Strain.strain from GXD_Genotype,PRB_Strain "
"where GXD_Genotype._Genotype_key = %s "
"and GXD_Genotype._Strain_key = PRB_Strain._Strain_key"
, genotypeKey);
strain = sqlQuickStringVerbose(conn, query->string);
if (isUnknown(strain))
freez(&strain);
dyStringFree(&query);
}
if (genotype == NULL)
genotype = cloneString("");
if (strain == NULL)
strain = cloneString("");
*retGenotype = genotype;
*retStrain = strain;
}
示例4: dyStringNew
struct dyString *edwFormatDuration(long long seconds)
/* Convert seconds to days/hours/minutes. Return result in a dyString you can free */
{
struct dyString *dy = dyStringNew(0);
int days = seconds/(3600*24);
if (days > 0)
dyStringPrintf(dy, "%d days, ", days);
seconds -= days*3600*24;
int hours = seconds/3600;
if (hours > 0 || days > 0)
dyStringPrintf(dy, "%d hours", hours);
seconds -= hours*3600;
if (days == 0)
{
int minutes = seconds/60;
if (minutes > 0)
{
if (hours > 0)
dyStringPrintf(dy, ", ");
dyStringPrintf(dy, "%d minutes", minutes);
}
if (hours == 0)
{
if (minutes > 0)
dyStringPrintf(dy, ", ");
seconds -= minutes*60;
dyStringPrintf(dy, "%d seconds", (int)seconds);
}
}
return dy;
}
示例5: addImagesMatchingStage
void addImagesMatchingStage(struct visiSearcher *searcher,
struct sqlConnection *conn, int schemeId, int taxon,
char *minAge, int wordIx, int wordCount)
/* Given a developmental stage scheme (schemeId) and a specific
* stage, return all images that match stage */
{
struct dyString *dy = dyStringNew(0);
char *maxAge;
dyStringClear(dy);
dyStringPrintf(dy,
"select age from lifeStage where lifeStageScheme = %d ",
schemeId);
dyStringPrintf(dy,
"and age > %s order by age", minAge);
maxAge = sqlQuickString(conn, dy->string);
dyStringClear(dy);
dyStringPrintf(dy, "select image.id from specimen,image ");
dyStringPrintf(dy, "where specimen.age >= %s ", minAge);
if (maxAge != NULL)
dyStringPrintf(dy, "and specimen.age < %s ", maxAge);
dyStringPrintf(dy, "and specimen.taxon = %d ", taxon);
dyStringPrintf(dy, "and specimen.id = image.specimen");
addImagesMatchingQuery(searcher, conn, dy->string, NULL, NULL,
wordIx, wordCount);
dyStringFree(&dy);
}
示例6: dyStringNew
static char *findSourcePath(char *baseDir, struct slName *pathList,
char *fileName, char *suffix)
/* Given a pathList and a fileName, try and find file in path. */
{
struct slName *dir;
struct dyString *dy = dyStringNew(0);
char *path = NULL;
if (baseDir[0] == 0)
baseDir = ".";
dyStringPrintf(dy, "%s/%s%s", baseDir, fileName, suffix);
if (fileExists(dy->string))
path = cloneString(dy->string);
else
{
for (dir = pathList; dir != NULL; dir = dir->next)
{
dyStringClear(dy);
dyStringPrintf(dy, "%s/%s%s", dir->name, fileName, suffix);
if (fileExists(dy->string))
{
path = cloneString(dy->string);
break;
}
}
}
dyStringFree(&dy);
if (path == NULL)
errAbort("Couldn't find %s%s", fileName, suffix);
return path;
}
示例7: safeGetOne
boolean safeGetOne(char *source, char *dest)
/* Fetch file from source to tmp file. When fetch
* is done rename temp file to dest and return TRUE. */
{
struct dyString *command = dyStringNew(0);
boolean ok = TRUE;
int err;
dyStringClear(command);
dyStringPrintf(command, "wget -nv -O %s '%s'",
tmpName, source);
verbose(2, "%s\n", command->string);
if ((err = system(command->string)) != 0)
{
fprintf(fLog, "Error %d on %s\n", err, command->string);
warn("Error %d on %s", err, command->string);
++errCount;
if (errCount > maxErrs)
errAbort("Aborting after %d wget errors", errCount);
ok = FALSE;
}
verbose(2, "wget returned %d\n", err);
/* Rename file to proper name */
if (ok)
{
if ((err = rename(tmpName, dest)) < 0)
{
fprintf(fLog, "Couldn't rename %s to %s\n", tmpName, dest);
errnoAbort("Couldn't rename %s to %s", tmpName, dest);
}
}
dyStringFree(&command);
return ok;
}
示例8: lineFileOpen
struct hash *readDescriptionFile(char *fileName)
/* Return two column file keyed by first column with
* values in second column. Strip any tabs from values. */
{
struct lineFile *lf = lineFileOpen(fileName, TRUE);
char *line;
struct hash *hash = newHash(16);
while (lineFileNextReal(lf, &line))
{
char *key = nextWord(&line);
char *val = skipLeadingSpaces(line);
if (val != NULL && val[0] != 0)
{
char *desc = hashFindVal(hash, key);
subChar(val, '\t', ' ');
stripChar(val, '\r');
/* if gene exists in hash */
if (desc != NULL)
{
struct dyString *dy = dyStringNew(1024);
dyStringPrintf(dy, "%s ", desc);
dyStringAppend(dy, val);
val = cloneString(dy->string);
dyStringFree(&dy);
}
/* add to gene and description to hash */
hashAdd(hash, key, cloneString(val));
}
}
lineFileClose(&lf);
return hash;
}
示例9: dyStringNew
struct estOrientInfo *estOrientInfoLoadWhere(struct sqlConnection *conn, char *table, char *where)
/* Load all estOrientInfo from table that satisfy where clause. The
* where clause may be NULL in which case whole table is loaded
* Dispose of this with estOrientInfoFreeList(). */
{
struct estOrientInfo *list = NULL, *el;
struct dyString *query = dyStringNew(256);
struct sqlResult *sr;
char **row;
sqlDyStringPrintf(query, "select * from %s", table);
if (where != NULL)
dyStringPrintf(query, " where %s", where);
sr = sqlGetResult(conn, query->string);
int off = sqlFieldColumn(sr, "bin") + 1; // offset of data; function returns -1 if no bin
while ((row = sqlNextRow(sr)) != NULL)
{
el = estOrientInfoLoad(row+off);
slAddHead(&list, el);
}
slReverse(&list);
sqlFreeResult(&sr);
dyStringFree(&query);
return list;
}
示例10: tagStormCheck
void tagStormCheck(char *schemaFile, char *tagStormFile)
/* tagStormCheck - Check that a tagStorm conforms to a schema.. */
{
/* Load up schema from file. Make a hash of all non-wildcard
* tags, and a list of wildcard tags. */
struct tagSchema *schema, *schemaList = tagSchemaFromFile(schemaFile);
struct slRef *wildSchemaList = NULL, *requiredSchemaList = NULL;
/* Split up schemaList into hash and wildSchemaList. Calculate schemaSize */
struct hash *hash = hashNew(0);
int schemaSize = 0;
for (schema = schemaList; schema != NULL; schema = schema->next)
{
++schemaSize;
if (anyWild(schema->name))
{
refAdd(&wildSchemaList, schema);
}
else
hashAdd(hash, schema->name, schema);
if (schema->required != 0)
refAdd(&requiredSchemaList, schema);
}
slReverse(&wildSchemaList);
schemaList = NULL;
struct tagStorm *tagStorm = tagStormFromFile(tagStormFile);
struct dyString *scratch = dyStringNew(0);
rCheck(tagStorm->forest, tagStormFile, wildSchemaList, hash, requiredSchemaList, scratch);
if (gErrCount > 0)
noWarnAbort();
else
verbose(1, "No problems detected.\n");
}
示例11: extractAccsFromGb
void extractAccsFromGb(char *gbFile, boolean missingOk, char *accFile,
char **accNames, int accCount)
/* Parse records of genBank file and print ones that match accession names. */
{
FILE *out = stdout;
struct hash *accTbl = hashNew(0);
struct lineFile *lf;
struct dyString* headLines = dyStringNew(4096);
int i;
if (accFile != NULL)
loadAccs(accFile, accTbl);
for (i = 0; i < accCount; i++)
addAcc(accTbl, accNames[i]);
/* process file */
lf = lineFileOpen(gbFile, TRUE);
while (seekLocus(lf))
processEntry(lf, accTbl, headLines, out);
lineFileClose(&lf);
/* flush and check for errors */
carefulClose(&out);
if (!missingOk)
checkMissedAccs(accTbl);
}
示例12: dyStringNew
static struct slName *getListFromCgapSageLibs(struct sqlConnection *conn, char *column, boolean returnIds, boolean distinct)
/* Return [unique] list of tissues sorted alphabetically. */
{
struct slName *list = NULL;
struct dyString *dy = dyStringNew(0);
char **row;
struct sqlResult *sr;
sqlDyStringPrintf(dy, "select ");
if (distinct)
dyStringAppend(dy, "distinct ");
sqlDyStringPrintf(dy, "%s", column);
if (returnIds)
dyStringAppend(dy, ",libId");
sqlDyStringPrintf(dy, " from cgapSageLib order by %s", column);
sr = sqlGetResult(conn, dy->string);
while ((row = sqlNextRow(sr)) != NULL)
{
char *word = (returnIds) ? row[1] : row[0];
slNameAddHead(&list, word);
}
slReverse(&list);
sqlFreeResult(&sr);
dyStringFree(&dy);
return list;
}
示例13: dyStringNew
struct spFeature *spFeatures(struct sqlConnection *conn, char *acc,
int classId, /* Feature class ID, 0 for all */
int typeId) /* Feature type ID, 0 for all */
/* Get feature list. slFreeList this when done. */
{
struct dyString *dy = dyStringNew(0);
struct spFeature *list = NULL, *el;
char **row;
struct sqlResult *sr;
dyStringAppend(dy,
"select start,end,featureClass,featureType,softEndBits from feature ");
dyStringPrintf(dy,
"where acc = '%s'", acc);
if (classId != 0)
dyStringPrintf(dy, " and featureClass=%d", classId);
if (typeId != 0)
dyStringPrintf(dy, " and featureType=%d", typeId);
sr = sqlGetResult(conn, dy->string);
while ((row = sqlNextRow(sr)) != NULL)
{
AllocVar(el);
el->start = sqlUnsigned(row[0]);
el->end = sqlUnsigned(row[1]);
el->featureClass = sqlUnsigned(row[2]);
el->featureType = sqlUnsigned(row[3]);
el->softEndBits = sqlUnsigned(row[4]);
slAddHead(&list, el);
}
sqlFreeResult(&sr);
dyStringFree(&dy);
slReverse(&list);
return list;
}
示例14: gensatFixFull
void gensatFixFull(char *captionFile)
/* Fix missing captions. */
{
struct lineFile *lf = lineFileOpen(captionFile, TRUE);
char *row[2];
struct dyString *sql = dyStringNew(0);
struct sqlConnection *conn = sqlConnect(database);
struct hash *capHash = newHash(16);
while (lineFileRowTab(lf, row))
{
int captionId;
char *submitId = row[0];
char *caption = row[1];
captionId = hashIntValDefault(capHash, caption, 0);
if (captionId == 0)
{
dyStringClear(sql);
dyStringAppend(sql, "insert into caption values(default, \"");
dyStringAppend(sql, caption);
dyStringAppend(sql, "\")");
sqlUpdate(conn, sql->string);
verbose(1, "%s\n", sql->string);
captionId = sqlLastAutoId(conn);
hashAddInt(capHash, caption, captionId);
}
dyStringClear(sql);
dyStringPrintf(sql, "update imageFile set caption=%d ", captionId);
dyStringPrintf(sql, "where submissionSet=%d ", gensatId);
dyStringPrintf(sql, "and submitId = \"%s\"", submitId);
sqlUpdate(conn, sql->string);
verbose(1, "%s\n", sql->string);
}
dyStringFree(&sql);
}
示例15: hashNumEntries
char *identifierWhereClause(char *idField, struct hash *idHash)
/* If the number of pasted IDs is reasonably low, return a where-clause component for the IDs. */
{
if (idHash == NULL || idField == NULL)
return NULL;
int numIds = hashNumEntries(idHash);
int maxIdsInWhere = cartUsualInt(cart, "hgt_maxIdsInWhere", DEFAULT_MAX_IDS_IN_WHERE);
if (numIds > 0 && numIds <= maxIdsInWhere)
{
struct dyString *dy = dyStringNew(16 * numIds);
dyStringPrintf(dy, "%s in (", idField);
struct hashCookie hc = hashFirst(idHash);
boolean first = TRUE;
char *id;
while ((id = hashNextName(&hc)) != NULL)
{
if (first)
first = FALSE;
else
dyStringAppend(dy, ", ");
dyStringPrintf(dy, "'%s'", id);
}
dyStringAppend(dy, ")");
return dyStringCannibalize(&dy);
}
return NULL;
}