diff options
author | lloyd <[email protected]> | 2009-07-16 15:07:59 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-07-16 15:07:59 +0000 |
commit | bd58db8eb1384fe26222d021325382f57f178cc7 (patch) | |
tree | b54713202d613e88407279e5319a97126e894d2a /src/libstate/scan_name.h | |
parent | 1172c616fa849af893c1935b8b1dee085f8aaac8 (diff) |
Move some files around to break up dependencies between directories
Diffstat (limited to 'src/libstate/scan_name.h')
-rw-r--r-- | src/libstate/scan_name.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/src/libstate/scan_name.h b/src/libstate/scan_name.h new file mode 100644 index 000000000..9e7af40d6 --- /dev/null +++ b/src/libstate/scan_name.h @@ -0,0 +1,77 @@ +/** +SCAN Name Abstraction +(C) 2008 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_SCAN_NAME_H__ +#define BOTAN_SCAN_NAME_H__ + +#include <botan/types.h> +#include <string> +#include <vector> +#include <set> + +namespace Botan { + +/** +A class encapsulating a SCAN name (similar to JCE conventions) +http://www.users.zetnet.co.uk/hopwood/crypto/scan/ +*/ +class SCAN_Name + { + public: + /** + @param algo_spec A SCAN name + */ + SCAN_Name(const std::string& algo_spec); + + /** + @return the original input string + */ + std::string as_string() const { return orig_algo_spec; } + + /** + @return the algorithm name + */ + std::string algo_name() const { return name[0]; } + + /** + @return the number of arguments + */ + u32bit arg_count() const { return name.size() - 1; } + + /** + @return if the number of arguments is between lower and upper + */ + bool arg_count_between(u32bit lower, u32bit upper) const + { return ((arg_count() >= lower) && (arg_count() <= upper)); } + + /** + @param i which argument + @return the ith argument + */ + std::string arg(u32bit i) const; + + /** + @param i which argument + @param def_value the default value + @return the ith argument or the default value + */ + std::string arg(u32bit i, const std::string& def_value) const; + + /** + @param i which argument + @param def_value the default value + @return the ith argument as a u32bit, or the default value + */ + u32bit arg_as_u32bit(u32bit i, u32bit def_value) const; + private: + std::string orig_algo_spec; + std::vector<std::string> name; + }; + +} + +#endif |