13 #include "../bscript/bstruct.h" 14 #include "../bscript/impstr.h" 15 #include "../clib/cfgelem.h" 16 #include "../clib/cfgfile.h" 17 #include "../clib/clib.h" 18 #include "../clib/dirlist.h" 19 #include "../clib/fileutil.h" 20 #include "../clib/stlutil.h" 21 #include "../clib/strutil.h" 22 #include "../plib/pkg.h" 23 #include "../plib/systemstate.h" 30 :
name( elem.rest() ), cmdlevel( static_cast<unsigned char>( cmdlevelnum ) )
50 for ( Aliases::const_iterator itr =
aliases.begin(); itr !=
aliases.end(); ++itr )
68 size_t size =
name.capacity() +
sizeof(
unsigned char );
75 size += 3 *
sizeof( std::string* );
76 for (
const auto& ele :
aliases )
78 size += ele.capacity();
88 if ( stricmp( name, cmdlvl.name.c_str() ) == 0 )
98 if ( cmdlvl.matches( str ) )
113 for (
unsigned diridx = 0; diridx < cmdlevel.
searchlist.size(); ++diridx )
117 std::string dir_name = search_dir->
dir;
118 if ( ( !pkg && m_pkg ) || ( pkg && !m_pkg ) )
124 dir_name = std::string( pkg->
dir().c_str() ) + dir_name;
129 std::string
name = dl.name(), ext;
130 if ( name[0] ==
'.' )
133 std::string::size_type pos = name.rfind(
'.' );
134 if ( pos != std::string::npos )
135 ext = name.substr( pos );
137 if ( pos != std::string::npos && ( !ext.compare(
".ecl" ) ) )
142 script_names->addElement( cmdinfo.release() );
146 if ( script_names->ref_arr.size() > 0 )
147 return script_names.release();
157 while ( cf.
read( elem ) )
169 while ( cf.
read( elem ) )
174 elem.
throw_error( std::string(
"Command Level " ) + elem.
rest() +
" not found." );
192 std::string dir, part;
195 part =
"textcmd/" + cmdlevel.
name +
"/";
196 dir = pkg->
dir() + part;
200 part =
"commands/" + cmdlevel.
name +
"/";
201 dir = pkg->
dir() + part;
206 for ( CmdLevel::Aliases::iterator itr = cmdlevel.
aliases.begin(); itr != cmdlevel.
aliases.end();
209 part =
"textcmd/" + *itr +
"/";
210 dir = pkg->
dir() + part;
214 part =
"commands/" + *itr +
"/";
215 dir = pkg->
dir() + part;
Bscript::ObjArray * GetCommandsInPackage(Plib::Package *m_pkg, int cmdlvl_num)
bool matches(const std::string &name) const
void process_package_cmds_cfg(Plib::Package *pkg)
void add_searchdir_front(Plib::Package *pkg, const std::string &dir)
size_t estimateSize() const
const char * rest() const
POL_NORETURN void throw_error(const std::string &errmsg) const
void add_searchdir(Plib::Package *pkg, const std::string &dir)
bool remove_prop(const char *propname, std::string *value)
int stringicmp(const S1 &str1, const S2 &str2)
void implicit_package_cmds_cfg(Plib::Package *pkg)
CmdLevel * find_cmdlevel(const char *name)
std::string GetPackageCfgPath(const Package *pkg, const std::string &filename)
void load_package_cmdlevels()
void mklower(std::string &str)
std::string normalized_dir_form(const std::string &istr)
bool FileExists(const char *filename)
bool read(ConfigElem &elem)
CmdLevel(Clib::ConfigElem &elem, int cmdlevelnum)
const std::string & dir() const
CmdLevel * FindCmdLevelByAlias(const std::string &str)