Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format code using clang-format==18.3.1 #2214

Merged
merged 5 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/analyzer/atsp/load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ bool ATSP::loadFromINIFile(const String& filename)
if (section->name == ".general")
{
IniFile::Property* p = section->firstProperty;
for (; p ; p = p->next)
for (; p; p = p->next)
{
key = p->key;
key.toLower();
Expand Down
2 changes: 1 addition & 1 deletion src/format-code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if [ $# -eq 0 ]
then
# No arguments: format all
SOURCE_DIRS="analyzer/ libs/ solver/ tools/ config/ tests/ packaging/"
SOURCE_FILES=$(find $SOURCE_DIRS -regextype egrep -regex ".*/*\.(c|cxx|cpp|cc|h|hxx|hpp)$")
SOURCE_FILES=$(find $SOURCE_DIRS -regextype egrep -regex ".*/*\.(c|cxx|cpp|cc|h|hxx|hpp)$" ! -path '*/antlr-interface/*')
else
# Format files provided as arguments
SOURCE_FILES="$@"
Expand Down
9 changes: 8 additions & 1 deletion src/libs/antares/args/args_to_utf8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,14 @@ std::pair<int, char**> IntoUTF8ArgsTranslator::convert()
for (int i = 0; i != argc_; ++i)
{
const uint len = (uint)wcslen(wargv[i]);
const uint newLen = WideCharToMultiByte(CP_UTF8, 0, wargv[i], len, nullptr, 0, nullptr, nullptr);
const uint newLen = WideCharToMultiByte(CP_UTF8,
0,
wargv[i],
len,
nullptr,
0,
nullptr,
nullptr);
argv_[i] = (char*)malloc((newLen + 1) * sizeof(char));
memset(argv_[i], 0, (newLen + 1) * sizeof(char));
WideCharToMultiByte(CP_UTF8, 0, wargv[i], len, argv_[i], newLen, nullptr, nullptr);
Expand Down
8 changes: 3 additions & 5 deletions src/libs/antares/array/include/antares/array/matrix.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -1044,8 +1044,6 @@ bool Matrix<T, ReadWriteT>::internalLoadCSVFile(const AnyString& filename,
uint options,
BufferType* buffer)
{
using namespace Yuni;

// Status
bool result = false;

Expand All @@ -1057,7 +1055,7 @@ bool Matrix<T, ReadWriteT>::internalLoadCSVFile(const AnyString& filename,

switch (loadFromFileToBuffer(*buffer, filename))
{
case IO::errNone:
case Yuni::IO::errNone:
{
// Empty files
if (buffer->empty())
Expand Down Expand Up @@ -1098,15 +1096,15 @@ bool Matrix<T, ReadWriteT>::internalLoadCSVFile(const AnyString& filename,
}
break;
}
case IO::errNotFound:
case Yuni::IO::errNotFound:
{
if (not(options & optQuiet))
{
logs.error() << "I/O Error: not found: '" << filename << "'";
}
break;
}
case IO::errMemoryLimit:
case Yuni::IO::errMemoryLimit:
{
if (not(options & optQuiet))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ void checkOrtoolsUsage(Antares::Data::UnitCommitmentMode ucMode,
bool ortoolsUsed,
const std::string& solverName);


void checkStudyVersion(const AnyString& optStudyFolder);

void checkSimplexRangeHydroPricing(Antares::Data::SimplexOptimization optRange,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,14 @@ class InvalidSolver: public LoadingError
explicit InvalidSolver(const std::string& solver, const std::string& availableSolverList);
};

class InvalidSolverSpecificParameters : public LoadingError
class InvalidSolverSpecificParameters: public LoadingError
{
public:
explicit InvalidSolverSpecificParameters(const std::string& solver, const std::string& specificParameters);
explicit InvalidSolverSpecificParameters(const std::string& solver,
const std::string& specificParameters);
};

class InvalidStudy : public LoadingError
class InvalidStudy: public LoadingError
{
public:
explicit InvalidStudy(const Yuni::String& study);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace Data
{
class Study;
}

/**
* @class FileTreeStudyLoader
* @brief A class to load studies from the file tree.
Expand Down
3 changes: 2 additions & 1 deletion src/libs/antares/inifile/include/antares/inifile/inifile.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ inline bool IniFile::empty() const
return not firstSection;
}

inline IniFile::Section::Section(const AnyString& name): name(name)
inline IniFile::Section::Section(const AnyString& name):
name(name)
{
}

Expand Down
12 changes: 5 additions & 7 deletions src/libs/antares/inifile/inifile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ void IniFile::Section::saveToStream(std::ostream& stream_out, uint64_t& written)
stream_out << '[' << name << "]\n";
written += 4 /* []\n\n */ + name.size();

each([&stream_out, &written](const IniFile::Property& p) {
p.saveToStream(stream_out, written);
});
each([&stream_out, &written](const IniFile::Property& p)
{ p.saveToStream(stream_out, written); });

stream_out << '\n';
}
Expand Down Expand Up @@ -249,7 +248,7 @@ bool IniFile::open(const fs::path& filename, bool warnings)

if (std::ifstream file(filename); file.is_open())
{
if (! readStream(file))
if (!readStream(file))
{
logs.error() << "Invalid INI file : " << filename;
return false;
Expand All @@ -266,9 +265,8 @@ bool IniFile::open(const fs::path& filename, bool warnings)

void IniFile::saveToStream(std::ostream& stream_out, uint64_t& written) const
{
each([&stream_out, &written](const IniFile::Section& s) {
s.saveToStream(stream_out, written);
});
each([&stream_out, &written](const IniFile::Section& s)
{ s.saveToStream(stream_out, written); });

if (written != 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/libs/antares/io/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@

#ifdef YUNI_OS_WINDOWS
#include <io.h>

#include <yuni/core/system/windows.hdr.h>
#else
#include <sys/types.h>
#include <unistd.h>
#endif
#include <errno.h>

#include <fstream>

#include <antares/logs/logs.h>
Expand Down
4 changes: 2 additions & 2 deletions src/libs/antares/io/include/antares/io/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
#ifndef __LIBS_ANTARES_IO_FILE_H__
#define __LIBS_ANTARES_IO_FILE_H__

#include <yuni/core/string.h>

#include <filesystem>

#include <yuni/core/string.h>

namespace Antares::IO
{
/*!
Expand Down
2 changes: 1 addition & 1 deletion src/libs/antares/locale/locale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void InitializeDefaultLocale()
}

#else
if (! std::setlocale(LC_ALL, "en_US.utf8"))
if (!std::setlocale(LC_ALL, "en_US.utf8"))
{
std::cerr << "impossible to set locale to en_US.utf8" << std::endl;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace Data
{
class Study;
}

/**
* @class IStudyLoader
* @brief The IStudyLoader class is an interface for loading studies.
Expand Down
7 changes: 4 additions & 3 deletions src/libs/antares/study/area/area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,20 @@ Area::Area():
internalInitialize();
}

Area::Area(const AnyString& name) : Area()
Area::Area(const AnyString& name):
Area()
{
internalInitialize();
this->name = name;
this->id = Antares::transformNameIntoID(this->name);
}

Area::Area(const AnyString& name, const AnyString& id) : Area()
Area::Area(const AnyString& name, const AnyString& id):
Area()
{
internalInitialize();
this->name = name;
this->id = Antares::transformNameIntoID(id);

}

Area::~Area()
Expand Down
12 changes: 8 additions & 4 deletions src/libs/antares/study/area/links.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

#include "antares/study/area/links.h"

#include <array>
#include <filesystem>
#include <limits>
#include <array>

#include <antares/exception/LoadingError.hpp>
#include <antares/logs/logs.h>
Expand Down Expand Up @@ -308,9 +308,13 @@ namespace // anonymous

bool isPropertyUsedForLinkTSgeneration(const std::string& key)
{
std::array<std::string, 7> listKeys
= {"unitcount", "nominalcapacity", "law.planned", "law.forced",
"volatility.planned", "volatility.forced", "force-no-generation"};
std::array<std::string, 7> listKeys = {"unitcount",
"nominalcapacity",
"law.planned",
"law.forced",
"volatility.planned",
"volatility.forced",
"force-no-generation"};
return std::find(listKeys.begin(), listKeys.end(), key) != listKeys.end();
}

Expand Down
21 changes: 12 additions & 9 deletions src/libs/antares/study/area/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,8 +968,9 @@ static bool AreaListLoadFromFolderSingleArea(Study& study,
ret = hydroSeries->LoadMaxPower(area.id, buffer) && ret;
}

hydroSeries->resizeTSinDeratedMode(
study.parameters.derated, studyVersion, study.usedByTheSolver);
hydroSeries->resizeTSinDeratedMode(study.parameters.derated,
studyVersion,
study.usedByTheSolver);
}

// Wind
Expand Down Expand Up @@ -1278,7 +1279,7 @@ Area* AreaList::findFromPosition(const int x, const int y) const
{
auto lastArea = i->second;
if (lastArea->ui && std::abs(lastArea->ui->x - x) < nearestDistance
&& std::abs(lastArea->ui->y - y) < nearestDistance)
&& std::abs(lastArea->ui->y - y) < nearestDistance)
{
nearestItem = lastArea;
}
Expand Down Expand Up @@ -1326,12 +1327,14 @@ void AreaListEnsureDataLoadPrepro(AreaList* l)
/* Asserts */
assert(l);

l->each([](Data::Area& area) {
if (!area.load.prepro)
{
area.load.prepro = new Antares::Data::Load::Prepro();
}
});
l->each(
[](Data::Area& area)
{
if (!area.load.prepro)
{
area.load.prepro = new Antares::Data::Load::Prepro();
}
});
}

void AreaListEnsureDataSolarPrepro(AreaList* l)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,18 @@ bool BindingConstraintGroupRepository::buildFrom(const BindingConstraintsReposit

bool BindingConstraintGroupRepository::timeSeriesWidthConsistentInGroups() const
{
bool allConsistent = !std::ranges::any_of(groups_, [](const auto& group)
bool allConsistent = !std::ranges::any_of(
groups_,
[](const auto& group)
{
const auto& constraints = group->constraints();
if (constraints.empty())
{
return false;
}
auto width = (*constraints.begin())->RHSTimeSeries().width;
bool isConsistent = std::ranges::all_of(constraints,
bool isConsistent = std::ranges::all_of(
constraints,
[&width](const std::shared_ptr<BindingConstraint>& bc)
{
bool sameWidth = bc->RHSTimeSeries().width == width;
Expand All @@ -89,15 +92,16 @@ bool BindingConstraintGroupRepository::timeSeriesWidthConsistentInGroups() const

void BindingConstraintGroupRepository::resizeAllTimeseriesNumbers(unsigned int nb_years)
{
std::ranges::for_each(groups_, [&nb_years](auto& group)
{ group->timeseriesNumbers.reset(nb_years); });
std::ranges::for_each(groups_,
[&nb_years](auto& group) { group->timeseriesNumbers.reset(nb_years); });
}

BindingConstraintGroup* BindingConstraintGroupRepository::operator[](const std::string& name) const
{
if (auto group = std::ranges::find_if(groups_, [&name](auto& group_of_constraint)
{ return group_of_constraint->name() == name; });
group != groups_.end())
if (auto group = std::ranges::find_if(groups_,
[&name](auto& group_of_constraint)
{ return group_of_constraint->name() == name; });
group != groups_.end())
{
return group->get();
}
Expand Down
1 change: 0 additions & 1 deletion src/libs/antares/study/cleaner/cleaner-v20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ bool listOfFilesAnDirectoriesToKeep(StudyCleaningInfos* infos)
buffer.clear() << infos->folder << "/input/bindingconstraints/bindingconstraints.ini";
if (ini.open(buffer))
{

ini.each(
[&e](const IniFile::Section& section)
{
Expand Down
6 changes: 2 additions & 4 deletions src/libs/antares/study/include/antares/study/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ class Parameters final
** \param version Current study version
** \return True if the settings have been loaded, false if at least one error has occured
*/
bool loadFromFile(const AnyString& filename,
const StudyVersion& version);
bool loadFromFile(const AnyString& filename, const StudyVersion& version);

/*!
** \brief Prepare all settings for a simulation
Expand Down Expand Up @@ -501,8 +500,7 @@ class Parameters final

private:
//! Load data from an INI file
bool loadFromINI(const IniFile& ini,
const StudyVersion& version);
bool loadFromINI(const IniFile& ini, const StudyVersion& version);

void resetPlayedYears(uint nbOfYears);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#define __ANTARES_LIBS_STUDY_PARTS_HYDRO_CONTAINER_H__

#include <optional>

#include "../../fwd.h"
#include "allocation.h"
#include "prepro.h"
Expand All @@ -30,7 +31,7 @@
namespace Antares::Data
{

//! The maximum number of days in a year
//! The maximum number of days in a year
constexpr size_t dayYearCount = 366;

struct DailyDemand
Expand Down Expand Up @@ -233,9 +234,7 @@ class PartHydro
// As this function can be called a lot of times, we pass working variables and returned variables
// as arguments, so that we don't have to create them locally (as in a classical function) each
// time.
double getWaterValue(const double& level,
const Matrix<double>& waterValues,
const uint day);
double getWaterValue(const double& level, const Matrix<double>& waterValues, const uint day);

// Interpolates a rate from the credit modulation table according to a level
double getWeeklyModulation(const double& level /* format : in % of reservoir capacity */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
#ifndef __LIBS_STUDY_SCENARIO_BUILDER_DATA_HYDRO_LEVELS_H__
#define __LIBS_STUDY_SCENARIO_BUILDER_DATA_HYDRO_LEVELS_H__

#include "scBuilderDataInterface.h"
#include <functional>

#include "scBuilderDataInterface.h"

namespace Antares
{
namespace Data
Expand Down
Loading
Loading