mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Make all API outputs const
To make it clear that they're not meant for modification.
This commit is contained in:
+7
-7
@@ -465,7 +465,7 @@ extern "C"
|
||||
* @returns A return code.
|
||||
*/
|
||||
LOOT_API unsigned int loot_sort_plugins(loot_db db,
|
||||
char *** const sortedPlugins,
|
||||
const char * const ** const sortedPlugins,
|
||||
size_t * const numPlugins);
|
||||
|
||||
/**
|
||||
@@ -555,8 +555,8 @@ extern "C"
|
||||
LOOT_API unsigned int loot_get_masterlist_revision(loot_db db,
|
||||
const char * const masterlistPath,
|
||||
const bool getShortID,
|
||||
char ** const revisionID,
|
||||
char ** const revisionDate,
|
||||
const char ** const revisionID,
|
||||
const char ** const revisionDate,
|
||||
bool * const isModified);
|
||||
|
||||
/**@}*/
|
||||
@@ -585,7 +585,7 @@ extern "C"
|
||||
* @returns A return code.
|
||||
*/
|
||||
LOOT_API unsigned int loot_get_tag_map(loot_db db,
|
||||
char *** const tagMap,
|
||||
const char * const ** const tagMap,
|
||||
size_t * const numTags);
|
||||
|
||||
/**
|
||||
@@ -619,9 +619,9 @@ extern "C"
|
||||
*/
|
||||
LOOT_API unsigned int loot_get_plugin_tags(loot_db db,
|
||||
const char * const plugin,
|
||||
unsigned int ** const tags_added,
|
||||
const unsigned int ** const tags_added,
|
||||
size_t * const numTags_added,
|
||||
unsigned int ** const tags_removed,
|
||||
const unsigned int ** const tags_removed,
|
||||
size_t * const numTags_removed,
|
||||
bool * const userlistModified);
|
||||
|
||||
@@ -643,7 +643,7 @@ extern "C"
|
||||
*/
|
||||
LOOT_API unsigned int loot_get_plugin_messages(loot_db db,
|
||||
const char * const plugin,
|
||||
loot_message ** const messages,
|
||||
const loot_message ** const messages,
|
||||
size_t * const numMessages);
|
||||
|
||||
/**
|
||||
|
||||
+12
-12
@@ -480,7 +480,7 @@ LOOT_API unsigned int loot_eval_lists(loot_db db, const unsigned int language) {
|
||||
////////////////////////////////////
|
||||
|
||||
LOOT_API unsigned int loot_sort_plugins(loot_db db,
|
||||
char *** const sortedPlugins,
|
||||
const char * const ** const sortedPlugins,
|
||||
size_t * const numPlugins) {
|
||||
if (db == nullptr || sortedPlugins == nullptr || numPlugins == nullptr)
|
||||
return c_error(loot_error_invalid_args, "Null pointer passed.");
|
||||
@@ -506,7 +506,7 @@ LOOT_API unsigned int loot_sort_plugins(loot_db db,
|
||||
}
|
||||
|
||||
*numPlugins = db->getPluginNames().size();
|
||||
*sortedPlugins = const_cast<char **>(&db->getPluginNames()[0]);
|
||||
*sortedPlugins = &db->getPluginNames()[0];
|
||||
|
||||
return loot_ok;
|
||||
}
|
||||
@@ -553,8 +553,8 @@ LOOT_API unsigned int loot_update_masterlist(loot_db db,
|
||||
LOOT_API unsigned int loot_get_masterlist_revision(loot_db db,
|
||||
const char * const masterlistPath,
|
||||
const bool getShortID,
|
||||
char ** const revisionID,
|
||||
char ** const revisionDate,
|
||||
const char ** const revisionID,
|
||||
const char ** const revisionDate,
|
||||
bool * const isModified) {
|
||||
if (db == nullptr || masterlistPath == nullptr || revisionID == nullptr || revisionDate == nullptr || isModified == nullptr)
|
||||
return c_error(loot_error_invalid_args, "Null pointer passed.");
|
||||
@@ -588,8 +588,8 @@ LOOT_API unsigned int loot_get_masterlist_revision(loot_db db,
|
||||
return c_error(loot_error_no_mem, e.what());
|
||||
}
|
||||
|
||||
*revisionID = const_cast<char*>(db->getRevisionIdString());
|
||||
*revisionDate = const_cast<char*>(db->getRevisionDateString());
|
||||
*revisionID = db->getRevisionIdString();
|
||||
*revisionDate = db->getRevisionDateString();
|
||||
*isModified = edited;
|
||||
|
||||
return loot_ok;
|
||||
@@ -602,7 +602,7 @@ LOOT_API unsigned int loot_get_masterlist_revision(loot_db db,
|
||||
// Returns an array of the Bash Tags encounterred when loading the masterlist
|
||||
// and userlist, and the number of tags in the returned array. The array and
|
||||
// its contents are static and should not be freed by the client.
|
||||
LOOT_API unsigned int loot_get_tag_map(loot_db db, char *** const tagMap, size_t * const numTags) {
|
||||
LOOT_API unsigned int loot_get_tag_map(loot_db db, const char * const ** const tagMap, size_t * const numTags) {
|
||||
if (db == nullptr || tagMap == nullptr || numTags == nullptr)
|
||||
return c_error(loot_error_invalid_args, "Null pointer passed.");
|
||||
|
||||
@@ -636,7 +636,7 @@ LOOT_API unsigned int loot_get_tag_map(loot_db db, char *** const tagMap, size_t
|
||||
return c_error(loot_error_no_mem, e.what());
|
||||
}
|
||||
|
||||
*tagMap = const_cast<char **>(&db->getBashTagMap()[0]);
|
||||
*tagMap = &db->getBashTagMap()[0];
|
||||
*numTags = db->getBashTagMap().size();
|
||||
|
||||
return loot_ok;
|
||||
@@ -650,9 +650,9 @@ LOOT_API unsigned int loot_get_tag_map(loot_db db, char *** const tagMap, size_t
|
||||
// will be nullptr. The userlistModified bool is true if the userlist contains Bash Tag
|
||||
// suggestion message additions.
|
||||
LOOT_API unsigned int loot_get_plugin_tags(loot_db db, const char * const plugin,
|
||||
unsigned int ** const tagIds_added,
|
||||
const unsigned int ** const tagIds_added,
|
||||
size_t * const numTags_added,
|
||||
unsigned int ** const tagIds_removed,
|
||||
const unsigned int ** const tagIds_removed,
|
||||
size_t * const numTags_removed,
|
||||
bool * const userlistModified) {
|
||||
if (db == nullptr || plugin == nullptr || tagIds_added == nullptr || numTags_added == nullptr || tagIds_removed == nullptr || numTags_removed == nullptr || userlistModified == nullptr)
|
||||
@@ -709,7 +709,7 @@ LOOT_API unsigned int loot_get_plugin_tags(loot_db db, const char * const plugin
|
||||
// loot_destroy_db or loot_get_plugin_messages are next called. plugin is case-insensitive.
|
||||
// If no messages are attached, *messages will be nullptr and numMessages will equal 0.
|
||||
LOOT_API unsigned int loot_get_plugin_messages(loot_db db, const char * const plugin,
|
||||
loot_message ** const messages,
|
||||
const loot_message ** const messages,
|
||||
size_t * const numMessages) {
|
||||
if (db == nullptr || plugin == nullptr || messages == nullptr || numMessages == nullptr)
|
||||
return c_error(loot_error_invalid_args, "Null pointer passed.");
|
||||
@@ -730,7 +730,7 @@ LOOT_API unsigned int loot_get_plugin_messages(loot_db db, const char * const pl
|
||||
|
||||
db->setPluginMessages(pluginMessages);
|
||||
|
||||
*messages = const_cast<loot_message*>(&db->getPluginMessages()[0]);
|
||||
*messages = &db->getPluginMessages()[0];
|
||||
*numMessages = db->getPluginMessages().size();
|
||||
|
||||
return loot_ok;
|
||||
|
||||
@@ -196,8 +196,8 @@ TEST_F(OblivionAPIOperationsTest, UpdateMasterlist) {
|
||||
}
|
||||
|
||||
TEST_F(OblivionAPIOperationsTest, GetMasterlistRevision) {
|
||||
char * revisionID;
|
||||
char * revisionDate;
|
||||
const char * revisionID;
|
||||
const char * revisionDate;
|
||||
bool isModified;
|
||||
EXPECT_EQ(loot_error_invalid_args, loot_get_masterlist_revision(NULL, masterlistPath.string().c_str(), false, &revisionID, &revisionDate, &isModified));
|
||||
EXPECT_EQ(loot_error_invalid_args, loot_get_masterlist_revision(db, NULL, false, &revisionID, &revisionDate, &isModified));
|
||||
@@ -345,7 +345,7 @@ TEST_F(SkyrimAPIOperationsTest, EvalLists) {
|
||||
}
|
||||
|
||||
TEST_F(OblivionAPIOperationsTest, SortPlugins) {
|
||||
char ** sortedPlugins;
|
||||
const char * const * sortedPlugins;
|
||||
size_t numPlugins;
|
||||
EXPECT_EQ(loot_error_invalid_args, loot_sort_plugins(NULL, &sortedPlugins, &numPlugins));
|
||||
EXPECT_EQ(loot_error_invalid_args, loot_sort_plugins(db, NULL, &numPlugins));
|
||||
@@ -376,7 +376,7 @@ TEST_F(OblivionAPIOperationsTest, SortPlugins) {
|
||||
}
|
||||
|
||||
TEST_F(SkyrimAPIOperationsTest, SortPlugins) {
|
||||
char ** sortedPlugins;
|
||||
const char * const * sortedPlugins;
|
||||
size_t numPlugins;
|
||||
EXPECT_EQ(loot_error_invalid_args, loot_sort_plugins(NULL, &sortedPlugins, &numPlugins));
|
||||
EXPECT_EQ(loot_error_invalid_args, loot_sort_plugins(db, NULL, &numPlugins));
|
||||
@@ -449,7 +449,7 @@ TEST_F(SkyrimAPIOperationsTest, ApplyLoadOrder) {
|
||||
}
|
||||
|
||||
TEST_F(OblivionAPIOperationsTest, GetTagMap) {
|
||||
char ** tagMap;
|
||||
const char * const * tagMap;
|
||||
size_t numTags;
|
||||
EXPECT_EQ(loot_error_invalid_args, loot_get_tag_map(NULL, &tagMap, &numTags));
|
||||
EXPECT_EQ(loot_error_invalid_args, loot_get_tag_map(db, NULL, &numTags));
|
||||
@@ -490,8 +490,8 @@ TEST_F(OblivionAPIOperationsTest, GetTagMap) {
|
||||
}
|
||||
|
||||
TEST_F(OblivionAPIOperationsTest, GetPluginTags) {
|
||||
unsigned int * added;
|
||||
unsigned int * removed;
|
||||
const unsigned int * added;
|
||||
const unsigned int * removed;
|
||||
size_t numAdded, numRemoved;
|
||||
bool modified;
|
||||
EXPECT_EQ(loot_error_invalid_args, loot_get_plugin_tags(NULL, "Unofficial Oblivion Patch.esp", &added, &numAdded, &removed, &numRemoved, &modified));
|
||||
@@ -506,7 +506,7 @@ TEST_F(OblivionAPIOperationsTest, GetPluginTags) {
|
||||
EXPECT_EQ(loot_error_no_tag_map, loot_get_plugin_tags(db, "Unofficial Oblivion Patch.esp", &added, &numAdded, &removed, &numRemoved, &modified));
|
||||
|
||||
// Load tag map.
|
||||
char ** tagMap;
|
||||
const char * const * tagMap;
|
||||
size_t numTags;
|
||||
ASSERT_NO_THROW(GenerateMasterlist());
|
||||
ASSERT_EQ(loot_ok, loot_load_lists(db, masterlistPath.string().c_str(), NULL));
|
||||
@@ -554,7 +554,7 @@ TEST_F(OblivionAPIOperationsTest, GetPluginTags) {
|
||||
}
|
||||
|
||||
TEST_F(OblivionAPIOperationsTest, GetPluginMessages) {
|
||||
loot_message * messages;
|
||||
const loot_message * messages;
|
||||
size_t numMessages;
|
||||
EXPECT_EQ(loot_error_invalid_args, loot_get_plugin_messages(NULL, "EnhancedWeatherSIOnly.esm", &messages, &numMessages));
|
||||
EXPECT_EQ(loot_error_invalid_args, loot_get_plugin_messages(db, NULL, &messages, &numMessages));
|
||||
|
||||
Reference in New Issue
Block a user