description and source-codefunction Registry(options) {
if (!(this instanceof Registry))
return new Registry(options);
/* private members */
var _options = options || {}
, _host = '' + (_options.host || '') // hostname
, _hive = '' + (_options.hive || HKLM) // registry hive
, _key = '' + (_options.key || '') // registry key
, _arch = _options.arch || null // hive architecture
/* getters/setters */
/**
* The hostname.
* @readonly
* @member {string} Registry#host
*/
this.__defineGetter__('host', function () { return _host; });
/**
* The hive id.
* @readonly
* @member {string} Registry#hive
*/
this.__defineGetter__('hive', function () { return _hive; });
/**
* The registry key name.
* @readonly
* @member {string} Registry#key
*/
this.__defineGetter__('key', function () { return _key; });
/**
* The full path to the registry key.
* @readonly
* @member {string} Registry#path
*/
this.__defineGetter__('path', function () { return (_host.length == 0 ? '' : '\\\\' + host + '\\') + _hive + _key; });
/**
* The registry hive architecture ('x86' or 'x64').
* @readonly
* @member {string} Registry#arch
*/
this.__defineGetter__('arch', function () { return _arch; });
/**
* Creates a new {@link Registry} instance that points to the parent registry key.
* @readonly
* @member {Registry} Registry#parent
*/
this.__defineGetter__('parent', function () {
var i = _key.lastIndexOf('\\')
return new Registry({
host: this.host,
hive: this.hive,
key: (i == -1)?'':_key.substring(0, i),
arch: this.arch
});
});
// validate options...
if (HIVES.indexOf(_hive) == -1)
throw new Error('illegal hive specified.');
if (!KEY_PATTERN.test(_key))
throw new Error('illegal key specified.');
if (_arch && _arch != 'x64' && _arch != 'x86')
throw new Error('illegal architecture specified (use x86 or x64)');
}