picofuse-objc

Instance Methods | Class Methods | List of all members
NXEnvironment Class Reference

The command line, and what the program and the system it runs on are. More...

#import <Foundation/Foundation.h>

Inheritance diagram for NXEnvironment:
Inheritance graph
[legend]
Collaboration diagram for NXEnvironment:
Collaboration graph
[legend]

Instance Methods

(id) - initWithArgc:argv:
 Initializes an environment for a command line.
 
(NXMap *) - parseFlags:error:
 Parses the flags on the command line. More...
 
(BOOL) - writeUsageToStream:flags:
 Writes a line for each flag to a stream, with its type and its default, such as " --count, -n <int> (default: 3)". More...
 
(NXArray *) - arguments
 Returns the NXString arguments after the flags, from the last parse, or an empty array if there hasn't been one or it failed.
 
(NXString *) - name
 Returns the program's name.
 
(NXString *) - version
 Returns the program's version, or nil.
 
(NXString *) - system
 Returns the system, such as "darwin", "linux" or a Pico board's name.
 
(NXString *) - serial
 Returns the device's serial number, or nil.
 
- Instance Methods inherited from NXObject
(void) - dealloc
 Frees the instance. More...
 
(NXZone *) - zone
 Returns the zone in which the instance was allocated. More...
 
(id) - retain
 Increases the retain count of the receiver. More...
 
(void) - release
 Decreases the retain count of the receiver. More...
 
(id) - autorelease
 Releases the receiver later, when the current autorelease pool of the thread is drained. More...
 
(id) - copy
 Returns a copy which can't be changed by anything else, which the caller owns and has to release. More...
 
(uintptr_t) - hash
 Returns a number for the object, which is the same for objects which are equal by isEqual:. More...
 
(NXString *) - description
 Returns a string which describes the instance, for logging. More...
 
- Instance Methods inherited from Object
(id) - init
 Initialize the instance, after allocation. More...
 
(Class) - class
 Returns the class of the instance. More...
 
(Class) - superclass
 Returns the superclass of the instance. More...
 
(BOOL) - isEqual:
 Compares the receiver to another object for equality. More...
 
(BOOL) - isKindOfClass:
 Returns a Boolean value that indicates whether the receiver is an instance of a given class. More...
 
(BOOL) - conformsTo:
 Checks if the receiver's class conforms to a protocol. More...
 
- Instance Methods inherited from <ObjectProtocol>
(BOOL) - respondsToSelector:
 Checks if the receiver responds to a selector. More...
 

Class Methods

(NXEnvironment *) + environmentWithArgc:argv:
 Returns an environment for a command line. More...
 
- Class Methods inherited from NXObject
(id) + alloc
 Allocates a new instance in the default zone, or if there isn't one, with sys_calloc(). More...
 
(id) + allocWithZone:
 Allocates a new instance in a specific zone. More...
 
(id) + new
 Allocates and initializes a new instance, as [[cls alloc] init] does. More...
 
(NXString *) + description
 Returns the name of the class.
 
- Class Methods inherited from Object
(void) + initialize
 Performs one-time initialization for the class. More...
 
(Class) + class
 Returns the class object. More...
 
(Class) + superclass
 Returns the superclass of the class. More...
 
(BOOL) + conformsTo:
 Checks if the class conforms to a protocol. More...
 

Additional Inherited Members

- Protected Attributes inherited from Object
Class isa
 A pointer to the object's class structure. More...
 

Detailed Description

The command line, and what the program and the system it runs on are.

Flags are parsed with picofuse's parser, as described by NXArgument objects:

NXString *error = nil;
NXMap *values = [environment parseFlags:[NXArray arrayWithObjects:
[NXArgument argumentWithName:@"verbose" short:@"v"],
nil] error:&error];

picofuse has one parser for the process, so parsing is done one at a time, and everything it returns is copied.

Definition at line 27 of file NXEnvironment.h.

Method Documentation

◆ environmentWithArgc:argv:()

+ (NXEnvironment *) environmentWithArgc: (int)  argc
argv: (char **)  argv 

Returns an environment for a command line.

Parameters
argcThe number of arguments, including the program's name.
argvThe arguments, which must stay valid while it's used.

◆ parseFlags:error:()

- (NXMap *) parseFlags: (NXArray *)  flags
error: (NXString **)  error 

Parses the flags on the command line.

Parameters
flagsThe NXArgument flags which can be given.
errorSet to why it couldn't parse, such as "unknown flag --x", or nil if it doesn't matter.
Returns
The value of every flag, keyed by its long name: as it's given, or its default. Or nil if a flag isn't an NXArgument, a name, long or short, is another flag's, a flag given is unknown or a value isn't of its type. With nothing after the program's name, it's every default, which is so on a Pico.

◆ writeUsageToStream:flags:()

- (BOOL) writeUsageToStream: (NXStream *)  stream
flags: (NXArray *)  flags 

Writes a line for each flag to a stream, with its type and its default, such as " --count, -n <int> (default: 3)".

Parameters
streamThe stream to write to.
flagsThe NXArgument flags, as for parseFlags:error:.
Returns
YES, or NO if a flag isn't an NXArgument, a name is another flag's, it couldn't be written, or it's a Pico, which has no command line.

The documentation for this class was generated from the following file: