ajfmt.c


Function ajFmtPuts

Format and emit the converted numeric (ajFmtPutd) or string (ajFmtPuts) in str[0..len-1] according to Fmt's defaults and the values of flags,width and precision. It is a c.r.e for str=null, len less than 0 or flags=null.

Synopsis

Prototype
void ajFmtPuts (
      const char* str,
      ajint len,
      int function put,
      void* cl,
      const ajuint* flags,
      ajint width,
      ajint precision
);

TypeNameRead/WriteDescription
const char*strInputText to write.
ajintlenInputText length.
int functionputFunctionStandard function.
void*clModifyStandard - where to write the output
const ajuint*flagsInputFlags (after the %)
ajintwidthInputWidth (before the dot)
ajintprecisionInputPrecision (after the dot)
void RETURN

Input
str:(Input)Text to write.
len:(Input)Text length.
put:(Function)Standard function.
flags:(Input)Flags (after the %)
width:(Input)Width (before the dot)
precision:(Input)Precision (after the dot)
Input & Output
cl:(Modify)Standard - where to write the output
Returns
void:No return value

Description

Format and emit the converted numeric (ajFmtPutd) or string (ajFmtPuts) in str[0..len-1] according to Fmt's defaults and the values of flags,width and precision. It is a c.r.e for str=null, len less than 0 or flags=null.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtFmt

formats and emits the "..." arguments according to the format string fmt

Synopsis

Prototype
void ajFmtFmt (
      ajint function put,
      void* cl,
      const char* fmt,
      ...
);

TypeNameRead/WriteDescription
ajint functionputFunctionStandard function.
void*clModifyStandard - where to write the output
const char*fmtInputFormat string
...varargVarargVariable length argument list
void RETURN

Input
put:(Function)Standard function.
fmt:(Input)Format string
:(Vararg)Variable length argument list
Input & Output
cl:(Modify)Standard - where to write the output
Returns
void:No return value

Description

formats and emits the "..." arguments according to the format string fmt

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtPrint

format and emit the "..." arguments according to fmt;writes to stdout.

Synopsis

Prototype
void ajFmtPrint (
      const char* fmt,
      ...
);

TypeNameRead/WriteDescription
const char*fmtInputFormat string.
...varargVarargVariable length argument list
void RETURN

Input
fmt:(Input)Format string.
:(Vararg)Variable length argument list
Returns
void:No return value

Description

format and emit the "..." arguments according to fmt;writes to stdout.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtVPrint

format and emit the "..." arguments according to fmt;writes to stdout.

Synopsis

Prototype
void ajFmtVPrint (
      const char* fmt,
      va_list ap
);

TypeNameRead/WriteDescription
const char*fmtInputFormat string.
va_listapVarargVariable length argument list
void RETURN

Input
fmt:(Input)Format string.
ap:(Vararg)Variable length argument list
Returns
void:No return value

Description

format and emit the "..." arguments according to fmt;writes to stdout.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtError

format and emit the "..." arguments according to fmt;writes to stderr.

Synopsis

Prototype
void ajFmtError (
      const char* fmt,
      ...
);

TypeNameRead/WriteDescription
const char*fmtInputFormat string.
...varargVarargVariable length argument list
void RETURN

Input
fmt:(Input)Format string.
:(Vararg)Variable length argument list
Returns
void:No return value

Description

format and emit the "..." arguments according to fmt;writes to stderr.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtVError

format and emit the "..." arguments according to fmt. Writes to stderr.

Synopsis

Prototype
void ajFmtVError (
      const char* fmt,
      va_list ap
);

TypeNameRead/WriteDescription
const char*fmtInputFormat string.
va_listapVarargVariable length argument list
void RETURN

Input
fmt:(Input)Format string.
ap:(Vararg)Variable length argument list
Returns
void:No return value

Description

format and emit the "..." arguments according to fmt. Writes to stderr.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtPrintF

format and emit the "..." arguments according to fmt;writes to stream..

Synopsis

Prototype
void ajFmtPrintF (
      AjPFile file,
      const char* fmt,
      ...
);

TypeNameRead/WriteDescription
AjPFilefileModifyOutput file.
const char*fmtInputFormat string.
...varargVarargVariable length argument list
void RETURN

Input
fmt:(Input)Format string.
:(Vararg)Variable length argument list
Input & Output
file:(Modify)Output file.
Returns
void:No return value

Description

format and emit the "..." arguments according to fmt;writes to stream..

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtVPrintF

format and emit the "..." arguments according to fmt;writes to stream..

Synopsis

Prototype
void ajFmtVPrintF (
      AjPFile file,
      const char* fmt,
      va_list ap
);

TypeNameRead/WriteDescription
AjPFilefileModifyOutput file.
const char*fmtInputFormat string.
va_listapVarargVariable length argument list
void RETURN

Input
fmt:(Input)Format string.
ap:(Vararg)Variable length argument list
Input & Output
file:(Modify)Output file.
Returns
void:No return value

Description

format and emit the "..." arguments according to fmt;writes to stream..

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtVPrintFp

Format and emit the "..." arguments according to fmt;writes to stream..

Synopsis

Prototype
void ajFmtVPrintFp (
      FILE* stream,
      const char* fmt,
      va_list ap
);

TypeNameRead/WriteDescription
FILE*streamModifyOutput file.
const char*fmtInputFormat string.
va_listapVarargVariable length argument list
void RETURN

Input
fmt:(Input)Format string.
ap:(Vararg)Variable length argument list
Input & Output
stream:(Modify)Output file.
Returns
void:No return value

Description

Format and emit the "..." arguments according to fmt;writes to stream..

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtPrintFp

format and emit the "..." arguments according to fmt;writes to stream..

Synopsis

Prototype
void ajFmtPrintFp (
      FILE* stream,
      const char* fmt,
      ...
);

TypeNameRead/WriteDescription
FILE*streamModifyOutput file.
const char*fmtInputFormat string.
...varargVarargVariable length argument list
void RETURN

Input
fmt:(Input)Format string.
:(Vararg)Variable length argument list
Input & Output
stream:(Modify)Output file.
Returns
void:No return value

Description

format and emit the "..." arguments according to fmt;writes to stream..

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtVPrintCL

formats the "..." arguments into buf[1...size-1] according to fmt, appends a num character, and returns the length of buf. It is a c.r.e for size to be less than or equal to 0. Raises Fmt_Overflow if more than size-1 characters are emitted.

Synopsis

Prototype
ajint ajFmtVPrintCL (
      char* buf,
      ajint size,
      const char* fmt,
      va_list ap
);

TypeNameRead/WriteDescription
char*bufOutputchar string to be written to.
ajintsizeInputlength of buffer
const char*fmtInputFormat string.
va_listapVarargVariable length argument list
ajint RETURNnumber of characters written to buf.

Input
size:(Input)length of buffer
fmt:(Input)Format string.
ap:(Vararg)Variable length argument list
Output
buf:(Output)char string to be written to.
Returns
ajint:number of characters written to buf.

Description

formats the "..." arguments into buf[1...size-1] according to fmt, appends a num character, and returns the length of buf. It is a c.r.e for size to be less than or equal to 0. Raises Fmt_Overflow if more than size-1 characters are emitted.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtPrintCL

formats the "..." arguments into buf[1...size-1] according to fmt, appends a num character, and returns the length of buf. It is a c.r.e for size to be lass than or equal to 0. Raises Fmt_Overflow if more than size-1 characters are emitted.

Synopsis

Prototype
ajint ajFmtPrintCL (
      char* buf,
      ajint size,
      const char* fmt,
      ...
);

TypeNameRead/WriteDescription
char*bufOutputchar string to be written to.
ajintsizeInputlength of buffer
const char*fmtInputFormat string
...varargVarargVariable length argument list
ajint RETURNnumber of characters written to buf.

Input
size:(Input)length of buffer
fmt:(Input)Format string
:(Vararg)Variable length argument list
Output
buf:(Output)char string to be written to.
Returns
ajint:number of characters written to buf.

Description

formats the "..." arguments into buf[1...size-1] according to fmt, appends a num character, and returns the length of buf. It is a c.r.e for size to be lass than or equal to 0. Raises Fmt_Overflow if more than size-1 characters are emitted.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtStr

Formats the "..." arguments into a New AjPStr according to fmt. It starts with an initial size of 20 then doubles until the fmt output fits.

The caller is responsible for deleting the AjPStr afterwards.

Synopsis

Prototype
AjPStr ajFmtStr (
      const char* fmt,
      ...
);

TypeNameRead/WriteDescription
const char*fmtInputFormat string.
...varargVarargVariable length argument list
AjPStr RETURNnew AjPStr with Ptr holding formatted chars

Input
fmt:(Input)Format string.
:(Vararg)Variable length argument list
Returns
AjPStr:new AjPStr with Ptr holding formatted chars

Description

Formats the "..." arguments into a New AjPStr according to fmt. It starts with an initial size of 20 then doubles until the fmt output fits.

The caller is responsible for deleting the AjPStr afterwards.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtPrintS

Formats the "..." arguments into an AjPStr according to fmt. If AjPStr is not large enough then if it is the only one i.e Use = 1 then increase till it fits. Else return 0 if it does not fit. If it fits return the address of the new AjPStr.

Synopsis

Prototype
AjPStr ajFmtPrintS (
      AjPStr* pthis,
      const char* fmt,
      ...
);

TypeNameRead/WriteDescription
AjPStr*pthisModifyString to be written too.
const char*fmtInputFormat for string.
...varargVarargVariable length argument list
AjPStr RETURNOutput string

Input
fmt:(Input)Format for string.
:(Vararg)Variable length argument list
Input & Output
pthis:(Modify)String to be written too.
Returns
AjPStr:Output string

Description

Formats the "..." arguments into an AjPStr according to fmt. If AjPStr is not large enough then if it is the only one i.e Use = 1 then increase till it fits. Else return 0 if it does not fit. If it fits return the address of the new AjPStr.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtVPrintS

Formats the "..." arguments into an AjPStr according to fmt. If AjPStr is not large enough then if it is the only one i.e Use = 1 then increase till it fits. Else return 0 if it does not fit. If it fits return the address of the new AjPStr.

Synopsis

Prototype
AjPStr ajFmtVPrintS (
      AjPStr* pthis,
      const char* fmt,
      va_list ap
);

TypeNameRead/WriteDescription
AjPStr*pthisModifyString to be written too.
const char*fmtInputFormat for string.
va_listapVarargVariable length argument list
AjPStr RETURNOutput string

Input
fmt:(Input)Format for string.
ap:(Vararg)Variable length argument list
Input & Output
pthis:(Modify)String to be written too.
Returns
AjPStr:Output string

Description

Formats the "..." arguments into an AjPStr according to fmt. If AjPStr is not large enough then if it is the only one i.e Use = 1 then increase till it fits. Else return 0 if it does not fit. If it fits return the address of the new AjPStr.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtPrintAppS

Formats the "..." arguments and appends to an AjPStr according to fmt. If AjPStr is not large enough then if it is the only one i.e Use = 1 then increase till it fits. Else return 0 if it does not fit. If it fits return the address of the new AjPStr.

Synopsis

Prototype
AjPStr ajFmtPrintAppS (
      AjPStr* pthis,
      const char* fmt,
      ...
);

TypeNameRead/WriteDescription
AjPStr*pthisModifyString to be written too.
const char*fmtInputFormat for string.
...varargVarargVariable length argument list
AjPStr RETURNOutput string.

Input
fmt:(Input)Format for string.
:(Vararg)Variable length argument list
Input & Output
pthis:(Modify)String to be written too.
Returns
AjPStr:Output string.

Description

Formats the "..." arguments and appends to an AjPStr according to fmt. If AjPStr is not large enough then if it is the only one i.e Use = 1 then increase till it fits. Else return 0 if it does not fit. If it fits return the address of the new AjPStr.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtVfmtStrCL

Same as ajFmtPrintCL but takes arguments from the list ap.

Synopsis

Prototype
ajint ajFmtVfmtStrCL (
      char** pbuf,
      ajint pos,
      size_t* size,
      const char* fmt,
      va_list ap
);

TypeNameRead/WriteDescription
char**pbufOutputchar string to be written to.
ajintposInputposition in buffer to start writing
size_t*sizeModifyallocated size of the buffer
const char*fmtInputFormat string.
va_listapVarargVariable length argument list.
ajint RETURNnumber of characters written to buf.

Input
pos:(Input)position in buffer to start writing
fmt:(Input)Format string.
ap:(Vararg)Variable length argument list.
Output
pbuf:(Output)char string to be written to.
Input & Output
size:(Modify)allocated size of the buffer
Returns
ajint:number of characters written to buf.

Description

Same as ajFmtPrintCL but takes arguments from the list ap.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtVfmtCL

Same as ajFmtPrintCL but takes arguments from the list ap.

Synopsis

Prototype
ajint ajFmtVfmtCL (
      char* buf,
      ajint size,
      const char* fmt,
      va_list ap
);

TypeNameRead/WriteDescription
char*bufOutputchar string to be written to.
ajintsizeInputlength of buffer
const char*fmtInputFormat string.
va_listapVarargVariable length argument list.
ajint RETURNnumber of characters written to buf.

Input
size:(Input)length of buffer
fmt:(Input)Format string.
ap:(Vararg)Variable length argument list.
Output
buf:(Output)char string to be written to.
Returns
ajint:number of characters written to buf.

Description

Same as ajFmtPrintCL but takes arguments from the list ap.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtString

formats the "..." arguments into a null-terminated string according to fmt and returns that string.

Synopsis

Prototype
char* ajFmtString (
      const char* fmt,
      ...
);

TypeNameRead/WriteDescription
const char*fmtInputFormat string
...varargVarargVariable length argument list
char* RETURNOutput string.

Input
fmt:(Input)Format string
:(Vararg)Variable length argument list
Returns
char*:Output string.

Description

formats the "..." arguments into a null-terminated string according to fmt and returns that string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtVString

as ajFmtString but takes arguments from the list ap.

Synopsis

Prototype
char* ajFmtVString (
      const char* fmt,
      va_list ap
);

TypeNameRead/WriteDescription
const char*fmtInputFormat string.
va_listapVarargVariable length argument list.
char* RETURNOutput string.

Input
fmt:(Input)Format string.
ap:(Vararg)Variable length argument list.
Returns
char*:Output string.

Description

as ajFmtString but takes arguments from the list ap.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtVfmt

as ajFmtPrint but takes arguments from the list ap.

Synopsis

Prototype
void ajFmtVfmt (
      int function put,
      void* cl,
      const char* fmt,
      va_list ap
);

TypeNameRead/WriteDescription
int functionputFunctionStandard function
void*clModifyWhere we are going to write the results
const char*fmtInputFormat string
va_listapVarargVariable argument list
void RETURN

Input
put:(Function)Standard function
fmt:(Input)Format string
ap:(Vararg)Variable argument list
Input & Output
cl:(Modify)Where we are going to write the results
Returns
void:No return value

Description

as ajFmtPrint but takes arguments from the list ap.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtPutd

Given a string containing a number in full, converts it using the width and precision values.

Synopsis

Prototype
void ajFmtPutd (
      const char* str,
      ajint len,
      int function put,
      void* cl,
      const ajuint* flags,
      ajint width,
      ajint precision
);

TypeNameRead/WriteDescription
const char*strInputText to write.
ajintlenInputText length.
int functionputFunctionStandard function.
void*clModifyStandard - where to write the output
const ajuint*flagsInputFlags (after the %)
ajintwidthInputWidth (before the dot)
ajintprecisionInputPrecision (after the dot)
void RETURN

Input
str:(Input)Text to write.
len:(Input)Text length.
put:(Function)Standard function.
flags:(Input)Flags (after the %)
width:(Input)Width (before the dot)
precision:(Input)Precision (after the dot)
Input & Output
cl:(Modify)Standard - where to write the output
Returns
void:No return value

Description

Given a string containing a number in full, converts it using the width and precision values.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtPrintSplit

Block and print a string. String is split at given delimiters

Synopsis

Prototype
void ajFmtPrintSplit (
      AjPFile outf,
      const AjPStr str,
      const char* prefix,
      ajint len,
      const char* delim
);

TypeNameRead/WriteDescription
AjPFileoutfModifyoutput stream
const AjPStrstrInputtext to write
const char*prefixInputprefix string
ajintlenInputmaximum span
const char*delimInputdelimiter string
void RETURN

Input
str:(Input)text to write
prefix:(Input)prefix string
len:(Input)maximum span
delim:(Input)delimiter string
Input & Output
outf:(Modify)output stream
Returns
void:No return value

Description

Block and print a string. String is split at given delimiters

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtScanS

Scan a string according to fmt and load the ... variable pointers Like C function sscanf.

Synopsis

Prototype
ajint ajFmtScanS (
      const AjPStr thys,
      const char* fmt,
      ...
);

TypeNameRead/WriteDescription
const AjPStrthysInputString.
const char*fmtInputFormat string.
...varargVarargVariable length argument list
ajint RETURNnumber of successful conversions

Input
thys:(Input)String.
fmt:(Input)Format string.
:(Vararg)Variable length argument list
Returns
ajint:number of successful conversions

Description

Scan a string according to fmt and load the ... variable pointers Like C function sscanf.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtScanC

Scan a string according to fmt and load the ... variable pointers Like C function sscanf.

Synopsis

Prototype
ajint ajFmtScanC (
      const char* thys,
      const char* fmt,
      ...
);

TypeNameRead/WriteDescription
const char*thysInputString.
const char*fmtInputFormat string.
...varargVarargVariable length argument list
ajint RETURNnumber of successful conversions

Input
thys:(Input)String.
fmt:(Input)Format string.
:(Vararg)Variable length argument list
Returns
ajint:number of successful conversions

Description

Scan a string according to fmt and load the ... variable pointers Like C function sscanf.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajFmtScanF

Scan an AjPFile object according to fmt and load the ... variable pointers Like C function fscanf.

Synopsis

Prototype
ajint ajFmtScanF (
      AjPFile thys,
      const char* fmt,
      ...
);

TypeNameRead/WriteDescription
AjPFilethysModifyInput file object
const char*fmtInputFormat string.
...varargVarargVariable length argument list
ajint RETURNnumber of successful conversions

Input
fmt:(Input)Format string.
:(Vararg)Variable length argument list
Input & Output
thys:(Modify)Input file object
Returns
ajint:number of successful conversions

Description

Scan an AjPFile object according to fmt and load the ... variable pointers Like C function fscanf.

See Also

See other functions in this section

Availability

In release 6.4.0