Add @safe and final where possible, remove unnecessary documentation and fix incorrect indentation

This commit is contained in:
Jeremy Baxter 2023-12-05 08:59:35 +13:00
parent 472261e15a
commit 97c9c427ff
2 changed files with 22 additions and 33 deletions

2
esv.d
View file

@ -219,7 +219,7 @@ key = %s
esv.extraParameters = iniData["api"].getKey("parameters"); esv.extraParameters = iniData["api"].getKey("parameters");
string string
returnValid(string def, string val) returnValid(string def, string val) @safe
{ {
return val == "" ? def : val; return val == "" ? def : val;
} }

View file

@ -162,8 +162,8 @@ verseValid(in char[] verse) @safe
"^\\d{1,3}:\\d{1,3}$", "^\\d{1,3}:\\d{1,3}$",
"^\\d{1,3}:\\d{1,3}-\\d{1,3}$" "^\\d{1,3}:\\d{1,3}-\\d{1,3}$"
]) { ]) {
if (!verse.matchAll(regex(re)).empty) if (!verse.matchAll(regex(re)).empty)
return true; return true;
} }
return false; return false;
@ -183,26 +183,17 @@ class ESVApi
string _url; string _url;
} }
/**
* Structure that contains associative arrays for each of
* the possible parameter types. Specify API parameters here.
*/
ESVApiOptions opts; ESVApiOptions opts;
/**
* Any additional parameters to append to the request. /** Additional request parameters */
* Must start with an ampersand ('&').
*/
string extraParameters; string extraParameters;
/** /** Called whenever progress is made on a request. */
* Callback function that is called whenever progress is made
* on a request.
*/
int delegate(size_t, size_t, size_t, size_t) onProgress; int delegate(size_t, size_t, size_t, size_t) onProgress;
/** /**
* Constructs an ESVApi object using the given authentication key. * Constructs an ESVApi object using the given authentication key.
*/ */
this(string key, string tmpName = "esv") this(string key, string tmpName = "esv") @safe
{ {
_key = key; _key = key;
_tmp = tempDir() ~ tmpName; _tmp = tempDir() ~ tmpName;
@ -220,31 +211,31 @@ class ESVApi
* Returns the API authentication key that was given when the object * Returns the API authentication key that was given when the object
* was constructed. This authentication key cannot be changed. * was constructed. This authentication key cannot be changed.
*/ */
@property string final @property string
key() const nothrow pure @safe key() const nothrow pure @nogc @safe
{ {
return _key; return _key;
} }
/** /**
* Returns the subdirectory used to store temporary audio passages. * Returns the subdirectory used to store temporary audio passages.
*/ */
@property string final @property string
tmpDir() const nothrow pure @safe tmpDir() const nothrow pure @nogc @safe
{ {
return _tmp; return _tmp;
} }
/** /**
* Returns the API URL currently in use. * Returns the API URL currently in use.
*/ */
@property string final @property string
url() const nothrow pure @safe url() const nothrow pure @nogc @safe
{ {
return _url; return _url;
} }
/** /**
* Sets the API URL currently in use to the given url argument. * Sets the API URL currently in use to the given url argument.
*/ */
@property void final @property void
url(immutable(string) url) @safe url(immutable(string) url) @safe
in (!url.matchAll(`^https?://.+\\..+(/.+)?`).empty, "Invalid URL format") in (!url.matchAll(`^https?://.+\\..+(/.+)?`).empty, "Invalid URL format")
{ {
@ -396,17 +387,14 @@ class ESVApi
*/ */
struct ESVApiOptions struct ESVApiOptions
{ {
/** Boolean options */
bool[string] b; bool[string] b;
/** Integer options */
int[string] i; int[string] i;
/** Indentation style to use when formatting text passages. */
ESVIndent indent_using; ESVIndent indent_using;
/** /**
* If initialise is true, initialise an ESVApiOptions * If initialise is true, initialise an ESVApiOptions
* structure with the default values. * structure with the default values.
*/ */
this(bool initialise) nothrow @safe this(bool initialise) nothrow @safe
{ {
if (!initialise) if (!initialise)
@ -436,6 +424,7 @@ struct ESVApiOptions
/** /**
* Exception thrown on API errors. * Exception thrown on API errors.
*
* Currently only used when there is no search results * Currently only used when there is no search results
* following a call of searchFormat. * following a call of searchFormat.
*/ */