Skip to content

Commit

Permalink
Add missing static casts
Browse files Browse the repository at this point in the history
  • Loading branch information
kleag committed May 2, 2024
1 parent fd900b2 commit babd2bc
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ int AbstractLexiconIdGeneratorInformer::operator() (
AbstractLexiconIdGeneratorInformer* AbstractLexiconIdGeneratorInformer::theInformer = 0;

AbstractLexiconIdGeneratorInformer* AbstractLexiconIdGeneratorInformer::getInstance() {
if( theInformer == 0 ) {
if( theInformer == nullptr ) {
theInformer = new AbstractLexiconIdGeneratorInformer();
}
return theInformer;
Expand Down
4 changes: 2 additions & 2 deletions lima_common/src/common/MediaticData/EntityType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ bool EntityType::operator<(const EntityType& other) const

bool EntityType::isNull() const
{
return (m_d->m_id==static_cast<EntityTypeId>(0)
&& m_d->m_groupId==static_cast<EntityGroupId>(0));
return (m_d->m_id == static_cast<EntityTypeId>(0)
&& m_d->m_groupId == static_cast<EntityGroupId>(0));
}

EntityTypeId EntityType::getTypeId() const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void BowTextHandler::startAnalysis()
// delete m_writer;
// m_writer=0;
//}
if (m_writer == 0){
if (m_writer == nullptr){
m_writer=new BowTextWriter();
}
m_bowstream=new std::ostringstream();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void BowTextWriter::setOut(std::ostream* out)

void BowTextWriter::endAnalysis()
{
if (m_d->m_out == 0)
if (m_d->m_out == nullptr)
{
BOWLOGINIT;
LERROR << "BowTextWriter Error: output stream is not set !";
Expand All @@ -73,7 +73,7 @@ void BowTextWriter::endDocument()

void BowTextWriter::handle(const char* buf, int length)
{
if (m_d->m_out == 0)
if (m_d->m_out == nullptr)
{
BOWLOGINIT;
LERROR << "BowTextWriter Error: output stream is not set !";
Expand All @@ -86,7 +86,7 @@ void BowTextWriter::startAnalysis()
{
BOWLOGINIT;
LDEBUG << "BowTextWriter::startAnalysis";
if (m_d->m_out == 0)
if (m_d->m_out == nullptr)
{
BOWLOGINIT;
LERROR << "BowTextWriter Error: output stream is not set !";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void StructuredBoWToBoWDocument::
addProperties(BoWDocument& /*document*/,
const GenericDocumentProperties* properties)
{
if (properties == 0 ) {
if (properties == nullptr ) {
return;
}
std::pair<GenericDocumentProperties::IntPropertiesIterator,GenericDocumentProperties::IntPropertiesIterator> intProps=properties->getIntProperties();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void Lima::XmlReader::XmlReaderClientFactory::configureClientFactory(
for(ItrIds = MapMediaFactory.begin(); ItrIds != MapMediaFactory.end(); ItrIds++) {

// on ne cree une factory que si elle n'est pas encore dans la liste
if(factory->getFactoryFromId(ItrIds->second) == 0) {
if(factory->getFactoryFromId(ItrIds->second) == nullptr) {

// Create the processor factory
auto factoryfactory = Lima::AbstractProcessingClientFactoryFactory::getFactory(ItrIds->second);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ LimaStatusCode EasyXmlDumper::process(AnalysisContent& analysis) const
DUMPERLOGINIT;

LinguisticMetaData* metadata = static_cast<LinguisticMetaData*>(analysis.getData("LinguisticMetaData"));
if (metadata == 0) {
if (metadata == nullptr) {
LERROR << "EasyXmlDumper::process no LinguisticMetaData ! abort";
return MISSING_DATA;
}
Expand All @@ -139,22 +139,22 @@ LimaStatusCode EasyXmlDumper::process(AnalysisContent& analysis) const
}

auto graph = std::dynamic_pointer_cast<AnalysisGraph>(analysis.getData(m_graph));
if (graph == 0)
if (graph == nullptr)
{
graph = new AnalysisGraph(m_graph,m_language,true,true);
analysis.setData(m_graph,graph);
}

auto syntacticData = std::dynamic_pointer_cast<SyntacticData>(analysis.getData("SyntacticData"));
if (syntacticData == 0)
if (syntacticData == nullptr)
{
syntacticData = new SyntacticAnalysis::SyntacticData(std::dynamic_pointer_cast<AnalysisGraph>(analysis.getData(m_graph)),0);
syntacticData->setupDependencyGraph();
analysis.setData("SyntacticData",syntacticData);
}

auto annotationData = std::dynamic_pointer_cast< AnnotationData >(analysis.getData("AnnotationData"));
if (annotationData == 0)
if (annotationData == nullptr)
{
annotationData = std::make_shared<AnnotationData>();
if (std::dynamic_pointer_cast<AnalysisGraph>(analysis.getData("AnalysisGraph")) != 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ operator()(const LinguisticAnalysisStructure::AnalysisGraph& graph,
AnalysisContent& /*ac*/ ) const
{
Token* token = get(vertex_token,*(graph.getGraph()),v);
if (token == 0)
if (token == nullptr)
{
AULOGINIT;
LERROR << "Null token on vertex " << v;
Expand Down Expand Up @@ -338,7 +338,7 @@ operator()(const LinguisticAnalysisStructure::AnalysisGraph& graph,
AnalysisContent& /*ac*/ ) const
{
Token* token = get(vertex_token,*(graph.getGraph()),v);
if (token == 0)
if (token == nullptr)
{
AULOGINIT;
LERROR << "Null token on vertex " << v;
Expand Down Expand Up @@ -389,13 +389,13 @@ bool NoSpaceWith::operator()(const LinguisticAnalysisStructure::AnalysisGraph& g
{
Token* token1 = get(vertex_token,*(graph.getGraph()),v1);
Token* token2 = get(vertex_token,*(graph.getGraph()),v2);
if (token1 == 0)
if (token1 == nullptr)
{
AULOGINIT;
LERROR << "Null token on vertex " << v1;
return false;
}
if (token2 == 0)
if (token2 == nullptr)
{
AULOGINIT;
LERROR << "Null token on vertex " << v2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ SpiritTokenizerLoader::SpiritTokenizerLoader(Automaton& automaton, const std::st
State* SpiritTokenizerLoader::stateNamed(const LimaString& name)
{
State* newState = m_automaton.stateNamed(name);
if (newState == 0)
if (newState == nullptr)
{
newState = new State(name, m_automaton);
m_automaton.states().push_back(newState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ LimaString Text::token()
#endif
StringsPoolIndex form=(*m_d->m_stringsPool)[str];
Token *tToken = new Token(form,str,m_d->m_debPtr+1,(delta-m_d->m_debPtr));
if (tToken == 0) throw MemoryErrorException();
if (tToken == nullptr) throw MemoryErrorException();
// @todo: set default status here, according to structured status (alpha,numeric etc...)
// instead of setting it at each change of status (setAlphaCapital, setNumeric etc...)
tToken->setStatus(m_d->m_curSettings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const State* Transition::run(Text& text) const
TOKENIZERLOGINIT;
#endif
const CharClass* currentClass = text.currentClass();
if (currentClass == 0)
if (currentClass == nullptr)
{
TOKENIZERLOGINIT;
LERROR << "Transition::run Null Class for char '"<< limastring2utf8stdstring(LimaString()+text.currentChar()) << "'";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ bool CreateSpecificEntity::operator()(Automaton::RecognizerMatch& match,
// (specific to modex) AddEntityFeature
// WARN : some hard coded stuff here in resource names
EntityType seType=match.getType();
if (seType.getGroupId() == 0)
if (seType.getGroupId() == static_cast<EntityGroupId>(0))
{
SELOGINIT;
LERROR << "CreateSpecificEntity::operator() null group id:" << seType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

using namespace std;
using namespace Lima::Common;
using namespace Lima::Common::MediaticData;
using namespace Lima::LinguisticProcessing::LinguisticAnalysisStructure;

namespace Lima {
Expand Down Expand Up @@ -323,10 +324,10 @@ TransitionUnit* createTransition(const LimaString str,
// entity transition
else if (s.size()>=2 && s[0]==CHAR_BEGIN_ENTITY && s[s.size()-1]==CHAR_END_ENTITY) {
LimaString entityName(s.mid(1,s.size()-2));
Common::MediaticData::EntityType type=resolveEntityName(entityName,activeEntityGroups);
EntityType type=resolveEntityName(entityName,activeEntityGroups);
if (type.isNull()) {
Common::MediaticData::EntityGroupId groupId = resolveGroupName(entityName,activeEntityGroups);
if( groupId == 0) {
EntityGroupId groupId = resolveGroupName(entityName,activeEntityGroups);
if( groupId == static_cast<EntityGroupId>(0)) {
AUCLOGINIT;
LERROR << "createTransition: cannot resolve entity name "
<< Common::Misc::limastring2utf8stdstring(s);
Expand Down Expand Up @@ -371,7 +372,7 @@ TransitionUnit* createTransition(const LimaString str,

//**********************************************************************
//
Common::MediaticData::EntityGroupId
EntityGroupId
resolveGroupName(const LimaString s,
const std::vector<LimaString>& activeEntityGroups)
{
Expand All @@ -380,11 +381,12 @@ resolveGroupName(const LimaString s,
LDEBUG << "resolveGroupName: try to resolve group name "
<< Common::Misc::limastring2utf8stdstring(s);
#endif
Common::MediaticData::EntityGroupId foundGroup;
EntityGroupId foundGroup;
try {
LimaString groupName=s;
#ifdef DEBUG_LP
LDEBUG << "resolveGroupName: try group name " << Common::Misc::limastring2utf8stdstring(s);
LDEBUG << "resolveGroupName: try group name "
<< Common::Misc::limastring2utf8stdstring(s);
#endif
foundGroup = Common::MediaticData::MediaticData::single().getEntityGroupId(groupName);
// group is among active groups
Expand Down
2 changes: 1 addition & 1 deletion lima_pelf/resourceTool/ResourceEditorTableWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void ResourceEditorTableWidget::editEntry (const QModelIndex& index)
{
ResourceEditorTableModel* retm = dynamic_cast<ResourceEditorTableModel*>(resourceModel);
AbstractResourceEntry* entry = retm->getFoundEntry(index.row());
if(entry == 0)
if(entry == nullptr)
return;
retm->dataModified = true;
Q_EMIT editEntryDlg(entry);
Expand Down
2 changes: 1 addition & 1 deletion lima_pelf/resourceTool/ResourceReaderTableModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ QVariant ResourceReaderTableModel::data (const QModelIndex& index, int role) con
return QVariant();
int column = index.column();
AbstractResourceEntry* entry = getFoundEntry(index.row());
if(entry == 0)
if(entry == nullptr)
return QVariant();
return QVariant(entry->getColumnData(column));
}
Expand Down

0 comments on commit babd2bc

Please sign in to comment.