OpenBSD code style

This commit is contained in:
Jeremy Baxter 2023-09-24 16:11:20 +13:00
parent c21ab033ee
commit ca36b7fb90
2 changed files with 26 additions and 13 deletions

9
esv.d
View file

@ -206,7 +206,8 @@ key = %s
esv.extraParameters = iniData["api"].getKey("parameters"); esv.extraParameters = iniData["api"].getKey("parameters");
string returnValid(string def, string val) string
returnValid(string def, string val)
{ {
return val == "" ? def : val; return val == "" ? def : val;
} }
@ -275,12 +276,14 @@ key = %s
return true; return true;
} }
private string extractOpt(in GetOptException e) @safe private string
extractOpt(in GetOptException e) @safe
{ {
return e.msg.matchFirst("-.")[0]; return e.msg.matchFirst("-.")[0];
} }
private string parseBook(in string book) @safe private string
parseBook(in string book) @safe
{ {
return book.replaceAll(regex("[-_]"), " "); return book.replaceAll(regex("[-_]"), " ");
} }

View file

@ -135,7 +135,8 @@ const string[] ESVAPI_PARAMETERS = [
* Returns true if the argument book is a valid book of the Bible. * Returns true if the argument book is a valid book of the Bible.
* Otherwise, returns false. * Otherwise, returns false.
*/ */
bool bookValid(in char[] book) nothrow @safe bool
bookValid(in char[] book) nothrow @safe
{ {
foreach (string b; BIBLE_BOOKS) { foreach (string b; BIBLE_BOOKS) {
if (book.capitalize() == b.capitalize()) if (book.capitalize() == b.capitalize())
@ -147,9 +148,11 @@ bool bookValid(in char[] book) nothrow @safe
* Returns true if the argument book is a valid verse format. * Returns true if the argument book is a valid verse format.
* Otherwise, returns false. * Otherwise, returns false.
*/ */
bool verseValid(in char[] verse) @safe bool
verseValid(in char[] verse) @safe
{ {
bool vMatch(in string re) @safe bool
vMatch(in string re) @safe
{ {
return !verse.matchAll(regex(re)).empty; return !verse.matchAll(regex(re)).empty;
} }
@ -188,28 +191,32 @@ 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 key() const nothrow pure @safe @property string
key() const nothrow pure @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 tmpDir() const nothrow pure @safe @property string
tmpDir() const nothrow pure @safe
{ {
return _tmp; return _tmp;
} }
/* /*
* Returns the API URL currently in use. * Returns the API URL currently in use.
*/ */
@property string url() const nothrow pure @safe @property string
url() const nothrow pure @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 url(immutable(string) url) @safe @property void
url(immutable(string) url) @safe
in (!url.matchAll(`^https?://.+\\..+(/.+)?`).empty, "Invalid URL format") in (!url.matchAll(`^https?://.+\\..+(/.+)?`).empty, "Invalid URL format")
{ {
_url = url; _url = url;
@ -222,7 +229,8 @@ class ESVApi
* *
* Example: getVerses("John", "3:16-21") * Example: getVerses("John", "3:16-21")
*/ */
string getVerses(in char[] book, in char[] verse) const string
getVerses(in char[] book, in char[] verse) const
in (bookValid(book), "Invalid book") in (bookValid(book), "Invalid book")
in (verseValid(verse), "Invalid verse format") in (verseValid(verse), "Invalid verse format")
{ {
@ -299,7 +307,8 @@ class ESVApi
* *
* Example: getAudioVerses("John", "3:16-21") * Example: getAudioVerses("John", "3:16-21")
*/ */
string getAudioVerses(in char[] book, in char[] verse) const string
getAudioVerses(in char[] book, in char[] verse) const
in (bookValid(book), "Invalid book") in (bookValid(book), "Invalid book")
in (verseValid(verse), "Invalid verse format") in (verseValid(verse), "Invalid verse format")
{ {
@ -333,7 +342,8 @@ class ESVApi
* *
* Example: search("It is finished") * Example: search("It is finished")
*/ */
char[] search(in string query, in bool raw = true) char[]
search(in string query, in bool raw = true)
{ {
ulong i; ulong i;
char[] response; char[] response;