⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 asn1.h

📁 asn格式文件的编译器
💻 H
📖 第 1 页 / 共 5 页
字号:
	bool isValid() const { return size() >= (unsigned)getLowerLimit() && (getConstraintType() != FixedConstraint || size() <= getUpperLimit());} 	bool isStrictlyValid() const { return size() >= (unsigned)getLowerLimit() && size() <= getUpperLimit();}    OCTET_STRING * clone() const { return static_cast<OCTET_STRING*>(do_clone());}    static AbstractData* create(const void* info);	void swap(OCTET_STRING& other) { ContainerType::swap(other); }    operator std::string () const { return std::string(begin(), end()); }   ASN1_EXPORT static const InfoType theInfo;	static bool equal_type(const ASN1::AbstractData& type)	{return type.info() == reinterpret_cast<const ASN1::AbstractData::InfoType*>(&theInfo);}  private:	virtual int do_compare(const AbstractData& other) const;	virtual AbstractData* do_clone() const ;	virtual bool do_accept(Visitor&);	virtual bool do_accept(ConstVisitor&) const;};template <class Constraint>class Constrained_OCTET_STRING : public OCTET_STRING{        typedef OCTET_STRING Inherited;  protected:        typedef Inherited::InfoType InfoType;  public:	Constrained_OCTET_STRING(const void* info = &theInfo): OCTET_STRING(info)	{}	Constrained_OCTET_STRING(size_type n, char v) : OCTET_STRING(n, v, &theInfo)	{ }	template <class Itr>		Constrained_OCTET_STRING(Itr first, Itr last) :         OCTET_STRING(&theInfo)	{ assign(first, last); }	Constrained_OCTET_STRING(const std::vector<char>& other) : OCTET_STRING(other, &theInfo) {}   // Constrained_OCTET_STRING(const Constrained_OCTET_STRING & other) ;	Constrained_OCTET_STRING & operator = (const std::vector<char>& other) {		assign(other.begin(), other.end());		return *this;	}    Constrained_OCTET_STRING & operator=(const std::string & str) {		assign((const char*)(str.begin()), (const char*)(str.end()));		return *this;	}    Constrained_OCTET_STRING & operator=(const char* str) {        assign(str, str+strlen(str));         return *this;    }    Constrained_OCTET_STRING * clone() const { return static_cast<Constrained_OCTET_STRING*>(OCTET_STRING::clone());}    static AbstractData* create();	void swap(Constrained_OCTET_STRING& other) { OCTET_STRING::swap(other); }    static const InfoType theInfo;	static bool equal_type(const ASN1::AbstractData& type)	{return type.info() == reinterpret_cast<const ASN1::AbstractData::InfoType*>(&theInfo);}};template <class Constraint>const typename Constrained_OCTET_STRING<Constraint>::InfoType Constrained_OCTET_STRING<Constraint>::theInfo = {    OCTET_STRING::create,    4,    Constraint::constraint_type,    Constraint::lower_bound,    Constraint::upper_bound};/** Base class for ASN String types.*/class AbstractString : public ConstrainedObject, public std::string, public detail::Allocator<AbstractString>{protected:	typedef std::string base_string;public:	AbstractString(const AbstractString& other);	typedef base_string::value_type value_type;	typedef base_string::size_type size_type;	typedef base_string::difference_type difference_type;	typedef base_string::reference reference;	typedef base_string::const_reference const_reference;	AbstractString& operator=(const char * str) { assign(str);  return *this;} 	AbstractString& operator=(const std::string & str) { assign(str);  return *this;} 	AbstractString& operator=(char c) { assign(1, c); return *this;} 	AbstractString& operator+=(const std::string& rhs) { append(rhs);  return *this;}	AbstractString& operator+=(const char *s) { append(s);  return *this;}	AbstractString& operator+=(char c) { append(1, c);  return *this;}	AbstractString& append(const std::string& str) { base_string::append(str); return *this;}	AbstractString& append(const std::string& str, size_type pos, size_type n) { base_string::append(str,pos, n); return *this;}	AbstractString& append(const char *s, size_type n) { base_string::append(s,n); return *this;}	AbstractString& append(const char *s) { base_string::append(s); return *this;}	AbstractString& append(size_type n, char c) { base_string::append(n,c); return *this;}	AbstractString& append(const_iterator first, const_iterator last) { base_string::append(first, last); return *this;}	AbstractString& assign(const base_string& str) { base_string::assign(str); return *this;}	AbstractString& assign(const base_string& str,size_type pos, size_type n) { base_string::assign(str,pos,n); return *this;}	AbstractString& assign(const char *s, size_type n) { base_string::assign(s,n); return *this;}	AbstractString& assign(const char *s) { base_string::assign(s); return *this;}	AbstractString& assign(size_type n, char c) { base_string::assign(n,c); return *this;}	AbstractString& assign(const_iterator first, const_iterator last) { base_string::assign(first,last); return *this;}	AbstractString& insert(size_type p0, const base_string& str) { base_string::insert(p0, str); return *this;}	AbstractString& insert(size_type p0, const base_string& str, size_type pos, size_type n) { base_string::insert(p0, str, pos, n); return *this;}	AbstractString& insert(size_type p0, const char *s, size_type n) { base_string::insert(p0, s,n); return *this;}	AbstractString& insert(size_type p0, const char *s) { base_string::insert(p0, s); return *this;}	AbstractString& insert(size_type p0, size_type n, char c) { base_string::insert(p0, n,c); return *this;}	int compare(const AbstractString& other) const { return base_string::compare(other); }    	bool isValid() const;	bool isStrictlyValid() const;    size_type find_first_invalid() const { 		return info()->characterSetSize ? find_first_not_of(info()->characterSet) : std::string::npos;	}#ifdef ASN1_HAS_IOSTREAM    friend std::ostream& operator << (std::ostream& os, const AbstractString& data)    { return os << static_cast<const std::string&>(data); }#endif	const char* getCharacterSet() const  { return info()->characterSet; }    unsigned getCharacterSetSize() const { return info()->characterSetSize; }    unsigned getCanonicalSetBits() const { return info()->canonicalSetBits; }	unsigned getNumBits(bool align) const { return align ? info()->charSetAlignedBits : info()->charSetUnalignedBits; }    static AbstractData* create(const void*);  private:	virtual int do_compare(const AbstractData& other) const;	virtual AbstractData* do_clone() const ;	virtual bool do_accept(Visitor&);	virtual bool do_accept(ConstVisitor&) const;  protected:	AbstractString(const void* info);	AbstractString(const void* info, const std::string& str);	AbstractString(const void* info, const char* str);	  	struct InfoType	{		CreateFun create;    		unsigned tag;		unsigned type;		int lowerLimit;		unsigned upperLimit;		const char* characterSet;		unsigned characterSetSize;		unsigned canonicalSetBits;		unsigned charSetUnalignedBits;		unsigned charSetAlignedBits;	};	      const InfoType* info() const { return static_cast<const InfoType*>(info_);}};class NumericString : public AbstractString { protected:    NumericString(const void* info) : AbstractString(info) { }public:    NumericString() : AbstractString(&theInfo) { }	NumericString(const std::string& str, const void* info = &theInfo) : AbstractString(info, str) { }	NumericString(const char* str, const void* info = &theInfo) : AbstractString(info,str) { }	NumericString& operator = (const NumericString& other) { assign(other); return *this;}	NumericString& operator=(const char * str) { assign(str);  return *this;} 	NumericString& operator=(const std::string & str) { assign(str);  return *this;} 	NumericString& operator=(char c) { assign(1, c); return *this;}        NumericString * clone() const { return static_cast<NumericString *>(AbstractString::clone()); }     static AbstractData* create();	void swap(NumericString& other) { base_string::swap(other); }   ASN1_EXPORT static const InfoType theInfo;	static bool equal_type(const ASN1::AbstractData& type)	{return type.info() == reinterpret_cast<const ASN1::AbstractData::InfoType*>(&theInfo);}};class PrintableString : public AbstractString { protected:    PrintableString(const void* info) : AbstractString(info) { }public:    PrintableString() : AbstractString(&theInfo) { }	PrintableString(const std::string& str, const void* info = &theInfo) : AbstractString(info, str) { }	PrintableString(const char* str, const void* info = &theInfo) : AbstractString(info,str) { }	PrintableString& operator = (const PrintableString& other) { assign(other); return *this;}	PrintableString& operator=(const char * str) { assign(str);  return *this;} 	PrintableString& operator=(const std::string & str) { assign(str);  return *this;} 	PrintableString& operator=(char c) { assign(1, c); return *this;} 	PrintableString * clone() const { return static_cast<PrintableString *>(AbstractString::clone()); }     static AbstractData* create();	void swap(PrintableString& other) { base_string::swap(other); }   ASN1_EXPORT static const InfoType theInfo;	static bool equal_type(const ASN1::AbstractData& type)	{return type.info() == reinterpret_cast<const ASN1::AbstractData::InfoType*>(&theInfo);}};class VisibleString : public AbstractString { protected:    VisibleString(const void* info) : AbstractString(info) { }public:    VisibleString() : AbstractString(&theInfo) { }	VisibleString(const std::string& str, const void* info = &theInfo) : AbstractString(info, str) { }	VisibleString(const char* str, const void* info = &theInfo) : AbstractString(info,str) { }	VisibleString& operator = (const VisibleString& other) { assign(other); return *this;}	VisibleString& operator=(const char * str) { assign(str);  return *this;} 	VisibleString& operator=(const std::string & str) { assign(str);  return *this;} 	VisibleString& operator=(char c) { assign(1, c); return *this;} 	VisibleString * clone() const { return static_cast<VisibleString *>(AbstractString::clone()); }     static AbstractData* create();	void swap(VisibleString& other) { base_string::swap(other); }   ASN1_EXPORT static const InfoType theInfo;	static bool equal_type(const ASN1::AbstractData& type)	{return type.info() == reinterpret_cast<const ASN1::AbstractData::InfoType*>(&theInfo);}};class IA5String : public AbstractString { protected:    IA5String(const void* info) : AbstractString(info) { }public:    IA5String() : AbstractString(&theInfo) { }	IA5String(const std::string& str, const void* info = &theInfo) : AbstractString(info, str) { }	IA5String(const char* str, const void* info = &theInfo) : AbstractString(info,str) { }	IA5String& operator = (const IA5String& other) { assign(other); return *this;}	IA5String& operator=(const char * str) { assign(str);  return *this;} 	IA5String& operator=(const std::string & str) { assign(str);  return *this;} 	IA5String& operator=(char c) { assign(1, c); return *this;} 	IA5String * clone() const { return static_cast<IA5String *>(AbstractString::clone()); }     static AbstractData* create();	void swap(IA5String& other) { base_string::swap(other); }   ASN1_EXPORT static const InfoType theInfo;	static bool equal_type(const ASN1::AbstractData& type)	{return type.info() == reinterpret_cast<const ASN1::AbstractData::InfoType*>(&theInfo);}};class GeneralString : public AbstractString { protected:    GeneralString(const void* info) : AbstractString(info) { }public:    GeneralString() : AbstractString(&theInfo) { }	GeneralString(const std::string& str, const void* info = &theInfo) : AbstractString(info, str) { }	GeneralString(const char* str, const void* info = &theInfo) : AbstractString(info,str) { }	GeneralString& operator = (const GeneralString& other) { assign(other); return *this;}	GeneralString& operator=(const char * str) { assign(str);  return *this;} 	GeneralString& operator=(const std::string & str) { assign(str);  return *this;} 	GeneralString& operator=(char c) { assign(1, c); return *this;} 	GeneralString * clone() const { return static_cast<GeneralString *>(AbstractString::clone()); }     static AbstractData* create();	void swap(GeneralString& other) { base_string::swap(other); }   ASN1_EXPORT static const InfoType theInfo;	static bool equal_type(const ASN1::AbstractData& type)	{return type.info() == reinterpret_cast<const ASN1::AbstractData::InfoType*>(&theInfo);}};/** Class for ASN BMP (16 bit) String type.*/class BMPString : public ConstrainedObject, public std::wstring{  protected:	typedef std::wstring base_string;	BMPString(const void* info);	struct InfoType	{	   CreateFun create;    	   unsigned tag;	   unsigned type;	   int lowerLimit;	   unsigned upperLimit;	   wchar_t firstChar, lastChar;	   unsigned charSetUnalignedBits;	   unsigned charSetAlignedBits;	};  public:	typedef base_string::value_type value_type;	typedef base_string::size_type size_type;	typedef base_string::difference_type difference_type;	typedef base_string::reference reference;	typedef base_string::const_reference const_reference;    BMPString();	BMPString(const base_string& str, const void* info = &theInfo);	BMPString(const value_type* str, const void* info = &theInfo);    BMPString(const BMPString & other);	BMPString & operator=(const value_type * str) { return assign(str);} 	BMPString & operator=(const base_string & str) { return  assign(str);} 	BMPString & operator=(value_type c) { return  assign(1,c);} 	BMPString& operator+=(const base_string& rhs) { return append(rhs);}	BMPString& operator+=(const value_type *s) { return append(s);}	BMPString& operator+=(value_type c) { return append(1, c);}	BMPString& append(const base_string& str) { base_string::append(str); return *this;}	BMPString& append(const base_string& str, size_type pos, size_type n) { base_string::append(str,pos, n); return *this;}	BMPString& append(const value_type *s, size_type n) { base_string::append(s,n); return *this;}	BMPString& append(const value_type *s) { base_string::append(s); return *this;}	BMPString& append(size_type n, value_type c) { base_string::append(n,c); return *this;}	BMPString& append(const_iterator first, const_iterator last) { base_string::append(first, last); return *this;}	BMPString& assign(const base_string& str) { base_string::assign(str); return *this;}	BMPString& assign(const base_string& str,size_type pos, size_type n) { base_string::assign(str,pos,n); return *this;}	BMPString& assign(const value_type *s, size_type n) { base_string::assign(s,n); return *this;}	BMPString& assign(const value_type *s) { base_string::assign(s); return *this;}	BMPString& assign(size_type n, value_type c) { base_string::assign(n,c); return *this;}	BMPString& assign(const_iterator first, const_iterator last) { base_string::assign(first,last); return *this;}	BMPString& insert(size_type p0, const base_string& str) { base_string::insert(p0, str); return *this;}	BMPString& insert(size_type p0, const base_string& str, size_type pos, size_type n) { base_string::insert(p0,str,pos,n); return *this;}	BMPString& insert(size_type p0, const value_type *s, size_type n) { base_string::insert(p0,s,n); return *this;}	BMPString& insert(size_type p0, const value_type *s) { base_string::insert(p0,s); return *this;}	BMPString& insert(size_type p0, size_type n, value_type c) { base_string::insert(p0,n,c); return *this;}		int compare(const BMPString& other) const { return base_string::compare(other); }    	BMPString * clone() const { return static_cast<BMPString *>(do_clone()); }     static AbstractData* create(const void* info);	void swap(BMPString& other) { base_string::swap(other); }	bool isValid() const;	bool isStrictlyValid() const;#ifdef ASN1_HAS_IOSTREAM    friend std::ostream& operator << (std::ostream& os, const BMPString& data)    { return os << static_cast<const AbstractData&>(data); }#endif    wchar_t getFirstChar() const { return info()->firstChar; }	wchar_t getLastChar() const { return info()->lastChar; }	unsigned getNumBits(bool align) const {         return align ? info()->charSetAlignedBits : info()->charSetUnalignedBits;     }   ASN1_EXPORT static const InfoType theInfo;	static bool equal_type(const ASN1::AbstractData& type)	{return type.info() == reinterpret_cast<const ASN1::AbstractData::InfoType*>(&theInfo);}	size_type first_illegal_at() const;  private:    bool legalCharacter(wchar_t ch) const;    const InfoType* info() const { return static_cast<const InfoType*>(info_);}    int do_compare(const AbstractData& other) const;    virtual AbstractData * do_clone() const;	virtual bool do_accept(Visitor&);	virtual bool do_accept(ConstVisitor&) const;};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -