Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:47:03

0001 #ifndef PASSWORDREADER_H
0002 #define PASSWORDREADER_H
0003 
0004 #include <string>
0005 
0006 class PasswordReader {
0007 public:
0008   /** Read data password from a local file. File can contain password for
0009    * several user. The format is one record by line. Line must start with the
0010    * user login followed by the password. Login and password can be separated by
0011    * space(s), tab(s), a colon or a slash.
0012    * @param fileName file with password list
0013    * @param login of user to look for
0014    * @param password [out] password read from the file
0015    * @throw cms::Exception if file cannot be read or if the password was not
0016    * found
0017    */
0018   void readPassword(const std::string& fileName, const std::string& user, std::string& password);
0019 
0020   /** Function to split a string into tokens. Usage:
0021    * <pre>
0022    * int pos = 0;
0023    * string tok;
0024    * const string s = .....;     //string to tokenize
0025    * const string delim = " \t"; //list of token delimiters
0026    * while((tok = tokenize(s, delim, pos))!=string::npos){
0027    *   .... code using tok ...
0028    * }
0029    * </pre>
0030    * @param s string to tokenize
0031    * @param list of delimiters
0032    * @param [in,out] pos current scan position in the string
0033    */
0034   std::string tokenize(const std::string& s, const std::string& delim, size_t& pos) const;
0035 
0036   /** Trims unwanted characters (e.g. spaces) at start and end of a string.
0037    * @param s [in,out] input string
0038    * @param chars set of characters to trim
0039    */
0040   std::string trim(const std::string& s, const std::string& chars) const;
0041 };
0042 
0043 #endif  //PASSWORDREADER_H not defined