mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-02 02:44:15 +00:00
Missing files
This commit is contained in:
parent
fb16e50c4d
commit
3b3f5d0188
45
util.cpp
Normal file
45
util.cpp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
namespace i2p
|
||||||
|
{
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
std::map<std::string, std::string> mapArgs;
|
||||||
|
|
||||||
|
void ParseArguments(int argc, const char* const argv[])
|
||||||
|
{
|
||||||
|
mapArgs.clear();
|
||||||
|
for (int i = 1; i < argc; i++)
|
||||||
|
{
|
||||||
|
std::string strKey (argv[i]);
|
||||||
|
std::string strValue;
|
||||||
|
size_t has_data = strKey.find('=');
|
||||||
|
if (has_data != std::string::npos)
|
||||||
|
{
|
||||||
|
strValue = strKey.substr(has_data+1);
|
||||||
|
strKey = strKey.substr(0, has_data);
|
||||||
|
}
|
||||||
|
if (strKey[0] != '-')
|
||||||
|
break;
|
||||||
|
|
||||||
|
mapArgs[strKey] = strValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetIntArg(const std::string& strArg, int nDefault)
|
||||||
|
{
|
||||||
|
if (mapArgs.count(strArg))
|
||||||
|
return atoi(mapArgs[strArg].c_str());
|
||||||
|
return nDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetStringArg(const std::string& strArg, std::string nDefault)
|
||||||
|
{
|
||||||
|
if (mapArgs.count(strArg))
|
||||||
|
return mapArgs[strArg];
|
||||||
|
return nDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace end
|
||||||
|
}
|
19
util.h
Normal file
19
util.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#ifndef UTIL_H
|
||||||
|
#define UTIL_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace i2p
|
||||||
|
{
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
extern std::map<std::string, std::string> mapArgs;
|
||||||
|
void ParseArguments(int argc, const char* const argv[]);
|
||||||
|
int GetIntArg(const std::string& strArg, int nDefault);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user