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
);

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.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.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,
      ...
);

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

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.0

Function ajFmtPrint

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

Synopsis

Prototype

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

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.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.0

Function ajFmtVPrint

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

Synopsis

Prototype

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

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.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.0

Function ajFmtError

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

Synopsis

Prototype

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

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.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.0

Function ajFmtVError

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

Synopsis

Prototype

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

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.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.0

Function ajFmtPrintF

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

Synopsis

Prototype

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

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..

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.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
);

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..

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.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
);

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..

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.0

Function ajFmtPrintFp

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

Synopsis

Prototype

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

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..

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.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
);

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.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.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,
      ...
);

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.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.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 reponsible for deleting the AjPStr afterwards.

Synopsis

Prototype

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

Input

fmt:(Input)Format string.
:(Vararg)Variable length argument list

Returns

AjPStr:fnew 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 reponsible for deleting the AjPStr afterwards.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.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,
      ...
);

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.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.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
);

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.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.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,
      ...
);

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.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.0

Function ajFmtVfmtStrCL

Same as ajFmtPrintCL but takes arguments from the list ap.

Synopsis

Prototype

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

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.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.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
);

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.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.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,
      ...
);

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.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.0

Function ajFmtVString

as ajFmtString but takes arguments from the list ap.

Synopsis

Prototype

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

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.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.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
);

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.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.0

Function ajFmtRegister

Registers 'newcvt' as the conversion routine for format code 'code'

Synopsis

Prototype

Fmt_T ajFmtRegister (
      ajint code,
      Fmt_T newcvt
);

Input

code:(Input)value of char to be replaced
newcvt:(Function)new routine for conversion

Returns

Fmt_T:old value

Description

Registers 'newcvt' as the conversion routine for format code 'code'

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.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
);

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.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.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
);

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

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.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,
      ...
);

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.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.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,
      ...
);

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.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.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,
      ...
);

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.

Usage

See source code

Example

In preparation

Errors

See source code

Dependencies

See source code

See Also

See other functions in this section

Availability

In release 3.0.0