本文整理汇总了C++中AttrListPrintMask类的典型用法代码示例。如果您正苦于以下问题:C++ AttrListPrintMask类的具体用法?C++ AttrListPrintMask怎么用?C++ AttrListPrintMask使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AttrListPrintMask类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_status_print_mask_from_stream
int set_status_print_mask_from_stream (
const char * streamid,
bool is_filename,
const char ** pconstraint)
{
std::string where_expr;
std::string messages;
StringList attrs;
printmask_aggregation_t aggregation;
SimpleInputStream * pstream = NULL;
*pconstraint = NULL;
FILE *file = NULL;
if (MATCH == strcmp("-", streamid)) {
pstream = new SimpleFileInputStream(stdin, false);
} else if (is_filename) {
file = safe_fopen_wrapper_follow(streamid, "r");
if (file == NULL) {
fprintf(stderr, "Can't open select file: %s\n", streamid);
return -1;
}
pstream = new SimpleFileInputStream(file, true);
} else {
pstream = new StringLiteralInputStream(streamid);
}
ASSERT(pstream);
int err = SetAttrListPrintMaskFromStream(
*pstream,
*getCondorStatusPrintFormats(),
pm,
pmHeadFoot,
aggregation,
group_by_keys,
where_expr,
attrs,
messages);
delete pstream; pstream = NULL;
if ( ! err) {
if (aggregation != PR_NO_AGGREGATION) {
fprintf(stderr, "print-format aggregation not supported\n");
return -1;
}
if ( ! where_expr.empty()) {
*pconstraint = pm.store(where_expr.c_str());
//if ( ! validate_constraint(*pconstraint)) {
// formatstr_cat(messages, "WHERE expression is not valid: %s\n", *pconstraint);
//}
}
// convert projection list into the format that condor status likes. because programmers.
attrs.rewind();
const char * attr;
while ((attr = attrs.next())) { projList.AppendArg(attr); }
}
if ( ! messages.empty()) { fprintf(stderr, "%s", messages.c_str()); }
return err;
}
示例2: printQuillNormal
void
printQuillNormal (ClassAd *ad) {
static bool first = true;
static AttrListPrintMask alpm;
if (ad)
{
// print header if necessary
if (first)
{
printf ("\n%-20.20s %-10.10s %-16.16s %-18.18s\n\n",
ATTR_NAME, ATTR_MACHINE, ATTR_QUILL_SQL_TOTAL,
ATTR_QUILL_SQL_LAST_BATCH);
alpm.registerFormat("%-20.20s ", ATTR_NAME,
"[??????????????????] ");
alpm.registerFormat("%-10.10s ", ATTR_MACHINE,
"[????????] ");
alpm.registerFormat("%16d ",ATTR_QUILL_SQL_TOTAL,
"[??????????????] ");
alpm.registerFormat("%18d\n",ATTR_QUILL_SQL_LAST_BATCH,
"[???????????]\n");
first = false;
}
alpm.display (stdout, ad);
}
}
示例3: SetAttrListPrintMaskFromStream
// Read a stream a line at a time, and parse it to fill out the print mask,
// header, group_by, where expression, and projection attributes.
//
int SetAttrListPrintMaskFromStream (
SimpleInputStream & stream, // in: fetch lines from this stream until nextline() returns NULL
const CustomFormatFnTable & FnTable, // in: table of custom output functions for SELECT
AttrListPrintMask & mask, // out: columns and headers set in SELECT
printmask_headerfooter_t & headfoot, // out: header and footer flags set in SELECT or SUMMARY
printmask_aggregation_t & aggregate, // out: aggregation mode in SELECT
std::vector<GroupByKeyInfo> & group_by, // out: ordered set of attributes/expressions in GROUP BY
std::string & where_expression, // out: classad expression from WHERE
StringList & attrs, // out ClassAd attributes referenced in mask or group_by outputs
std::string & error_message) // out, if return is non-zero, this will be an error message
{
ClassAd ad; // so we can GetExprReferences
enum section_t { NOWHERE=0, SELECT, SUMMARY, WHERE, GROUP};
enum cust_t { PRINTAS_STRING, PRINTAS_INT, PRINTAS_FLOAT };
bool label_fields = false;
const char * labelsep = " = ";
const char * prowpre = NULL;
const char * pcolpre = " ";
const char * pcolsux = NULL;
const char * prowsux = "\n";
mask.SetAutoSep(prowpre, pcolpre, pcolsux, prowsux);
error_message.clear();
aggregate = PR_NO_AGGREGATION;
printmask_headerfooter_t usingHeadFoot = (printmask_headerfooter_t)(HF_CUSTOM | HF_NOSUMMARY);
section_t sect = SELECT;
tokener toke("");
while (toke.set(stream.nextline())) {
if ( ! toke.next())
continue;
if (toke.matches("#")) continue;
if (toke.matches("SELECT")) {
while (toke.next()) {
if (toke.matches("FROM")) {
if (toke.next()) {
if (toke.matches("AUTOCLUSTER")) {
aggregate = PR_FROM_AUTOCLUSTER;
} else {
std::string aa; toke.copy_token(aa);
formatstr_cat(error_message, "Warning: Unknown header argument %s for SELECT FROM\n", aa.c_str());
}
}
} else if (toke.matches("UNIQUE")) {
aggregate = PR_COUNT_UNIQUE;
} else if (toke.matches("BARE")) {
usingHeadFoot = HF_BARE;
} else if (toke.matches("NOTITLE")) {
usingHeadFoot = (printmask_headerfooter_t)(usingHeadFoot | HF_NOTITLE);
} else if (toke.matches("NOHEADER")) {
usingHeadFoot = (printmask_headerfooter_t)(usingHeadFoot | HF_NOHEADER);
} else if (toke.matches("NOSUMMARY")) {
usingHeadFoot = (printmask_headerfooter_t)(usingHeadFoot | HF_NOSUMMARY);
} else if (toke.matches("LABEL")) {
label_fields = true;
} else if (label_fields && toke.matches("SEPARATOR")) {
if (toke.next()) { std::string tmp; toke.copy_token(tmp); collapse_escapes(tmp); labelsep = mask.store(tmp.c_str()); }
} else if (toke.matches("RECORDPREFIX")) {
if (toke.next()) { std::string tmp; toke.copy_token(tmp); collapse_escapes(tmp); prowpre = mask.store(tmp.c_str()); }
} else if (toke.matches("RECORDSUFFIX")) {
if (toke.next()) { std::string tmp; toke.copy_token(tmp); collapse_escapes(tmp); prowsux = mask.store(tmp.c_str()); }
} else if (toke.matches("FIELDPREFIX")) {
if (toke.next()) { std::string tmp; toke.copy_token(tmp); collapse_escapes(tmp); pcolpre = mask.store(tmp.c_str()); }
} else if (toke.matches("FIELDSUFFIX")) {
if (toke.next()) { std::string tmp; toke.copy_token(tmp); collapse_escapes(tmp); pcolsux = mask.store(tmp.c_str()); }
} else {
std::string aa; toke.copy_token(aa);
formatstr_cat(error_message, "Warning: Unknown header argument %s for SELECT\n", aa.c_str());
}
}
mask.SetAutoSep(prowpre, pcolpre, pcolsux, prowsux);
sect = SELECT;
continue;
} else if (toke.matches("WHERE")) {
sect = WHERE;
if ( ! toke.next()) continue;
} else if (toke.matches("GROUP")) {
sect = GROUP;
if ( ! toke.next() || (toke.matches("BY") && ! toke.next())) continue;
} else if (toke.matches("SUMMARY")) {
usingHeadFoot = (printmask_headerfooter_t)(usingHeadFoot & ~HF_NOSUMMARY);
while (toke.next()) {
if (toke.matches("STANDARD")) {
// attrs.insert(ATTR_JOB_STATUS);
} else if (toke.matches("NONE")) {
usingHeadFoot = (printmask_headerfooter_t)(usingHeadFoot | HF_NOSUMMARY);
} else {
std::string aa; toke.copy_token(aa);
formatstr_cat(error_message, "Unknown argument %s for SELECT\n", aa.c_str());
}
}
sect = SUMMARY;
continue;
}
//.........这里部分代码省略.........
示例4: AddPrintColumn
static void AddPrintColumn(const char * heading, int width, int opts, const char * expr)
{
mask.set_heading(heading);
int wid = width ? width : strlen(heading);
mask.registerFormat("%v", wid, opts, expr);
}
示例5: ppDisplayHeadings
static void ppDisplayHeadings(FILE* file, ClassAd *ad, const char * pszExtra)
{
if (ad) {
// render the first ad to a string so the column widths update
std::string tmp;
pm.display(tmp, ad, NULL);
}
if (pm.has_headings()) {
pm.display_Headings(file);
} else {
pm.display_Headings(file, pm_head);
}
if (pszExtra)
printf("%s", pszExtra);
}
示例6: Lbl
void
printRun (ClassAd *ad, bool first)
{
if (first) {
ppInit();
ppSetColumn(ATTR_NAME, wide_display ? -34 : -15, ! wide_display);
if (javaMode) {
ppSetColumn(ATTR_JAVA_VENDOR, -11, ! wide_display);
ppSetColumn(ATTR_JAVA_VERSION, Lbl("Ver"), -6, ! wide_display);
} else if (vmMode) {
ppSetColumn(ATTR_VM_TYPE, Lbl("VMType"), -6, ! wide_display);
ppSetColumn(ATTR_VM_NETWORKING_TYPES, Lbl("Network"), -11, ! wide_display);
} else {
ppSetColumn(ATTR_OPSYS, -11, true);
ppSetColumn(ATTR_ARCH, -6, true);
}
ppSetColumn(ATTR_LOAD_AVG, Lbl("LoadAv"), formatLoadAvg, NULL, 6, true);
ppSetColumn(ATTR_REMOTE_USER, -20, ! wide_display);
ppSetColumn(ATTR_CLIENT_MACHINE, -16, ! wide_display);
ppDisplayHeadings(stdout, ad, "\n");
}
if (ad)
pm.display (stdout, ad);
}
示例7: ppSetColumnFormat
static void ppSetColumnFormat(const CustomFormatFn & fmt, const char * print, int width, bool truncate, ivfield alt, const char * attr)
{
int opts = ppWidthOpts(width, truncate) | ppAltOpts(alt);
if (width == 11 && fmt.IsNumber() && (fmt.Is(formatElapsedTime) || fmt.Is(formatRealTime))) {
opts |= FormatOptionNoPrefix;
width = 12;
}
pm.registerFormat(print, width, opts, fmt, attr);
}
示例8:
void
printMasterNormal(ClassAd *ad, bool first)
{
if (first) {
ppInit();
ppSetColumn(ATTR_NAME, -20, false);
ppDisplayHeadings(stdout, ad, "\n");
}
if (ad)
pm.display (stdout, ad);
}
示例9: printHeader
static void printHeader()
{
// Print header
if ( ! longformat) {
if ( ! customFormat) {
// hack to get backward-compatible formatting
if ( ! wide_format && 80 == wide_format_width)
short_header();
else {
init_default_custom_format();
if ( ! wide_format || 0 != wide_format_width) {
int console_width = wide_format_width;
if (console_width <= 0) console_width = getConsoleWindowSize()-1; // -1 because we get double spacing if we use the full width.
if (console_width < 0) console_width = 1024;
mask.SetOverallWidth(console_width);
}
}
}
if (customFormat && mask.has_headings()) {
mask.display_Headings(stdout);
}
}
}
示例10: init_default_custom_format
// setup display mask for default output
static void init_default_custom_format()
{
mask.SetAutoSep(NULL, " ", NULL, "\n");
int opts = wide_format ? (FormatOptionNoTruncate | FormatOptionAutoWidth) : 0;
AddPrintColumn(" ID", -7, FormatOptionNoTruncate, ATTR_CLUSTER_ID, format_job_id);
AddPrintColumn("OWNER", -14, FormatOptionAutoWidth | opts, ATTR_OWNER);
AddPrintColumn("SUBMITTED", 11, 0, ATTR_Q_DATE, format_int_date);
AddPrintColumn("RUN_TIME", 12, 0, ATTR_CLUSTER_ID, format_hist_runtime);
AddPrintColumn("ST", -2, 0, ATTR_JOB_STATUS, format_int_job_status);
AddPrintColumn("COMPLETED", 11, 0, ATTR_COMPLETION_DATE, format_int_date);
AddPrintColumn("CMD", -15, FormatOptionLeftAlign | FormatOptionNoTruncate, ATTR_JOB_CMD, format_job_cmd_and_args);
customFormat = TRUE;
}
示例11: printJob
// print a single job ad
//
static void printJob(ClassAd & ad)
{
if (longformat) {
if (use_xml) {
fPrintAdAsXML(stdout, ad);
} else {
fPrintAd(stdout, ad);
}
printf("\n");
} else {
if (customFormat) {
mask.display(stdout, &ad);
} else {
displayJobShort(&ad);
}
}
}
示例12: readHistoryFromFile
// Read the history from a single file and print it out.
static void readHistoryFromFile(char *JobHistoryFileName, char* constraint, ExprTree *constraintExpr)
{
int EndFlag = 0;
int ErrorFlag = 0;
int EmptyFlag = 0;
AttrList *ad = NULL;
long offset = 0;
bool BOF = false; // Beginning Of File
MyString buf;
FILE* LogFile=safe_fopen_wrapper(JobHistoryFileName,"r");
if (!LogFile) {
fprintf(stderr,"History file (%s) not found or empty.\n", JobHistoryFileName);
exit(1);
}
// In case of rotated history files, check if we have already reached the number of
// matches specified by the user before reading the next file
if (specifiedMatch != 0) {
if (matchCount == specifiedMatch) { // Already found n number of matches, cleanup
fclose(LogFile);
return;
}
}
if (backwards) {
offset = findLastDelimiter(LogFile, JobHistoryFileName);
}
while(!EndFlag) {
if (backwards) { // Read history file backwards
if (BOF) { // If reached beginning of file
break;
}
offset = findPrevDelimiter(LogFile, JobHistoryFileName, offset);
if (offset == -1) { // Unable to match constraint
break;
} else if (offset != 0) {
fseek(LogFile, offset, SEEK_SET);
buf.readLine(LogFile); // Read one line to skip delimiter and adjust to actual offset of ad
} else { // Offset set to 0
BOF = true;
fseek(LogFile, offset, SEEK_SET);
}
}
if( !( ad=new AttrList(LogFile,"***", EndFlag, ErrorFlag, EmptyFlag) ) ){
fprintf( stderr, "Error: Out of memory\n" );
exit( 1 );
}
if( ErrorFlag ) {
printf( "\t*** Warning: Bad history file; skipping malformed ad(s)\n" );
ErrorFlag=0;
if(ad) {
delete ad;
ad = NULL;
}
continue;
}
if( EmptyFlag ) {
EmptyFlag=0;
if(ad) {
delete ad;
ad = NULL;
}
continue;
}
if (!constraint || EvalBool(ad, constraintExpr)) {
if (longformat) {
ad->fPrint(stdout); printf("\n");
} else {
if (customFormat) {
mask.display(stdout, ad);
} else {
displayJobShort(ad);
}
}
matchCount++; // if control reached here, match has occured
if (specifiedMatch != 0) { // User specified a match number
if (matchCount == specifiedMatch) { // Found n number of matches, cleanup
if (ad) {
delete ad;
ad = NULL;
}
fclose(LogFile);
return;
}
}
}
if(ad) {
delete ad;
//.........这里部分代码省略.........
示例13: if
void
prettyPrint (ClassAdList &adList, TrackTotals *totals)
{
ppOption pps = using_print_format ? PP_CUSTOM : ppStyle;
ClassAd *ad;
int classad_index;
int last_classad_index;
bool fPrintHeadings = pm.has_headings() || (pm_head.Length() > 0);
classad_index = 0;
last_classad_index = adList.Length() - 1;
adList.Open();
while ((ad = adList.Next())) {
if (!wantOnlyTotals) {
switch (pps) {
case PP_STARTD_NORMAL:
if (absentMode) {
printStartdAbsent (ad, (classad_index == 0));
} else if( offlineMode ) {
printStartdOffline( ad, (classad_index == 0));
} else {
printStartdNormal (ad, (classad_index == 0));
}
break;
case PP_STARTD_SERVER:
printServer (ad, (classad_index == 0));
break;
case PP_STARTD_RUN:
printRun (ad, (classad_index == 0));
break;
case PP_STARTD_COD:
printCOD (ad);
break;
case PP_STARTD_STATE:
printState(ad, (classad_index == 0));
break;
#ifdef HAVE_EXT_POSTGRESQL
case PP_QUILL_NORMAL:
printQuillNormal (ad);
break;
#endif /* HAVE_EXT_POSTGRESQL */
case PP_SCHEDD_NORMAL:
printScheddNormal (ad, (classad_index == 0));
break;
case PP_NEGOTIATOR_NORMAL:
printNegotiatorNormal (ad, (classad_index == 0));
break;
case PP_SCHEDD_SUBMITTORS:
printScheddSubmittors (ad, (classad_index == 0));
break;
case PP_VERBOSE:
printVerbose (ad);
break;
case PP_XML:
printXML (ad, (classad_index == 0),
(classad_index == last_classad_index));
break;
case PP_MASTER_NORMAL:
printMasterNormal(ad, (classad_index == 0));
break;
case PP_COLLECTOR_NORMAL:
printCollectorNormal(ad, (classad_index == 0));
break;
case PP_CKPT_SRVR_NORMAL:
printCkptSrvrNormal(ad, (classad_index == 0));
break;
case PP_STORAGE_NORMAL:
printStorageNormal(ad, (classad_index == 0));
break;
case PP_GRID_NORMAL:
printGridNormal(ad, (classad_index == 0));
break;
case PP_GENERIC_NORMAL:
case PP_GENERIC:
case PP_ANY_NORMAL:
printAnyNormal(ad, (classad_index == 0));
break;
case PP_CUSTOM:
// hack: print a single item to a string, then discard the string
// this makes sure that the headings line up correctly over the first
// line of data.
if (fPrintHeadings) {
//.........这里部分代码省略.........
示例14: if
int
main(int argc, char* argv[])
{
Collectors = NULL;
#ifdef HAVE_EXT_POSTGRESQL
HistorySnapshot *historySnapshot;
SQLQuery queryhor;
SQLQuery queryver;
QuillErrCode st;
bool remotequill=false;
char *quillName=NULL;
AttrList *ad=0;
int flag = 1;
void **parameters;
char *dbconn=NULL;
char *completedsince = NULL;
char *dbIpAddr=NULL, *dbName=NULL,*queryPassword=NULL;
bool remoteread = false;
#endif /* HAVE_EXT_POSTGRESQL */
const char *owner=NULL;
bool readfromfile = true;
bool fileisuserlog = false;
char* JobHistoryFileName=NULL;
const char * pcolon=NULL;
GenericQuery constraint; // used to build a complex constraint.
ExprTree *constraintExpr=NULL;
std::string tmp;
int i;
myDistro->Init( argc, argv );
config();
#ifdef HAVE_EXT_POSTGRESQL
parameters = (void **) malloc(NUM_PARAMETERS * sizeof(void *));
queryhor.setQuery(HISTORY_ALL_HOR, NULL);
queryver.setQuery(HISTORY_ALL_VER, NULL);
#endif /* HAVE_EXT_POSTGRESQL */
for(i=1; i<argc; i++) {
if (is_dash_arg_prefix(argv[i],"long",1)) {
longformat=TRUE;
}
else if (is_dash_arg_prefix(argv[i],"xml",3)) {
use_xml = true;
longformat = true;
}
else if (is_dash_arg_prefix(argv[i],"backwards",1)) {
backwards=TRUE;
}
// must be at least -forw to avoid conflict with -f (for file) and -format
else if (is_dash_arg_prefix(argv[i],"nobackwards",3) ||
is_dash_arg_prefix(argv[i],"forwards",4)) {
backwards=FALSE;
}
else if (is_dash_arg_colon_prefix(argv[i],"wide", &pcolon, 1)) {
wide_format=TRUE;
if (pcolon) {
wide_format_width = atoi(++pcolon);
if ( ! mask.IsEmpty()) mask.SetOverallWidth(getDisplayWidth()-1);
if (wide_format_width <= 80) wide_format = FALSE;
}
}
else if (is_dash_arg_prefix(argv[i],"match",1) || is_dash_arg_prefix(argv[i],"limit",3)) {
i++;
if (argc <= i) {
fprintf(stderr,
"Error: Argument -match requires a number value "
" as a parameter.\n");
exit(1);
}
specifiedMatch = atoi(argv[i]);
}
#ifdef HAVE_EXT_POSTGRESQL
else if(is_dash_arg_prefix(argv[i], "dbname",1)) {
i++;
if (argc <= i) {
fprintf( stderr,
"Error: Argument -dbname requires the name of a quilld as a parameter\n" );
exit(1);
}
/*
if( !(quillName = get_daemon_name(argv[i])) ) {
fprintf( stderr, "Error: unknown host %s\n",
get_host_part(argv[i]) );
printf("\n");
//.........这里部分代码省略.........
示例15: readHistoryFromFileOld
// Read the history from a single file and print it out.
static void readHistoryFromFileOld(const char *JobHistoryFileName, const char* constraint, ExprTree *constraintExpr)
{
int EndFlag = 0;
int ErrorFlag = 0;
int EmptyFlag = 0;
ClassAd *ad = NULL;
long offset = 0;
bool BOF = false; // Beginning Of File
MyString buf;
int flags = 0;
if( !backwards ) {
// Currently, the file position manipulations used in -backwards
// do not work with files > 2GB on platforms with 32-bit file
// offsets.
flags = O_LARGEFILE;
}
int LogFd = safe_open_wrapper_follow(JobHistoryFileName,flags,0);
if (LogFd < 0) {
fprintf(stderr,"Error opening history file %s: %s\n", JobHistoryFileName,strerror(errno));
#ifdef EFBIG
if( (errno == EFBIG) && backwards ) {
fprintf(stderr,"The -backwards option does not support files this large.\n");
}
#endif
exit(1);
}
FILE *LogFile = fdopen(LogFd,"r");
if (!LogFile) {
fprintf(stderr,"Error opening history file %s: %s\n", JobHistoryFileName,strerror(errno));
exit(1);
}
// In case of rotated history files, check if we have already reached the number of
// matches specified by the user before reading the next file
if (specifiedMatch != 0) {
if (matchCount == specifiedMatch) { // Already found n number of matches, cleanup
fclose(LogFile);
return;
}
}
if (backwards) {
offset = findLastDelimiter(LogFile, JobHistoryFileName);
}
if(longformat && use_xml) {
std::string out;
AddClassAdXMLFileHeader(out);
printf("%s\n", out.c_str());
}
while(!EndFlag) {
if (backwards) { // Read history file backwards
if (BOF) { // If reached beginning of file
break;
}
offset = findPrevDelimiter(LogFile, JobHistoryFileName, offset);
if (offset == -1) { // Unable to match constraint
break;
} else if (offset != 0) {
fseek(LogFile, offset, SEEK_SET);
buf.readLine(LogFile); // Read one line to skip delimiter and adjust to actual offset of ad
} else { // Offset set to 0
BOF = true;
fseek(LogFile, offset, SEEK_SET);
}
}
if( !( ad=new ClassAd(LogFile,"***", EndFlag, ErrorFlag, EmptyFlag) ) ){
fprintf( stderr, "Error: Out of memory\n" );
exit( 1 );
}
if( ErrorFlag ) {
printf( "\t*** Warning: Bad history file; skipping malformed ad(s)\n" );
ErrorFlag=0;
if(ad) {
delete ad;
ad = NULL;
}
continue;
}
if( EmptyFlag ) {
EmptyFlag=0;
if(ad) {
delete ad;
ad = NULL;
}
continue;
}
if (!constraint || constraint[0]=='\0' || EvalBool(ad, constraintExpr)) {
if (longformat) {
if( use_xml ) {
fPrintAdAsXML(stdout, *ad);
//.........这里部分代码省略.........