polserver/pol-core/bscript/compiler/model/ScopeName.cpp
turleypol da2943acb8
Tidy copy initialization (#859)
* trigger tidy

* copy&move BApplicPtr obj
always commit tidy changes

* move PolObject

* fix house add_component

* Automated clang-tidy change: performance-unnecessary-copy-initialization,performance-unnecessary-value-param

* Revert "Automated clang-tidy change: performance-unnecessary-copy-initialization,performance-unnecessary-value-param"

This reverts commit bb6aab13dbdfa4aaf420cdaafaf22940f241fc5b.

* performance-unnecessary-value-param gives some weird suggestions

* Automated clang-tidy change: performance-unnecessary-copy-initialization

* minor performance improvements

* added used tidy check

* missing dependency

* renamed build so its no longer requires?

* better add docs for the sneaky fix

* silence pr check, not all headers can be compiled seperatly

---------

Co-authored-by: Clang Tidy <clang-tidy@users.noreply.github.com>
2026-01-19 08:17:28 +01:00

51 lines
1.1 KiB
C++

#include "ScopeName.h"
#include "clib/clib.h"
#include "clib/strutil.h"
namespace Pol::Bscript::Compiler
{
ScopeName ScopeName::Global = ScopeName( "" );
ScopeName ScopeName::None = ScopeName();
ScopeName ScopeName::Super = ScopeName( Compiler::SUPER );
ScopeName::ScopeName( std::string name ) : std::optional<std::string>( std::move( name ) ) {}
ScopeName::ScopeName() : std::optional<std::string>( std::nullopt ) {}
bool ScopeName::global() const
{
return empty() || value().empty();
}
bool ScopeName::super() const
{
return has_value() && Clib::caseInsensitiveEqual( value(), ScopeName::Super.value() );
}
bool ScopeName::empty() const
{
return !has_value();
}
std::string ScopeName::string() const
{
return value_or( "" );
}
bool ScopeName::operator<( const ScopeName& other ) const
{
if ( !has_value() && !other.has_value() )
{
return false;
}
if ( !has_value() && other.has_value() )
{
return true;
}
if ( has_value() && !other.has_value() )
{
return false;
}
return stricmp( value().c_str(), other.value().c_str() ) < 0;
}
} // namespace Pol::Bscript::Compiler