Ansariel 2025-06-23 22:39:59 +02:00
commit de0cffb57f
7 changed files with 57 additions and 29 deletions

View File

@ -46,6 +46,8 @@
#include <map>
#include <set>
#include <boost/range.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
// <FS:ND> Suppress warnings about the string fiddling
#if LL_LINUX
@ -205,6 +207,39 @@ std::string ll_stream_notation_sd(const LLSD& sd)
return stream.str();
}
// <FS:Ansariel> Create LLSD from CSV
LLSD ll_sd_from_csv(std::istream& csv, std::string_view delimiters)
{
LLSD data;
bool headerRead{ false };
std::vector<std::string> columnNames;
std::string line;
while (std::getline(csv, line))
{
std::vector<std::string> columns;
boost::split(columns, line, boost::is_any_of(delimiters));
if (!headerRead)
{
headerRead = true;
columnNames = std::move(columns);
}
else
{
LLSD rowData;
for (size_t i = 0; i < columnNames.size() && i < columns.size(); ++i)
{
rowData[columnNames.at(i)] = columns.at(i);
}
data.append(rowData);
}
}
return data;
}
// </FS:Ansariel>
//compares the structure of an LLSD to a template LLSD and stores the
//"valid" values in a 3rd LLSD. Default values pulled from the template

View File

@ -65,6 +65,9 @@ LL_COMMON_API char* ll_pretty_print_sd(const LLSD& sd);
LL_COMMON_API std::string ll_stream_notation_sd(const LLSD& sd);
// <FS:Ansariel> Create LLSD from CSV
LL_COMMON_API LLSD ll_sd_from_csv(std::istream& csv, std::string_view delimiters = ",");
//compares the structure of an LLSD to a template LLSD and stores the
//"valid" values in a 3rd LLSD. Default values
//are pulled from the template. Extra keys/values in the test

View File

@ -431,7 +431,7 @@ bool LLScrollListCtrl::setMaxItemCount(S32 max_count)
}
// <FS:PP>
S32 LLScrollListCtrl::getMaxItemCount()
S32 LLScrollListCtrl::getMaxItemCount() const
{
return mMaxItemCount;
}

View File

@ -213,7 +213,7 @@ public:
// returns false if unable to set the max count so low
bool setMaxItemCount(S32 max_count);
S32 getMaxItemCount(); // <FS:PP>
S32 getMaxItemCount() const; // <FS:PP>
bool selectByID( const LLUUID& id ); // false if item not found

View File

@ -77,7 +77,7 @@ LLSD FSAssetBlacklistData::toLLSD() const
data["asset_region"] = region;
data["asset_type"] = type;
data["asset_blacklist_flag"] = flags;
data["asset_date"] = date;
data["asset_date"] = input_date;
data["asset_permanent"] = permanent;
return data;

View File

@ -3395,24 +3395,19 @@ void LLPanelLandAccess::importListCallback(LLNameListCtrl* list, const std::vect
return;
}
std::string line;
std::vector<LLUUID> uuids;
uuid_vec_t uuids;
LLSD csvData = ll_sd_from_csv(file);
file.close();
while (std::getline(file, line))
for (const auto& entry : llsd::inArray(csvData))
{
LLStringUtil::trim(line);
if (line.empty())
if (entry.has("UUID"))
{
continue;
}
LLUUID uuid;
if (uuid.set(line))
{
uuids.push_back(uuid);
LLUUID id{ entry["UUID"].asUUID() };
if (id.notNull())
uuids.push_back(std::move(id));
}
}
file.close();
if (uuids.empty())
{

View File

@ -4767,24 +4767,19 @@ void LLPanelEstateAccess::importListCallback(LLNameListCtrl* list, const std::ve
return;
}
std::string line;
std::vector<LLUUID> uuids;
uuid_vec_t uuids;
LLSD csvData = ll_sd_from_csv(file);
file.close();
while (std::getline(file, line))
for (const auto& entry : llsd::inArray(csvData))
{
LLStringUtil::trim(line);
if (line.empty())
if (entry.has("UUID"))
{
continue;
}
LLUUID uuid;
if (uuid.set(line))
{
uuids.push_back(uuid);
LLUUID id{ entry["UUID"].asUUID() };
if (id.notNull())
uuids.push_back(std::move(id));
}
}
file.close();
if (uuids.empty())
{