Foundational classes and types. More...
|
Classes | |
| protocol | <NXArchiving> |
| Objects which can be written to an archive and read back. More... | |
| class | NXArchive |
| Writes objects out as JSON or binary, and reads them back. More... | |
| class | NXArgument |
| A flag which can be given on the command line, as –name or -n, which NXEnvironment parses. More... | |
| class | NXArray |
| An ordered list of objects, which can be changed. More... | |
| class | NXAtomic |
| A 32-bit unsigned number, which threads can read and change without a lock. More... | |
| class | NXAutoreleasePool |
| A pool of objects, which are released when the pool is drained. More... | |
| protocol | <NXCollection> |
| Objects which hold other objects, such as arrays, which can be gone through with a for...in loop. More... | |
| class | NXColor |
| A color: red, green and blue, with an opacity. More... | |
| class | NXCondition |
| A lock, and a condition which threads holding it can wait for. More... | |
| class | NXConstantString |
The class of constant strings, such as @"string". More... | |
| class | NXData |
| Bytes, which can be added to. More... | |
| class | NXDate |
| A date and time, to the nanosecond, with the offset of a time zone. More... | |
| class | NXEnvironment |
| The command line, and what the program and the system it runs on are. More... | |
| protocol | <NXFastEnumeration> |
| Objects which can be gone through with a for...in loop. More... | |
| struct | NXPoint |
| A point, in pixels from the top left. More... | |
| struct | NXSize |
| A size, in pixels. More... | |
| struct | NXRect |
| A rectangle: its top left, and its size. More... | |
| class | NXLock |
| A lock, which one thread at a time can hold. More... | |
| protocol | <NXLocking> |
| Objects which can be locked by one thread at a time. More... | |
| class | NXMap |
| Objects found by keys, which can be changed. More... | |
| class | NXMutableString |
| A string which can be changed. More... | |
| class | NXNull |
| A null value, as an object, for where nil can't be used. More... | |
| class | NXNumber |
| An integer, floating point or boolean value, as an object. More... | |
| class | NXObject |
| The base class for objects in the Foundation framework. More... | |
| class | NXScanner |
| Reads tokens, one at a time, from a string or a stream. More... | |
| class | NXStream |
| A stream of bytes, which can be read or written. More... | |
| class | NXString |
| A string of UTF-8 text. More... | |
| class | NXThread |
| Runs methods in threads, and provides information about cores. More... | |
| class | NXWaitGroup |
| A count of work to be done, which threads can wait for to reach zero. More... | |
| class | NXZone |
| A region of memory, from which objects and other memory can be allocated. More... | |
Macros | |
| #define | NXNanosecond ((NXDuration)1) |
| One nanosecond. | |
| #define | NXMicrosecond (1000 * NXNanosecond) |
| One microsecond. | |
| #define | NXMillisecond (1000 * NXMicrosecond) |
| One millisecond. | |
| #define | NXSecond (1000 * NXMillisecond) |
| One second. | |
| #define | NXMinute (60 * NXSecond) |
| One minute. | |
| #define | NXHour (60 * NXMinute) |
| One hour. | |
| #define | NXDay (24 * NXHour) |
| One day of 24 hours. | |
| #define | NXHashMaxSize SYS_HASH_SIZE |
| The size in bytes of the largest hash. | |
| #define | NXLogDepthMax 4 |
| How deeply logs can be nested, as when a description itself logs, after which a line saying so is written instead. | |
| #define | NXDebug(format, ...) _NXDebug(format, ##__VA_ARGS__) |
| Writes a formatted line to the standard output, after "[DEBUG] ", in a debug build. More... | |
| #define | NXNotFound SIZE_MAX |
| Returned by methods which return where something is, when it isn't found. | |
| #define | NXStreamEnd SYS_IOSTREAM_EOF |
| Returned by peek when there's nothing to read. | |
Typedefs | |
| typedef int64_t | NXDuration |
| A length of time, in nanoseconds, which may be negative. More... | |
| typedef struct __objcFastEnumerationState | NXFastEnumerationState |
| The state of a for...in loop, passed to countByEnumeratingWithState:objects:count:. | |
Enumerations | |
| enum | NXArchiveFormat { NXArchiveFormatJSON, NXArchiveFormatBinary } |
| The formats of an archive. More... | |
| enum | NXComparisonResult { NXComparisonAscending = -1, NXComparisonSame = 0, NXComparisonDescending = 1 } |
| The order of two objects. More... | |
| enum | NXDateFormat { NXDateFormatISO8601 = sys_date_format_iso8601, NXDateFormatRFC2822 = sys_date_format_rfc2822, NXDateFormatLog = sys_date_format_log } |
| Ways of writing a date. More... | |
| enum | NXHashAlgorithm { NXHashAlgorithmMD5 = sys_hash_md5, NXHashAlgorithmSHA256 = sys_hash_sha256 } |
| Algorithms which hash data. More... | |
| enum | NXScannerFlags { NXScannerNone = sys_scanner_none, NXScannerEscapes = sys_scanner_escapes, NXScannerNewlines = sys_scanner_newlines, NXScannerKeywords = sys_scanner_keywords, NXScannerKeywordsWithUnderscores, NXScannerKeywordsWithDashes, NXScannerQuotesSingle = sys_scanner_quotes_single, NXScannerQuotesDouble = sys_scanner_quotes_double, NXScannerQuotes = sys_scanner_quotes, NXScannerCommentsHash = sys_scanner_comments_hash, NXScannerCommentsSlash = sys_scanner_comments_slash, NXScannerComments = sys_scanner_comments, NXScannerNumbers = sys_scanner_numbers, NXScannerNumbersOctal = sys_scanner_numbers_octal, NXScannerNumbersBinary = sys_scanner_numbers_binary, NXScannerNumbersHex = sys_scanner_numbers_hex, NXScannerNumbersFloat = sys_scanner_numbers_float, NXScannerDatesISO8601 = sys_scanner_dates_iso8601, NXScannerDates = sys_scanner_dates, NXScannerDurations = sys_scanner_durations } |
| Which tokens a scanner recognizes, besides runs of spaces, letters and digits. More... | |
| enum | NXScannerClass { NXScannerClassOther = sys_scanner_other, NXScannerClassSpace = sys_scanner_space, NXScannerClassDigit = sys_scanner_digit, NXScannerClassAlpha = sys_scanner_alpha, NXScannerClassPunct = sys_scanner_punct, NXScannerClassSymbol = sys_scanner_symbol, NXScannerClassControl = sys_scanner_control, NXScannerClassEscape = sys_scanner_escape, NXScannerClassNewline = sys_scanner_newline, NXScannerClassKeyword = sys_scanner_keyword, NXScannerClassString = sys_scanner_string, NXScannerClassComment = sys_scanner_comment, NXScannerClassNumber = sys_scanner_number, NXScannerClassDate = sys_scanner_date, NXScannerClassDuration = sys_scanner_duration } |
| The class of a token. More... | |
Functions | |
| uint32_t | NXDurationMilliseconds (NXDuration duration) |
| Converts a duration to milliseconds, as used by picofuse. More... | |
| NXDuration | NXDurationTimestamp (void) |
| Returns the time since the program started. More... | |
| NXString * | NXDurationDescription (NXDuration duration, NXDuration truncate) |
| Returns a description of a duration, such as "1d2h3m4s5ms6us7ns", which NXDurationFromString reads. More... | |
| BOOL | NXDurationFromString (NXString *string, NXDuration *duration) |
| Reads a duration from a string. More... | |
| static NXPoint | NXMakePoint (int16_t x, int16_t y) |
| Returns a point. | |
| static NXSize | NXMakeSize (uint16_t width, uint16_t height) |
| Returns a size. | |
| static NXRect | NXMakeRect (int16_t x, int16_t y, uint16_t width, uint16_t height) |
| Returns a rectangle. | |
| size_t | NXLog (NXString *format,...) |
| Writes a formatted line to the standard output. More... | |
| size_t | NXLogv (NXString *format, va_list args) |
| Writes a formatted line to the standard output, from arguments. | |
| int32_t | NXRandInt32 (void) |
| Returns a random 32-bit signed integer. | |
| uint32_t | NXRandUnsignedInt32 (void) |
| Returns a random 32-bit unsigned integer. | |
| int64_t | NXRandInt64 (void) |
| Returns a random 64-bit signed integer. | |
| uint64_t | NXRandUnsignedInt64 (void) |
| Returns a random 64-bit unsigned integer. | |
Foundational classes and types.
| #define NXDebug | ( | format, | |
| ... | |||
| ) | _NXDebug(format, ##__VA_ARGS__) |
| typedef int64_t NXDuration |
A length of time, in nanoseconds, which may be negative.
Durations are made by multiplying the constants for units of time. For example, 90 * NXSecond or NXMinute + 30 * NXSecond. They can be up to about 292 years.
Definition at line 17 of file NXDuration.h.
| enum NXArchiveFormat |
The formats of an archive.
| Enumerator | |
|---|---|
| NXArchiveFormatJSON | JSON, with keys, and no classes unless they differ. |
| NXArchiveFormatBinary | Values in order, little-endian, with a hash of each class. |
Definition at line 13 of file NXArchive.h.
| enum NXComparisonResult |
The order of two objects.
| Enumerator | |
|---|---|
| NXComparisonAscending | The first is before the second. |
| NXComparisonSame | They're in the same place. |
| NXComparisonDescending | The first is after the second. |
Definition at line 13 of file NXComparisonResult.h.
| enum NXDateFormat |
Ways of writing a date.
Definition at line 17 of file NXDate.h.
| enum NXHashAlgorithm |
Algorithms which hash data.
MD5 isn't secure, so it's only for uses such as checksums.
| Enumerator | |
|---|---|
| NXHashAlgorithmMD5 | MD5, which is 16 bytes. |
| NXHashAlgorithmSHA256 | SHA-256, which is 32 bytes. |
Definition at line 16 of file NXHashAlgorithm.h.
| enum NXScannerClass |
The class of a token.
Punctuation, symbols, control characters and line feeds are one character each; the others can be longer.
Definition at line 51 of file NXScanner.h.
| enum NXScannerFlags |
Which tokens a scanner recognizes, besides runs of spaces, letters and digits.
Combine them with |. Those such as NXScannerNumbersHex include the one they extend.
Definition at line 17 of file NXScanner.h.
| NXString* NXDurationDescription | ( | NXDuration | duration, |
| NXDuration | truncate | ||
| ) |
Returns a description of a duration, such as "1d2h3m4s5ms6us7ns", which NXDurationFromString reads.
| duration | The duration. |
| truncate | The unit to which the duration is truncated, or zero for none. |
| BOOL NXDurationFromString | ( | NXString * | string, |
| NXDuration * | duration | ||
| ) |
Reads a duration from a string.
| string | The whole of it is a duration: an optional sign, then one or more amounts, each a number and a unit, without spaces, such as "1h30m", "1.5s", "-250ms" or "1d2h3m". The units are "d", "day" or "days", "h", "m", "s", "ms", "us" or "µs", and "ns". Any part of a nanosecond is dropped. |
| duration | Where to put the duration, which isn't changed if it can't be read. |
| uint32_t NXDurationMilliseconds | ( | NXDuration | duration | ) |
Converts a duration to milliseconds, as used by picofuse.
| duration | The duration. |
| NXDuration NXDurationTimestamp | ( | void | ) |
Returns the time since the program started.
| size_t NXLog | ( | NXString * | format, |
| ... | |||
| ) |
Writes a formatted line to the standard output.
| format | The format, as for +[NXString stringWithFormat:], which can include %@ for the description of an object and t for a duration. A line feed is added. |
It's formatted before anything is written, so the description of an object can itself log, and its line is written first. A line of up to 127 bytes is formatted once, but a longer one is formatted twice, to find its length, so the descriptions in it are found twice. Logs nested more than NXLogDepthMax deep, as when a description logs itself, write a line saying so instead of recursing. Lines from threads at the same time aren't mixed. Don't log from an interrupt.