Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

runtime: set eol-style property to LF

git-svn-id: http://asn1-compiler.googlecode.com/svn/trunk@193 b35bc7a6-0bd6-6437-dd7b-65e59c63c965
  • Loading branch information...
commit 08a52e136638e0da919094ff97e85cbd1481f8dc 1 parent 97d73d5
tysonite authored
Showing with 1,702 additions and 1,702 deletions.
  1. +7 −7 runtime/CMakeLists.txt
  2. +19 −19 runtime/INSTALL
  3. +29 −29 runtime/src/ASN1Exception.hh
  4. +28 −28 runtime/src/BaseSequenceOfType.hh
  5. +28 −28 runtime/src/BaseSetOfType.hh
  6. +65 −65 runtime/src/BitString.cc
  7. +41 −41 runtime/src/BitString.hh
  8. +49 −49 runtime/src/BitStringType.hh
  9. +55 −55 runtime/src/BooleanType.hh
  10. +84 −84 runtime/src/CMakeLists.txt
  11. +76 −76 runtime/src/EnumeratedType.hh
  12. +18 −18 runtime/src/GeneralizedTimeType.cc
  13. +43 −43 runtime/src/GeneralizedTimeType.hh
  14. +18 −18 runtime/src/GraphicStringType.cc
  15. +46 −46 runtime/src/GraphicStringType.hh
  16. +57 −57 runtime/src/IntegerType.hh
  17. +44 −44 runtime/src/NullType.hh
  18. +44 −44 runtime/src/ObjectIdentifier.cc
  19. +42 −42 runtime/src/ObjectIdentifier.hh
  20. +50 −50 runtime/src/ObjectIdentifierType.hh
  21. +33 −33 runtime/src/OctetStringType.cc
  22. +70 −70 runtime/src/OctetStringType.hh
  23. +24 −24 runtime/src/PrintableStringType.cc
  24. +46 −46 runtime/src/PrintableStringType.hh
  25. +96 −96 runtime/src/SequenceOfType.hh
  26. +26 −26 runtime/src/SequenceType.hh
  27. +96 −96 runtime/src/SetOfType.hh
  28. +26 −26 runtime/src/SetType.hh
  29. +16 −16 runtime/src/SizeConstraintsHolder.cc
  30. +58 −58 runtime/src/SizeConstraintsHolder.hh
  31. +127 −127 runtime/src/TaggingType.hh
  32. +27 −27 runtime/src/Types.hh
  33. +58 −58 runtime/src/UnsignedIntegerType.hh
  34. +70 −70 runtime/src/ValueConstraintsHolder.hh
  35. +7 −7 runtime/src/Values.hh
  36. +20 −20 runtime/src/VisibleStringType.cc
  37. +46 −46 runtime/src/VisibleStringType.hh
  38. +13 −13 runtime/src/XERBuffer.hh
View
14 runtime/CMakeLists.txt
@@ -1,7 +1,7 @@
-project (asn1-runtime)
-
-cmake_minimum_required (VERSION 2.6)
-
-add_subdirectory (src)
-add_subdirectory (tests)
-
+project (asn1-runtime)
+
+cmake_minimum_required (VERSION 2.6)
+
+add_subdirectory (src)
+add_subdirectory (tests)
+
View
38 runtime/INSTALL
@@ -1,20 +1,20 @@
-= Prerequisites =
- * C/C++ compiler (GNU GCC 4.4.2 or newer, MS VS 2010)
- * Boost library (www.boost.org), only for unit tests
- * CMake (www.cmake.org)
-
-= How to build from source =
- Create directory:
- runtime# mkdir build
-
- Go inside directory:
- runtime# cd build
-
- Launch CMake:
- build# cmake ..
-
-After the last command execution, the project files will be generated by CMake build system.
-Depending on what was generated build runtime library and tests.
-
- I.e. for GNU/Linux execute GNU make:
+= Prerequisites =
+ * C/C++ compiler (GNU GCC 4.4.2 or newer, MS VS 2010)
+ * Boost library (www.boost.org), only for unit tests
+ * CMake (www.cmake.org)
+
+= How to build from source =
+ Create directory:
+ runtime# mkdir build
+
+ Go inside directory:
+ runtime# cd build
+
+ Launch CMake:
+ build# cmake ..
+
+After the last command execution, the project files will be generated by CMake build system.
+Depending on what was generated build runtime library and tests.
+
+ I.e. for GNU/Linux execute GNU make:
build# make
View
58 runtime/src/ASN1Exception.hh
@@ -1,29 +1,29 @@
-#ifndef __ASN1_EXCEPTION_HH
-#define __ASN1_EXCEPTION_HH
-
-#include <exception>
-#include <string>
-
-namespace asn1
-{
-
-class ASN1Exception : public std::exception
-{
-public:
-
- explicit ASN1Exception(const char* msg) throw()
- : _message(msg) {}
- explicit ASN1Exception(const std::string& msg) throw()
- : _message(msg) {}
- ~ASN1Exception() throw() {}
-
- const char* what() const throw() { return _message.c_str(); }
-
-private:
-
- std::string _message;
-};
-
-}
-
-#endif // __ASN1_EXCEPTION_HH
+#ifndef __ASN1_EXCEPTION_HH
+#define __ASN1_EXCEPTION_HH
+
+#include <exception>
+#include <string>
+
+namespace asn1
+{
+
+class ASN1Exception : public std::exception
+{
+public:
+
+ explicit ASN1Exception(const char* msg) throw()
+ : _message(msg) {}
+ explicit ASN1Exception(const std::string& msg) throw()
+ : _message(msg) {}
+ ~ASN1Exception() throw() {}
+
+ const char* what() const throw() { return _message.c_str(); }
+
+private:
+
+ std::string _message;
+};
+
+}
+
+#endif // __ASN1_EXCEPTION_HH
View
56 runtime/src/BaseSequenceOfType.hh
@@ -1,28 +1,28 @@
-#ifndef __BASE_SEQUENCE_OF_TYPE_HH
-#define __BASE_SEQUENCE_OF_TYPE_HH
-
-#include "SequenceType.hh"
-#include "SizeConstraintsHolder.hh"
-
-namespace asn1
-{
-
-class BaseSequenceOfType : public SequenceType, public SizeConstraintsHolder
-{
-public:
-
- // Constructor
- explicit BaseSequenceOfType(uint64_t minSize = 0, uint64_t maxSize = 0)
- : SizeConstraintsHolder(*this, minSize, maxSize) {}
-
- // Returns type identifier
- TypeID typeID() const { return SEQUENCE_OF_TYPE; }
-
-private:
-
- DISALLOW_COPY_AND_ASSIGN(BaseSequenceOfType);
-};
-
-}
-
-#endif // __BASE_SEQUENCE_OF_TYPE_HH
+#ifndef __BASE_SEQUENCE_OF_TYPE_HH
+#define __BASE_SEQUENCE_OF_TYPE_HH
+
+#include "SequenceType.hh"
+#include "SizeConstraintsHolder.hh"
+
+namespace asn1
+{
+
+class BaseSequenceOfType : public SequenceType, public SizeConstraintsHolder
+{
+public:
+
+ // Constructor
+ explicit BaseSequenceOfType(uint64_t minSize = 0, uint64_t maxSize = 0)
+ : SizeConstraintsHolder(*this, minSize, maxSize) {}
+
+ // Returns type identifier
+ TypeID typeID() const { return SEQUENCE_OF_TYPE; }
+
+private:
+
+ DISALLOW_COPY_AND_ASSIGN(BaseSequenceOfType);
+};
+
+}
+
+#endif // __BASE_SEQUENCE_OF_TYPE_HH
View
56 runtime/src/BaseSetOfType.hh
@@ -1,28 +1,28 @@
-#ifndef __BASE_SET_OF_TYPE_HH
-#define __BASE_SET_OF_TYPE_HH
-
-#include "SetType.hh"
-#include "SizeConstraintsHolder.hh"
-
-namespace asn1
-{
-
-class BaseSetOfType : public SetType, public SizeConstraintsHolder
-{
-public:
-
- // Constructor
- explicit BaseSetOfType(uint64_t minSize = 0, uint64_t maxSize = 0)
- : SizeConstraintsHolder(*this, minSize, maxSize) {}
-
- // Returns type identifier
- TypeID typeID() const { return SET_OF_TYPE; }
-
-private:
-
- DISALLOW_COPY_AND_ASSIGN(BaseSetOfType);
-};
-
-}
-
-#endif // __BASE_SET_OF_TYPE_HH
+#ifndef __BASE_SET_OF_TYPE_HH
+#define __BASE_SET_OF_TYPE_HH
+
+#include "SetType.hh"
+#include "SizeConstraintsHolder.hh"
+
+namespace asn1
+{
+
+class BaseSetOfType : public SetType, public SizeConstraintsHolder
+{
+public:
+
+ // Constructor
+ explicit BaseSetOfType(uint64_t minSize = 0, uint64_t maxSize = 0)
+ : SizeConstraintsHolder(*this, minSize, maxSize) {}
+
+ // Returns type identifier
+ TypeID typeID() const { return SET_OF_TYPE; }
+
+private:
+
+ DISALLOW_COPY_AND_ASSIGN(BaseSetOfType);
+};
+
+}
+
+#endif // __BASE_SET_OF_TYPE_HH
View
130 runtime/src/BitString.cc
@@ -1,65 +1,65 @@
-#include "BitString.hh"
-#include "ASN1Exception.hh"
-
-namespace asn1
-{
-
-// Sets specified bit
-void BitString::setBit(size_type bitNumber)
-{
- if (bitNumber < size())
- (*this)[bitNumber] = true;
-
- // TODO: expand vector to bitNumber size
-}
-
-// Clears specified bit
-void BitString::clearBit(size_type bitNumber)
-{
- if (bitNumber < size())
- (*this)[bitNumber] = false;
-
- // TODO: expand vector to bitNumber size
-}
-
-// Returns bit string represented as string (i.e. "11001")
-std::string BitString::getValueAsString() const
-{
- std::string value;
- value.reserve(size());
-
- for (const_iterator p = begin(); p != end(); ++p)
- {
- if (*p == true)
- value.append("1");
- else
- value.append("0");
- }
-
- return value;
-}
-
-// Parses and sets bit string
-void BitString::_parseAndSetBitString(const std::string& value)
-{
- // reserve space for value
- BitString tmp;
- tmp.reserve(value.size());
-
- // parse and set
- for (std::string::const_iterator p = value.begin(); p != value.end(); ++p)
- {
- if (*p != '1' && *p != '0')
- throw ASN1Exception("Bit String value '" + value + "' is incorrect");
-
- if (*p == '1')
- tmp.push_back(true);
- else
- tmp.push_back(false);
- }
-
- // apply value
- swap(tmp);
-}
-
-}
+#include "BitString.hh"
+#include "ASN1Exception.hh"
+
+namespace asn1
+{
+
+// Sets specified bit
+void BitString::setBit(size_type bitNumber)
+{
+ if (bitNumber < size())
+ (*this)[bitNumber] = true;
+
+ // TODO: expand vector to bitNumber size
+}
+
+// Clears specified bit
+void BitString::clearBit(size_type bitNumber)
+{
+ if (bitNumber < size())
+ (*this)[bitNumber] = false;
+
+ // TODO: expand vector to bitNumber size
+}
+
+// Returns bit string represented as string (i.e. "11001")
+std::string BitString::getValueAsString() const
+{
+ std::string value;
+ value.reserve(size());
+
+ for (const_iterator p = begin(); p != end(); ++p)
+ {
+ if (*p == true)
+ value.append("1");
+ else
+ value.append("0");
+ }
+
+ return value;
+}
+
+// Parses and sets bit string
+void BitString::_parseAndSetBitString(const std::string& value)
+{
+ // reserve space for value
+ BitString tmp;
+ tmp.reserve(value.size());
+
+ // parse and set
+ for (std::string::const_iterator p = value.begin(); p != value.end(); ++p)
+ {
+ if (*p != '1' && *p != '0')
+ throw ASN1Exception("Bit String value '" + value + "' is incorrect");
+
+ if (*p == '1')
+ tmp.push_back(true);
+ else
+ tmp.push_back(false);
+ }
+
+ // apply value
+ swap(tmp);
+}
+
+}
View
82 runtime/src/BitString.hh
@@ -1,41 +1,41 @@
-#ifndef __BIT_STRING_HH
-#define __BIT_STRING_HH
-
-#include <vector>
-#include <string>
-
-namespace asn1
-{
-
-class BitString : public std::vector<bool>
-{
-public:
-
- // Default constructor
- BitString() {}
-
- // Constructor: value is a string representation of the bit string.
- // i.e.: value = "11001"
- BitString(const std::string& value) { setValue(value); }
-
- // Sets bit string as string
- void setValue(const std::string& value) { _parseAndSetBitString(value); }
-
- // Sets specified bit
- void setBit(size_type bitNumber);
-
- // Clears specified bit
- void clearBit(size_type bitNumber);
-
- // Returns bit string represented as string (i.e. "11001")
- std::string getValueAsString() const;
-
-private:
-
- // Parses and sets bit string
- void _parseAndSetBitString(const std::string& value);
-};
-
-}
-
-#endif // __BIT_STRING_HH
+#ifndef __BIT_STRING_HH
+#define __BIT_STRING_HH
+
+#include <vector>
+#include <string>
+
+namespace asn1
+{
+
+class BitString : public std::vector<bool>
+{
+public:
+
+ // Default constructor
+ BitString() {}
+
+ // Constructor: value is a string representation of the bit string.
+ // i.e.: value = "11001"
+ BitString(const std::string& value) { setValue(value); }
+
+ // Sets bit string as string
+ void setValue(const std::string& value) { _parseAndSetBitString(value); }
+
+ // Sets specified bit
+ void setBit(size_type bitNumber);
+
+ // Clears specified bit
+ void clearBit(size_type bitNumber);
+
+ // Returns bit string represented as string (i.e. "11001")
+ std::string getValueAsString() const;
+
+private:
+
+ // Parses and sets bit string
+ void _parseAndSetBitString(const std::string& value);
+};
+
+}
+
+#endif // __BIT_STRING_HH
View
98 runtime/src/BitStringType.hh
@@ -1,49 +1,49 @@
-#ifndef __BIT_STRING_TYPE_HH
-#define __BIT_STRING_TYPE_HH
-
-#include "ASN1ValueReader.hh"
-#include "ASN1ValueWriter.hh"
-
-#include "Type.hh"
-
-namespace asn1
-{
-
-class BitStringType : public Type
-{
-public:
-
- typedef BitString ValueType;
-
- explicit BitStringType() {}
-
- // Returns type identifier
- virtual TypeID typeID() const { return BITSTRING_TYPE; }
-
- // Checks type parameters for validness
- void checkType(const ValueType& value) const {}
-
- // Reads the value
- void read(ASN1ValueReader& reader, ValueType& value) const
- {
- ValueRestorer<ValueType> restorer(value);
-
- reader.readBitString(value, *this);
-
- restorer.restoreNotNeeded();
- }
-
- // Writes the value
- void write(ASN1ValueWriter& writer, const ValueType& value) const
- {
- writer.writeBitString(value, *this);
- }
-
-private:
-
- DISALLOW_COPY_AND_ASSIGN(BitStringType);
-};
-
-}
-
-#endif // __BIT_STRING_TYPE_HH
+#ifndef __BIT_STRING_TYPE_HH
+#define __BIT_STRING_TYPE_HH
+
+#include "ASN1ValueReader.hh"
+#include "ASN1ValueWriter.hh"
+
+#include "Type.hh"
+
+namespace asn1
+{
+
+class BitStringType : public Type
+{
+public:
+
+ typedef BitString ValueType;
+
+ explicit BitStringType() {}
+
+ // Returns type identifier
+ virtual TypeID typeID() const { return BITSTRING_TYPE; }
+
+ // Checks type parameters for validness
+ void checkType(const ValueType& value) const {}
+
+ // Reads the value
+ void read(ASN1ValueReader& reader, ValueType& value) const
+ {
+ ValueRestorer<ValueType> restorer(value);
+
+ reader.readBitString(value, *this);
+
+ restorer.restoreNotNeeded();
+ }
+
+ // Writes the value
+ void write(ASN1ValueWriter& writer, const ValueType& value) const
+ {
+ writer.writeBitString(value, *this);
+ }
+
+private:
+
+ DISALLOW_COPY_AND_ASSIGN(BitStringType);
+};
+
+}
+
+#endif // __BIT_STRING_TYPE_HH
View
110 runtime/src/BooleanType.hh
@@ -1,55 +1,55 @@
-#ifndef __BOOLEAN_TYPE_HH
-#define __BOOLEAN_TYPE_HH
-
-#include "ASN1ValueReader.hh"
-#include "ASN1ValueWriter.hh"
-
-#include "Type.hh"
-
-namespace asn1
-{
-
-class BooleanType : public Type
-{
-public:
-
- typedef Boolean ValueType;
-
- explicit BooleanType(const ValueType& defaultValue = false, bool hasDefault = false)
- : _defaultValue(defaultValue), _hasDefault(hasDefault) {}
-
- // Returns type identifier
- virtual TypeID typeID() const { return BOOLEAN_TYPE; }
-
- const Boolean& defaultValue() const { return _defaultValue; }
- bool hasDefault() const { return _hasDefault; }
-
- // Reads the value
- void read(ASN1ValueReader& reader, ValueType& value) const
- {
- ValueRestorer<Boolean> restorer(value);
-
- reader.readBoolean(value, *this);
-
- restorer.restoreNotNeeded();
- }
-
- // Writes the value
- void write(ASN1ValueWriter& writer, const ValueType& value) const
- {
- writer.writeBoolean(value, *this);
- }
-
-private:
-
- ValueType _defaultValue;
- bool _hasDefault;
-
-private:
-
- DISALLOW_COPY_AND_ASSIGN(BooleanType);
-};
-
-}
-
-#endif // __BOOLEAN_TYPE_HH
+#ifndef __BOOLEAN_TYPE_HH
+#define __BOOLEAN_TYPE_HH
+
+#include "ASN1ValueReader.hh"
+#include "ASN1ValueWriter.hh"
+
+#include "Type.hh"
+
+namespace asn1
+{
+
+class BooleanType : public Type
+{
+public:
+
+ typedef Boolean ValueType;
+
+ explicit BooleanType(const ValueType& defaultValue = false, bool hasDefault = false)
+ : _defaultValue(defaultValue), _hasDefault(hasDefault) {}
+
+ // Returns type identifier
+ virtual TypeID typeID() const { return BOOLEAN_TYPE; }
+
+ const Boolean& defaultValue() const { return _defaultValue; }
+ bool hasDefault() const { return _hasDefault; }
+
+ // Reads the value
+ void read(ASN1ValueReader& reader, ValueType& value) const
+ {
+ ValueRestorer<Boolean> restorer(value);
+
+ reader.readBoolean(value, *this);
+
+ restorer.restoreNotNeeded();
+ }
+
+ // Writes the value
+ void write(ASN1ValueWriter& writer, const ValueType& value) const
+ {
+ writer.writeBoolean(value, *this);
+ }
+
+private:
+
+ ValueType _defaultValue;
+ bool _hasDefault;
+
+private:
+
+ DISALLOW_COPY_AND_ASSIGN(BooleanType);
+};
+
+}
+
+#endif // __BOOLEAN_TYPE_HH
View
168 runtime/src/CMakeLists.txt
@@ -1,84 +1,84 @@
-project (asn1-runtime)
-
-cmake_minimum_required (VERSION 2.6)
-
-set (ASN1_RUNTIME_INCLUDE_DIRS
- ${CMAKE_SOURCE_DIR}/src
- CACHE INTERNAL "")
-
-set (SOURCES
- BERValueReader.cc
- BERValueWriter.cc
- CERValueWriter.cc
- XERValueWriter.cc
- ChoiceType.cc
- GeneralizedTimeType.cc
- GraphicStringType.cc
- ObjectIdentifier.cc
- OctetStringType.cc
- PrintableStringType.cc
- Type.cc
- VisibleStringType.cc
- BitString.cc
- SizeConstraintsHolder.cc)
-
-set (HEADERS
- ASN1Exception.hh
- ASN1ValueReader.hh
- ASN1ValueWriter.hh
- BERBuffer.hh
- BERValueReader.hh
- BERValueWriter.hh
- BitStringType.hh
- BooleanType.hh
- CERValueWriter.hh
- ChoiceType.hh
- EnumeratedType.hh
- GeneralizedTimeType.hh
- GraphicStringType.hh
- IntegerType.hh
- NullType.hh
- ObjectIdentifier.hh
- ObjectIdentifierType.hh
- OctetStringType.hh
- PrintableStringType.hh
- SequenceOfType.hh
- SequenceType.hh
- TaggingType.hh
- Type.hh
- TypeCommon.hh
- Types.hh
- Utils.hh
- Values.hh
- VisibleStringType.hh
- XERBuffer.hh
- XERValueWriter.hh
- BitString.hh
- SizeConstraintsHolder.hh
- BaseSequenceOfType.hh
- SetType.hh
- BaseSetOfType.hh
- SetOfType.hh
- UnsignedIntegerType.hh
- ValueConstraintsHolder.hh)
-
-if (CMAKE_COMPILER_IS_GNUCC)
- set_source_files_properties(${SOURCES} PROPERTIES COMPILE_FLAGS "-std=c++0x -Wall")
-endif ()
-
-set (ASN1_RUNTIME_LIBRARY
- asn1-runtime-lib
- CACHE INTERNAL "")
-
-set (ASN1_RUNTIME_LINK_LIBRARIES
- ${ASN1_RUNTIME_LINK_LIBRARIES}
- ${ASN1_RUNTIME_LIBRARY}
- CACHE INTERNAL "")
-
-source_group ("Header Files" FILES ${HEADERS})
-
-add_library (${ASN1_RUNTIME_LIBRARY} ${SOURCES} ${HEADERS})
-
-target_link_libraries(${ASN1_RUNTIME_LIBRARY} ${ASN1_RUNTIME_LINK_LIBRARIES})
-
-
+project (asn1-runtime)
+
+cmake_minimum_required (VERSION 2.6)
+
+set (ASN1_RUNTIME_INCLUDE_DIRS
+ ${CMAKE_SOURCE_DIR}/src
+ CACHE INTERNAL "")
+
+set (SOURCES
+ BERValueReader.cc
+ BERValueWriter.cc
+ CERValueWriter.cc
+ XERValueWriter.cc
+ ChoiceType.cc
+ GeneralizedTimeType.cc
+ GraphicStringType.cc
+ ObjectIdentifier.cc
+ OctetStringType.cc
+ PrintableStringType.cc
+ Type.cc
+ VisibleStringType.cc
+ BitString.cc
+ SizeConstraintsHolder.cc)
+
+set (HEADERS
+ ASN1Exception.hh
+ ASN1ValueReader.hh
+ ASN1ValueWriter.hh
+ BERBuffer.hh
+ BERValueReader.hh
+ BERValueWriter.hh
+ BitStringType.hh
+ BooleanType.hh
+ CERValueWriter.hh
+ ChoiceType.hh
+ EnumeratedType.hh
+ GeneralizedTimeType.hh
+ GraphicStringType.hh
+ IntegerType.hh
+ NullType.hh
+ ObjectIdentifier.hh
+ ObjectIdentifierType.hh
+ OctetStringType.hh
+ PrintableStringType.hh
+ SequenceOfType.hh
+ SequenceType.hh
+ TaggingType.hh
+ Type.hh
+ TypeCommon.hh
+ Types.hh
+ Utils.hh
+ Values.hh
+ VisibleStringType.hh
+ XERBuffer.hh
+ XERValueWriter.hh
+ BitString.hh
+ SizeConstraintsHolder.hh
+ BaseSequenceOfType.hh
+ SetType.hh
+ BaseSetOfType.hh
+ SetOfType.hh
+ UnsignedIntegerType.hh
+ ValueConstraintsHolder.hh)
+
+if (CMAKE_COMPILER_IS_GNUCC)
+ set_source_files_properties(${SOURCES} PROPERTIES COMPILE_FLAGS "-std=c++0x -Wall")
+endif ()
+
+set (ASN1_RUNTIME_LIBRARY
+ asn1-runtime-lib
+ CACHE INTERNAL "")
+
+set (ASN1_RUNTIME_LINK_LIBRARIES
+ ${ASN1_RUNTIME_LINK_LIBRARIES}
+ ${ASN1_RUNTIME_LIBRARY}
+ CACHE INTERNAL "")
+
+source_group ("Header Files" FILES ${HEADERS})
+
+add_library (${ASN1_RUNTIME_LIBRARY} ${SOURCES} ${HEADERS})
+
+target_link_libraries(${ASN1_RUNTIME_LIBRARY} ${ASN1_RUNTIME_LINK_LIBRARIES})
+
+
View
152 runtime/src/EnumeratedType.hh
@@ -1,76 +1,76 @@
-#ifndef __ENUMERATED_TYPE_HH
-#define __ENUMERATED_TYPE_HH
-
-#include <list>
-#include <algorithm>
-
-#include "ASN1ValueReader.hh"
-#include "ASN1ValueWriter.hh"
-
-#include "Type.hh"
-
-namespace asn1
-{
-
-class EnumeratedType : public Type
-{
-public:
-
- typedef Integer ValueType;
- typedef std::list<ValueType> EnumsType;
-
- explicit EnumeratedType(const ValueType& defaultValue = 0, bool hasDefault = false)
- : _defaultValue(defaultValue), _hasDefault(hasDefault) {}
-
- // Returns type identifier
- virtual TypeID typeID() const { return ENUMERATED_TYPE; }
-
- const ValueType& defaultValue() const { return _defaultValue; }
- bool hasDefault() const { return _hasDefault; }
-
- // Checks type parameters for validness
- void checkType(const ValueType& value) const
- {
- EnumsType::const_iterator p = std::find(_enumValues.begin(), _enumValues.end(), value);
- if (p == _enumValues.end())
- throw ASN1Exception("Value '" + utils::ntos(value) + "' is illegal in enumeration " + toString());
- }
-
- // Reads the value
- void read(ASN1ValueReader& reader, ValueType& value) const
- {
- ValueRestorer<ValueType> restorer(value);
-
- reader.readEnumerated(value, *this);
-
- restorer.restoreNotNeeded();
- }
-
- // Writes the value
- void write(ASN1ValueWriter& writer, const ValueType& value) const
- {
- writer.writeEnumerated(value, *this);
- }
-
-protected:
-
- // Adds possible enumerated value
- void _addEnumValue(const ValueType& value)
- {
- _enumValues.push_back(value);
- }
-
-private:
-
- ValueType _defaultValue;
- bool _hasDefault;
- EnumsType _enumValues;
-
-private:
-
- DISALLOW_COPY_AND_ASSIGN(EnumeratedType);
-};
-
-}
-
-#endif // __ENUMERATED_TYPE_HH
+#ifndef __ENUMERATED_TYPE_HH
+#define __ENUMERATED_TYPE_HH
+
+#include <list>
+#include <algorithm>
+
+#include "ASN1ValueReader.hh"
+#include "ASN1ValueWriter.hh"
+
+#include "Type.hh"
+
+namespace asn1
+{
+
+class EnumeratedType : public Type
+{
+public:
+
+ typedef Integer ValueType;
+ typedef std::list<ValueType> EnumsType;
+
+ explicit EnumeratedType(const ValueType& defaultValue = 0, bool hasDefault = false)
+ : _defaultValue(defaultValue), _hasDefault(hasDefault) {}
+
+ // Returns type identifier
+ virtual TypeID typeID() const { return ENUMERATED_TYPE; }
+
+ const ValueType& defaultValue() const { return _defaultValue; }
+ bool hasDefault() const { return _hasDefault; }
+
+ // Checks type parameters for validness
+ void checkType(const ValueType& value) const
+ {
+ EnumsType::const_iterator p = std::find(_enumValues.begin(), _enumValues.end(), value);
+ if (p == _enumValues.end())
+ throw ASN1Exception("Value '" + utils::ntos(value) + "' is illegal in enumeration " + toString());
+ }
+
+ // Reads the value
+ void read(ASN1ValueReader& reader, ValueType& value) const
+ {
+ ValueRestorer<ValueType> restorer(value);
+
+ reader.readEnumerated(value, *this);
+
+ restorer.restoreNotNeeded();
+ }
+
+ // Writes the value
+ void write(ASN1ValueWriter& writer, const ValueType& value) const
+ {
+ writer.writeEnumerated(value, *this);
+ }
+
+protected:
+
+ // Adds possible enumerated value
+ void _addEnumValue(const ValueType& value)
+ {
+ _enumValues.push_back(value);
+ }
+
+private:
+
+ ValueType _defaultValue;
+ bool _hasDefault;
+ EnumsType _enumValues;
+
+private:
+
+ DISALLOW_COPY_AND_ASSIGN(EnumeratedType);
+};
+
+}
+
+#endif // __ENUMERATED_TYPE_HH
View
36 runtime/src/GeneralizedTimeType.cc
@@ -1,18 +1,18 @@
-#include "GeneralizedTimeType.hh"
-
-namespace asn1
-{
-
-// Checks type parameters for validness
-void GeneralizedTimeType::checkType(const ValueType& value) const
-{
- VisibleStringType::checkType(value);
-
- for (OctetString::size_type i = 0; i < value.size(); ++i)
- {
- OctetString::value_type c = value[i];
- // TODO: add checks
- }
-}
-
-}
+#include "GeneralizedTimeType.hh"
+
+namespace asn1
+{
+
+// Checks type parameters for validness
+void GeneralizedTimeType::checkType(const ValueType& value) const
+{
+ VisibleStringType::checkType(value);
+
+ for (OctetString::size_type i = 0; i < value.size(); ++i)
+ {
+ OctetString::value_type c = value[i];
+ // TODO: add checks
+ }
+}
+
+}
View
86 runtime/src/GeneralizedTimeType.hh
@@ -1,43 +1,43 @@
-#ifndef __GENERALIZED_TIME_TYPE_HH
-#define __GENERALIZED_TIME_TYPE_HH
-
-#include "VisibleStringType.hh"
-
-namespace asn1
-{
-
-class GeneralizedTimeType : public VisibleStringType
-{
-public:
-
- // Constructor
- explicit GeneralizedTimeType(const ValueType& defaultValue = "", bool hasDefault = false)
- : VisibleStringType(defaultValue, hasDefault) {}
-
- // Returns type identifier
- TypeID typeID() const { return GENERALIZED_TIME_TYPE; }
-
- // Checks type parameters for validness
- void checkType(const ValueType& value) const;
-
- // Reads the value
- void read(ASN1ValueReader& reader, ValueType& value) const
- {
- ValueRestorer<ValueType> restorer(value);
-
- restorer.restoreNotNeeded();
- }
-
- // Writes the value
- void write(ASN1ValueWriter& writer, const ValueType& value) const
- {
- }
-
-private:
-
- DISALLOW_COPY_AND_ASSIGN(GeneralizedTimeType);
-};
-
-}
-
-#endif // __GENERALIZED_TIME_TYPE_HH
+#ifndef __GENERALIZED_TIME_TYPE_HH
+#define __GENERALIZED_TIME_TYPE_HH
+
+#include "VisibleStringType.hh"
+
+namespace asn1
+{
+
+class GeneralizedTimeType : public VisibleStringType
+{
+public:
+
+ // Constructor
+ explicit GeneralizedTimeType(const ValueType& defaultValue = "", bool hasDefault = false)
+ : VisibleStringType(defaultValue, hasDefault) {}
+
+ // Returns type identifier
+ TypeID typeID() const { return GENERALIZED_TIME_TYPE; }
+
+ // Checks type parameters for validness
+ void checkType(const ValueType& value) const;
+
+ // Reads the value
+ void read(ASN1ValueReader& reader, ValueType& value) const
+ {
+ ValueRestorer<ValueType> restorer(value);
+
+ restorer.restoreNotNeeded();
+ }
+
+ // Writes the value
+ void write(ASN1ValueWriter& writer, const ValueType& value) const
+ {
+ }
+
+private:
+
+ DISALLOW_COPY_AND_ASSIGN(GeneralizedTimeType);
+};
+
+}
+
+#endif // __GENERALIZED_TIME_TYPE_HH
View
36 runtime/src/GraphicStringType.cc
@@ -1,18 +1,18 @@
-#include "GraphicStringType.hh"
-
-namespace asn1
-{
-
-// Checks type parameters for validness
-void GraphicStringType::checkType(const ValueType& value) const
-{
- OctetStringType::checkType(value);
-
- for (OctetString::size_type i = 0; i < value.size(); ++i)
- {
- OctetString::value_type c = value[i];
- // TODO: add checks
- }
-}
-
-}
+#include "GraphicStringType.hh"
+
+namespace asn1
+{
+
+// Checks type parameters for validness
+void GraphicStringType::checkType(const ValueType& value) const
+{
+ OctetStringType::checkType(value);
+
+ for (OctetString::size_type i = 0; i < value.size(); ++i)
+ {
+ OctetString::value_type c = value[i];
+ // TODO: add checks
+ }
+}
+
+}
View
92 runtime/src/GraphicStringType.hh
@@ -1,46 +1,46 @@
-#ifndef __GRAPHIC_STRING_TYPE_HH
-#define __GRAPHIC_STRING_TYPE_HH
-
-#include "OctetStringType.hh"
-
-namespace asn1
-{
-
-class GraphicStringType : public OctetStringType
-{
-public:
-
- // Constructor
- explicit GraphicStringType(const ValueType& defaultValue = "", bool hasDefault = false)
- : OctetStringType(defaultValue, hasDefault) {}
-
- // Returns type identifier
- TypeID typeID() const { return GRAPHIC_STRING_TYPE; }
-
- // Checks type parameters for validness
- void checkType(const ValueType& value) const;
-
- // Reads the value
- void read(ASN1ValueReader& reader, ValueType& value) const
- {
- ValueRestorer<ValueType> restorer(value);
-
- reader.readGraphicString(value, *this);
-
- restorer.restoreNotNeeded();
- }
-
- // Writes the value
- void write(ASN1ValueWriter& writer, const ValueType& value) const
- {
- writer.writeGraphicString(value, *this);
- }
-
-private:
-
- DISALLOW_COPY_AND_ASSIGN(GraphicStringType);
-};
-
-}
-
-#endif // __GRAPHIC_STRING_TYPE_HH
+#ifndef __GRAPHIC_STRING_TYPE_HH
+#define __GRAPHIC_STRING_TYPE_HH
+
+#include "OctetStringType.hh"
+
+namespace asn1
+{
+
+class GraphicStringType : public OctetStringType
+{
+public:
+
+ // Constructor
+ explicit GraphicStringType(const ValueType& defaultValue = "", bool hasDefault = false)
+ : OctetStringType(defaultValue, hasDefault) {}
+
+ // Returns type identifier
+ TypeID typeID() const { return GRAPHIC_STRING_TYPE; }
+
+ // Checks type parameters for validness
+ void checkType(const ValueType& value) const;
+
+ // Reads the value
+ void read(ASN1ValueReader& reader, ValueType& value) const
+ {
+ ValueRestorer<ValueType> restorer(value);
+
+ reader.readGraphicString(value, *this);
+
+ restorer.restoreNotNeeded();
+ }
+
+ // Writes the value
+ void write(ASN1ValueWriter& writer, const ValueType& value) const
+ {
+ writer.writeGraphicString(value, *this);
+ }
+
+private:
+
+ DISALLOW_COPY_AND_ASSIGN(GraphicStringType);
+};
+
+}
+
+#endif // __GRAPHIC_STRING_TYPE_HH
View
114 runtime/src/IntegerType.hh
@@ -1,57 +1,57 @@
-#ifndef __INTEGER_TYPE_HH
-#define __INTEGER_TYPE_HH
-
-#include "ASN1ValueReader.hh"
-#include "ASN1ValueWriter.hh"
-
-#include "Type.hh"
-#include "ValueConstraintsHolder.hh"
-
-namespace asn1
-{
-
-class IntegerType : public Type, public ValueConstraintsHolder<Integer>
-{
-public:
-
- typedef Integer ValueType;
-
- explicit IntegerType(const ValueType& defaultValue = 0, bool hasDefault = false)
- : ValueConstraintsHolder<ValueType>(*this, 0, 0), _defaultValue(defaultValue),
- _hasDefault(hasDefault) {}
-
- // Returns type identifier
- virtual TypeID typeID() const { return INTEGER_TYPE; }
-
- const Integer& defaultValue() const { return _defaultValue; }
- bool hasDefault() const { return _hasDefault; }
-
- // Reads the value
- void read(ASN1ValueReader& reader, ValueType& value) const
- {
- ValueRestorer<Integer> restorer(value);
-
- reader.readInteger(value, *this);
-
- restorer.restoreNotNeeded();
- }
-
- // Writes the value
- void write(ASN1ValueWriter& writer, const ValueType& value) const
- {
- writer.writeInteger(value, *this);
- }
-
-private:
-
- ValueType _defaultValue;
- bool _hasDefault;
-
-private:
-
- DISALLOW_COPY_AND_ASSIGN(IntegerType);
-};
-
-}
-
-#endif // __INTEGER_TYPE_HH
+#ifndef __INTEGER_TYPE_HH
+#define __INTEGER_TYPE_HH
+
+#include "ASN1ValueReader.hh"
+#include "ASN1ValueWriter.hh"
+
+#include "Type.hh"
+#include "ValueConstraintsHolder.hh"
+
+namespace asn1
+{
+
+class IntegerType : public Type, public ValueConstraintsHolder<Integer>
+{
+public:
+
+ typedef Integer ValueType;
+
+ explicit IntegerType(const ValueType& defaultValue = 0, bool hasDefault = false)
+ : ValueConstraintsHolder<ValueType>(*this, 0, 0), _defaultValue(defaultValue),
+ _hasDefault(hasDefault) {}
+
+ // Returns type identifier
+ virtual TypeID typeID() const { return INTEGER_TYPE; }
+
+ const Integer& defaultValue() const { return _defaultValue; }
+ bool hasDefault() const { return _hasDefault; }
+
+ // Reads the value
+ void read(ASN1ValueReader& reader, ValueType& value) const
+ {
+ ValueRestorer<Integer> restorer(value);
+
+ reader.readInteger(value, *this);
+
+ restorer.restoreNotNeeded();
+ }
+
+ // Writes the value
+ void write(ASN1ValueWriter& writer, const ValueType& value) const
+ {
+ writer.writeInteger(value, *this);
+ }
+
+private:
+
+ ValueType _defaultValue;
+ bool _hasDefault;
+
+private:
+
+ DISALLOW_COPY_AND_ASSIGN(IntegerType);
+};
+
+}
+
+#endif // __INTEGER_TYPE_HH
View
88 runtime/src/NullType.hh
@@ -1,44 +1,44 @@
-#ifndef __NULL_TYPE_HH
-#define __NULL_TYPE_HH
-
-#include "ASN1ValueReader.hh"
-#include "ASN1ValueWriter.hh"
-
-#include "Type.hh"
-
-namespace asn1
-{
-
-class NullType : public Type
-{
-public:
-
- class NullValueType
- {
- public:
- bool operator==(const NullValueType& other) const { return true; }
- bool operator!=(const NullValueType& other) const { return !(*this == other); }
- };
-
- typedef NullValueType ValueType; // represents NULL type, in fact it is not used anywhere
-
- // Constructor
- explicit NullType() {}
-
- // Returns type identifier
- TypeID typeID() const { return NULL_TYPE; }
-
- // Reads the value
- void read(ASN1ValueReader& reader, ValueType&) const { reader.readNull(*this); }
-
- // Writes the value
- void write(ASN1ValueWriter& writer, const ValueType&) const { writer.writeNull(*this); }
-
-private:
-
- DISALLOW_COPY_AND_ASSIGN(NullType);
-};
-
-}
-
-#endif // __NULL_TYPE_HH
+#ifndef __NULL_TYPE_HH
+#define __NULL_TYPE_HH
+
+#include "ASN1ValueReader.hh"
+#include "ASN1ValueWriter.hh"
+
+#include "Type.hh"
+
+namespace asn1
+{
+
+class NullType : public Type
+{
+public:
+
+ class NullValueType
+ {
+ public:
+ bool operator==(const NullValueType& other) const { return true; }
+ bool operator!=(const NullValueType& other) const { return !(*this == other); }
+ };
+
+ typedef NullValueType ValueType; // represents NULL type, in fact it is not used anywhere
+
+ // Constructor
+ explicit NullType() {}
+
+ // Returns type identifier
+ TypeID typeID() const { return NULL_TYPE; }
+
+ // Reads the value
+ void read(ASN1ValueReader& reader, ValueType&) const { reader.readNull(*this); }
+
+ // Writes the value
+ void write(ASN1ValueWriter& writer, const ValueType&) const { writer.writeNull(*this); }
+
+private:
+
+ DISALLOW_COPY_AND_ASSIGN(NullType);
+};
+
+}
+
+#endif // __NULL_TYPE_HH
View
88 runtime/src/ObjectIdentifier.cc
@@ -1,44 +1,44 @@
-#include "ObjectIdentifier.hh"
-#include "Utils.hh"
-#include "ASN1Exception.hh"
-
-namespace asn1
-{
-
-// Parses and sets oid
-void ObjectIdentifier::_parseAndSetOid(const std::string& value)
-{
- std::vector<std::string> tokens;
-
- utils::split(value, tokens, ".");
- if (tokens.size() <= 0)
- throw ASN1Exception("Object Identifier value '" + value + "' is incorrect");
-
- ObjectIdentifier tmp;
- for (std::vector<std::string>::const_iterator p = tokens.begin(); p != tokens.end(); ++p)
- tmp.push_back(utils::ston<SubOID>(*p)); // TODO: take into case when conversation is not possible
-
- swap(tmp);
-}
-
-// Returns object identifier represented as string (i.e. "1.2.3")
-std::string ObjectIdentifier::getValueAsString() const
-{
- std::string value;
-
- bool isFirst(true);
- for (const_iterator p = begin(); p != end(); ++p)
- {
- if (isFirst)
- {
- value = utils::ntos(*p);
- isFirst = false;
- }
- else
- value += "." + utils::ntos(*p);
- }
-
- return value;
-}
-
-}
+#include "ObjectIdentifier.hh"
+#include "Utils.hh"
+#include "ASN1Exception.hh"
+
+namespace asn1
+{
+
+// Parses and sets oid
+void ObjectIdentifier::_parseAndSetOid(const std::string& value)
+{
+ std::vector<std::string> tokens;
+
+ utils::split(value, tokens, ".");
+ if (tokens.size() <= 0)
+ throw ASN1Exception("Object Identifier value '" + value + "' is incorrect");
+
+ ObjectIdentifier tmp;
+ for (std::vector<std::string>::const_iterator p = tokens.begin(); p != tokens.end(); ++p)
+ tmp.push_back(utils::ston<SubOID>(*p)); // TODO: take into case when conversation is not possible
+
+ swap(tmp);
+}
+
+// Returns object identifier represented as string (i.e. "1.2.3")
+std::string ObjectIdentifier::getValueAsString() const
+{
+ std::string value;
+
+ bool isFirst(true);
+ for (const_iterator p = begin(); p != end(); ++p)
+ {
+ if (isFirst)
+ {
+ value = utils::ntos(*p);
+ isFirst = false;
+ }
+ else
+ value += "." + utils::ntos(*p);
+ }
+
+ return value;
+}
+
+}
View
84 runtime/src/ObjectIdentifier.hh
@@ -1,42 +1,42 @@
-#ifndef __OBJECT_IDENTIFIER_HH
-#define __OBJECT_IDENTIFIER_HH
-
-#include <cstdint>
-
-#include <string>
-#include <vector>
-
-#include "TypeCommon.hh"
-
-namespace asn1
-{
-
-class ObjectIdentifier : public std::vector<SubOID>
-{
-public:
-
- // Default constructor
- ObjectIdentifier() {}
-
- // Constructor
- ObjectIdentifier(const std::vector<SubOID>& value) { assign(value.begin(), value.end()); }
-
- // Constructor: value is a string representation of the object identifier.
- // i.e.: value = "1.2.3.4.5"
- ObjectIdentifier(const std::string& value) { setValue(value); }
-
- // Sets object identifier as string
- void setValue(const std::string& value) { _parseAndSetOid(value); }
-
- // Returns object identifier represented as string (i.e. "1.2.3")
- std::string getValueAsString() const;
-
-private:
-
- // Parses and sets oid
- void _parseAndSetOid(const std::string& value);
-};
-
-}
-
-#endif // __OBJECT_IDENTIFIER_HH
+#ifndef __OBJECT_IDENTIFIER_HH
+#define __OBJECT_IDENTIFIER_HH
+
+#include <cstdint>
+
+#include <string>
+#include <vector>
+
+#include "TypeCommon.hh"
+
+namespace asn1
+{
+
+class ObjectIdentifier : public std::vector<SubOID>
+{
+public:
+
+ // Default constructor
+ ObjectIdentifier() {}
+
+ // Constructor
+ ObjectIdentifier(const std::vector<SubOID>& value) { assign(value.begin(), value.end()); }
+
+ // Constructor: value is a string representation of the object identifier.
+ // i.e.: value = "1.2.3.4.5"
+ ObjectIdentifier(const std::string& value) { setValue(value); }
+
+ // Sets object identifier as string
+ void setValue(const std::string& value) { _parseAndSetOid(value); }
+
+ // Returns object identifier represented as string (i.e. "1.2.3")
+ std::string getValueAsString() const;
+
+private:
+
+ // Parses and sets oid
+ void _parseAndSetOid(const std::string& value);
+};
+
+}
+
+#endif // __OBJECT_IDENTIFIER_HH
View
100 runtime/src/ObjectIdentifierType.hh
@@ -1,50 +1,50 @@
-#ifndef __OBJECT_IDENTIFIER_TYPE_HH
-#define __OBJECT_IDENTIFIER_TYPE_HH
-
-#include "ASN1ValueReader.hh"
-#include "ASN1ValueWriter.hh"
-
-#include "Type.hh"
-
-namespace asn1
-{
-
-class ObjectIdentifierType : public Type
-{
-public:
-
- typedef ObjectIdentifier ValueType;
-
- // Constructor
- explicit ObjectIdentifierType() {}
-
- // Returns type identifier
- virtual TypeID typeID() const { return OBJECT_IDENTIFIER_TYPE; }
-
- // Checks type parameters for validness
- void checkType(const ObjectIdentifier&) const {}
-
- // Reads the value
- void read(ASN1ValueReader& reader, ValueType& value) const
- {
- ValueRestorer<ObjectIdentifier> restorer(value);
-
- reader.readObjectIdentifier(value, *this);
-
- restorer.restoreNotNeeded();
- }
-
- // Writes the value
- void write(ASN1ValueWriter& writer, const ValueType& value) const
- {
- writer.writeObjectIdentifier(value, *this);
- }
-
-private:
-
- DISALLOW_COPY_AND_ASSIGN(ObjectIdentifierType);
-};
-
-}
-
-#endif // __OBJECT_IDENTIFIER_TYPE_HH
+#ifndef __OBJECT_IDENTIFIER_TYPE_HH
+#define __OBJECT_IDENTIFIER_TYPE_HH
+
+#include "ASN1ValueReader.hh"
+#include "ASN1ValueWriter.hh"
+
+#include "Type.hh"
+
+namespace asn1
+{
+
+class ObjectIdentifierType : public Type
+{
+public:
+
+ typedef ObjectIdentifier ValueType;
+
+ // Constructor
+ explicit ObjectIdentifierType() {}
+
+ // Returns type identifier
+ virtual TypeID typeID() const { return OBJECT_IDENTIFIER_TYPE; }
+
+ // Checks type parameters for validness
+ void checkType(const ObjectIdentifier&) const {}
+
+ // Reads the value
+ void read(ASN1ValueReader& reader, ValueType& value) const
+ {
+ ValueRestorer<ObjectIdentifier> restorer(value);
+
+ reader.readObjectIdentifier(value, *this);
+
+ restorer.restoreNotNeeded();
+ }
+
+ // Writes the value
+ void write(ASN1ValueWriter& writer, const ValueType& value) const
+ {
+ writer.writeObjectIdentifier(value, *this);
+ }
+
+private:
+
+ DISALLOW_COPY_AND_ASSIGN(ObjectIdentifierType);
+};
+
+}
+
+#endif // __OBJECT_IDENTIFIER_TYPE_HH
View
66 runtime/src/OctetStringType.cc
@@ -1,33 +1,33 @@
-#include "ASN1Exception.hh"
-#include "Utils.hh"
-#include "OctetStringType.hh"
-
-namespace asn1
-{
-
-// Checks type parameters for validness
-void OctetStringType::checkType(const ValueType& value) const
-{
- for (SizesType::const_iterator p = _sizes.begin(); p != _sizes.end(); ++p)
- {
- if (p->first == p->second && value.size() != p->first)
- {
- throw ASN1Exception(toString() + " value '" + value + "' size is not equal to size '" +
- utils::ntos(p->first) + "'");
- }
-
- if (value.size() < p->first)
- {
- throw ASN1Exception(toString() + " value '" + value + "' size is less than minimum size '" +
- utils::ntos(p->first) + "'");
- }
-
- if (value.size() > p->second)
- {
- throw ASN1Exception(toString() + " value '" + value + "' size is more than maximum size '" +
- utils::ntos(p->second) + "'");
- }
- }
-}
-
-}
+#include "ASN1Exception.hh"
+#include "Utils.hh"
+#include "OctetStringType.hh"
+
+namespace asn1
+{
+
+// Checks type parameters for validness
+void OctetStringType::checkType(const ValueType& value) const
+{
+ for (SizesType::const_iterator p = _sizes.begin(); p != _sizes.end(); ++p)
+ {
+ if (p->first == p->second && value.size() != p->first)
+ {
+ throw ASN1Exception(toString() + " value '" + value + "' size is not equal to size '" +
+ utils::ntos(p->first) + "'");
+ }
+
+ if (value.size() < p->first)
+ {
+ throw ASN1Exception(toString() + " value '" + value + "' size is less than minimum size '" +
+ utils::ntos(p->first) + "'");
+ }
+
+ if (value.size() > p->second)
+ {
+ throw ASN1Exception(toString() + " value '" + value + "' size is more than maximum size '" +
+ utils::ntos(p->second) + "'");
+ }
+ }
+}
+
+}
View
140 runtime/src/OctetStringType.hh
@@ -1,70 +1,70 @@
-#ifndef __OCTET_STRING_TYPE_HH
-#define __OCTET_STRING_TYPE_HH
-
-#include <cstdint>
-#include <vector>
-#include <utility>
-
-#include "ASN1ValueReader.hh"
-#include "ASN1ValueWriter.hh"
-
-#include "Type.hh"
-
-namespace asn1
-{
-
-class OctetStringType : public Type
-{
-public:
-
- typedef OctetString ValueType;
-
- typedef std::pair<int64_t, int64_t> SizeMinMaxType;
- typedef std::vector<SizeMinMaxType> SizesType;
-
- // Constructor
- explicit OctetStringType(const ValueType& defaultValue = "", bool hasDefault = false)
- : _defaultValue(defaultValue), _hasDefault(hasDefault) {}
-
- // Returns type identifier
- virtual TypeID typeID() const { return OCTET_STRING_TYPE; }
-
- const ValueType& defaultValue() const { return _defaultValue; }
- bool hasDefault() const { return _hasDefault; }
-
- // Adds size constraint
- void addSize(int64_t minSize, int64_t maxSize) { _sizes.push_back(SizeMinMaxType(minSize, maxSize)); }
-
- // Checks type parameters for validness
- virtual void checkType(const ValueType& value) const;
-
- // Reads the value
- virtual void read(ASN1ValueReader& reader, ValueType& value) const
- {
- ValueRestorer<ValueType> restorer(value);
-
- reader.readOctetString(value, *this);
-
- restorer.restoreNotNeeded();
- }
-
- // Writes the value
- virtual void write(ASN1ValueWriter& writer, const ValueType& value) const
- {
- writer.writeOctetString(value, *this);
- }
-
-protected:
-
- ValueType _defaultValue;
- bool _hasDefault;
- SizesType _sizes;
-
-private:
-
- DISALLOW_COPY_AND_ASSIGN(OctetStringType);
-};
-
-}
-
-#endif // __OCTET_STRING_TYPE_HH
+#ifndef __OCTET_STRING_TYPE_HH
+#define __OCTET_STRING_TYPE_HH
+
+#include <cstdint>
+#include <vector>
+#include <utility>
+
+#include "ASN1ValueReader.hh"
+#include "ASN1ValueWriter.hh"
+
+#include "Type.hh"
+
+namespace asn1
+{
+
+class OctetStringType : public Type
+{
+public:
+
+ typedef OctetString ValueType;
+
+ typedef std::pair<int64_t, int64_t> SizeMinMaxType;
+ typedef std::vector<SizeMinMaxType> SizesType;
+
+ // Constructor
+ explicit OctetStringType(const ValueType& defaultValue = "", bool hasDefault = false)
+ : _defaultValue(defaultValue), _hasDefault(hasDefault) {}
+
+ // Returns type identifier
+ virtual TypeID typeID() const { return OCTET_STRING_TYPE; }
+
+ const ValueType& defaultValue() const { return _defaultValue; }
+ bool hasDefault() const { return _hasDefault; }
+
+ // Adds size constraint
+ void addSize(int64_t minSize, int64_t maxSize) { _sizes.push_back(SizeMinMaxType(minSize, maxSize)); }
+
+ // Checks type parameters for validness
+ virtual void checkType(const ValueType& value) const;
+
+ // Reads the value
+ virtual void read(ASN1ValueReader& reader, ValueType& value) const
+ {
+ ValueRestorer<ValueType> restorer(value);
+
+ reader.readOctetString(value, *this);
+
+ restorer.restoreNotNeeded();
+ }
+
+ // Writes the value
+ virtual void write(ASN1ValueWriter& writer, const ValueType& value) const
+ {
+ writer.writeOctetString(value, *this);
+ }
+
+protected:
+
+ ValueType _defaultValue;
+ bool _hasDefault;
+ SizesType _sizes;
+
+private:
+
+ DISALLOW_COPY_AND_ASSIGN(OctetStringType);
+};
+
+}
+
+#endif // __OCTET_STRING_TYPE_HH
View
48 runtime/src/PrintableStringType.cc
@@ -1,24 +1,24 @@
-#include "PrintableStringType.hh"
-#include "ASN1Exception.hh"
-
-namespace asn1
-{
-
-// Checks type parameters for validness
-void PrintableStringType::checkType(const ValueType& value) const
-{
- OctetStringType::checkType(value);
-
- for (OctetString::size_type i = 0; i < value.size(); ++i)
- {
- OctetString::value_type c = value[i];
- if (c < 'A' || c > 'Z' || c < 'a' || c > 'z' || c < '0' || c > '9' ||
- c != ' ' || c != '\'' || c != '(' || c != ')' || c != '+' || c != ',' ||
- c != '-' || c != '.' || c != '/' || c != ':' || c != '=' || c != '?')
- {
- throw ASN1Exception(toString() + " value '" + value + "' is not valid");
- }
- }
-}
-
-}
+#include "PrintableStringType.hh"
+#include "ASN1Exception.hh"
+
+namespace asn1
+{
+
+// Checks type parameters for validness
+void PrintableStringType::checkType(const ValueType& value) const
+{
+ OctetStringType::checkType(value);
+
+ for (OctetString::size_type i = 0; i < value.size(); ++i)
+ {
+ OctetString::value_type c = value[i];
+ if (c < 'A' || c > 'Z' || c < 'a' || c > 'z' || c < '0' || c > '9' ||
+ c != ' ' || c != '\'' || c != '(' || c != ')' || c != '+' || c != ',' ||
+ c != '-' || c != '.' || c != '/' || c != ':' || c != '=' || c != '?')
+ {
+ throw ASN1Exception(toString() + " value '" + value + "' is not valid");
+ }
+ }
+}
+
+}
View
92 runtime/src/PrintableStringType.hh
@@ -1,46 +1,46 @@
-#ifndef __PRINTABLE_STRING_TYPE_HH
-#define __PRINTABLE_STRING_TYPE_HH
-
-#include "OctetStringType.hh"
-
-namespace asn1
-{
-
-class PrintableStringType : public OctetStringType
-{
-public:
-
- // Constructor
- explicit PrintableStringType(const ValueType& defaultValue = "", bool hasDefault = false)
- : OctetStringType(defaultValue, hasDefault) {}
-
- // Returns type identifier
- TypeID typeID() const { return PRINTABLE_STRING_TYPE; }
-
- // Checks type parameters for validness
- void checkType(const ValueType& value) const;
-
- // Reads the value
- void read(ASN1ValueReader& reader, ValueType& value) const
- {
- ValueRestorer<ValueType> restorer(value);
-
- reader.readPrintableString(value, *this);
-
- restorer.restoreNotNeeded();
- }
-
- // Writes the value
- void write(ASN1ValueWriter& writer, const ValueType& value) const
- {
- writer.writePrintableString(value, *this);
- }
-
-private:
-
- DISALLOW_COPY_AND_ASSIGN(PrintableStringType);
-};
-
-}
-
-#endif // __PRINTABLE_STRING_TYPE_HH
+#ifndef __PRINTABLE_STRING_TYPE_HH
+#define __PRINTABLE_STRING_TYPE_HH
+
+#include "OctetStringType.hh"
+
+namespace asn1
+{
+
+class PrintableStringType : public OctetStringType
+{
+public:
+
+ // Constructor
+ explicit PrintableStringType(const ValueType& defaultValue = "", bool hasDefault = false)
+ : OctetStringType(defaultValue, hasDefault) {}
+
+ // Returns type identifier
+ TypeID typeID() const { return PRINTABLE_STRING_TYPE; }
+
+ // Checks type parameters for validness
+ void checkType(const ValueType& value) const;
+
+ // Reads the value
+ void read(ASN1ValueReader& reader, ValueType& value) const
+ {
+ ValueRestorer<ValueType> restorer(value);
+
+ reader.readPrintableString(value, *this);
+
+ restorer.restoreNotNeeded();
+ }
+
+ // Writes the value
+ void write(ASN1ValueWriter& writer, const ValueType& value) const
+ {
+ writer.writePrintableString(value, *this);
+ }
+
+private:
+
+ DISALLOW_COPY_AND_ASSIGN(PrintableStringType);
+};
+
+}
+
+#endif // __PRINTABLE_STRING_TYPE_HH
View
192 runtime/src/SequenceOfType.hh
@@ -1,96 +1,96 @@
-#ifndef __SEQUENCE_OF_TYPE_HH
-#define __SEQUENCE_OF_TYPE_HH
-
-#include <vector>
-
-#include "ASN1ValueReader.hh"
-#include "ASN1ValueWriter.hh"
-
-#include "BaseSequenceOfType.hh"
-
-namespace asn1
-{
-
-template <typename TypeItemType>
-class SequenceOfType : public BaseSequenceOfType
-{
-public:
-
- typedef std::vector<typename TypeItemType::ValueType> ValueType;
- typedef TypeItemType InnerType;
-
- // Constructor
- explicit SequenceOfType(TypeItemType* innerType, uint64_t minSize = 0, uint64_t maxSize = 0)
- : BaseSequenceOfType(minSize, maxSize), _innerType(innerType) {}
-
- // Destructor
- ~SequenceOfType() { delete _innerType; }
-
- // Returns string representation of type
- std::string toString() const
- {
- return BaseSequenceOfType::toString() + " { " + _innerType->toString() + " }";
- }
-
- // Returns reference to inner type
- TypeItemType& innerType() { return *_innerType; }
-
- // Checks type parameters for validness
- void checkType(const ValueType& value) const;
-
- void read(ASN1ValueReader& reader, ValueType& value) const;
- void write(ASN1ValueWriter& writer, const ValueType& value) const;
-
-private:
-
- TypeItemType* _innerType;
-
- DISALLOW_COPY_AND_ASSIGN(SequenceOfType);
-};
-
-template <typename TypeItemType>
-void SequenceOfType<TypeItemType>::checkType(const ValueType& value) const
-{
- checkSize(value.size());
- for (typename ValueType::const_iterator p = value.begin(); p != value.end(); ++p)
- _innerType->checkType(*p);
-}
-
-template <typename TypeItemType>
-void SequenceOfType<TypeItemType>::read(ASN1ValueReader& reader, ValueType& value) const
-{
- ValueRestorer<ValueType> restorer(value);
-
- // clear previous values
- value.clear();
-
- // allocate space for value depending on minimal size
- if (hasMinSize())
- value.reserve(static_cast<typename ValueType::size_type>(minSize()));
-
- // perform read of components
- reader.readSequenceOfBegin(*this);
- while (!reader.isSequenceOfEnd(*this))
- {
- typename TypeItemType::ValueType item;
- _innerType->read(reader, item);
- value.push_back(item);
- }
- reader.readSequenceOfEnd(*this);
-
- // do not restore value if reading completed without exceptions
- restorer.restoreNotNeeded();
-}
-
-template <typename TypeItemType>
-void SequenceOfType<TypeItemType>::write(ASN1ValueWriter& writer, const ValueType& value) const
-{
- writer.writeSequenceOfBegin(*this);
- for (typename ValueType::const_iterator p = value.begin(); p != value.end(); ++p)
- _innerType->write(writer, *p);
- writer.writeSequenceOfEnd(*this);
-}
-
-}
-
-#endif // __SEQUENCE_OF_TYPE_HH
+#ifndef __SEQUENCE_OF_TYPE_HH
+#define __SEQUENCE_OF_TYPE_HH
+
+#include <vector>
+
+#include "ASN1ValueReader.hh"
+#include "ASN1ValueWriter.hh"
+
+#include "BaseSequenceOfType.hh"
+
+namespace asn1
+{
+
+template <typename TypeItemType>
+class SequenceOfType : public BaseSequenceOfType
+{
+public:
+
+ typedef std::vector<typename TypeItemType::ValueType> ValueType;
+ typedef TypeItemType InnerType;
+
+ // Constructor
+ explicit SequenceOfType(TypeItemType* innerType, uint64_t minSize = 0, uint64_t maxSize = 0)
+ : BaseSequenceOfType(minSize, maxSize), _innerType(innerType) {}
+
+ // Destructor
+ ~SequenceOfType() { delete _innerType; }
+
+ // Returns string representation of type
+ std::string toString() const
+ {
+ return BaseSequenceOfType::toString() + " { " + _innerType->toString() + " }";
+ }
+
+ // Returns reference to inner type
+ TypeItemType& innerType() { return *_innerType; }
+
+ // Checks type parameters for validness
+ void checkType(const ValueType& value) const;
+
+ void read(ASN1ValueReader& reader, ValueType& value) const;
+ void write(ASN1ValueWriter& writer, const ValueType& value) const;
+
+private:
+
+ TypeItemType* _innerType;
+
+ DISALLOW_COPY_AND_ASSIGN(SequenceOfType);
+};
+
+template <typename TypeItemType>
+void SequenceOfType<TypeItemType>::checkType(const ValueType& value) const
+{
+ checkSize(value.size());
+ for (typename ValueType::const_iterator p = value.begin(); p != value.end(); ++p)
+ _innerType->checkType(*p);
+}
+
+template <typename TypeItemType>
+void SequenceOfType<TypeItemType>::read(ASN1ValueReader& reader, ValueType& value) const
+{
+ ValueRestorer<ValueType> restorer(value);
+
+ // clear previous values
+ value.clear();
+
+ // allocate space for value depending on minimal size
+ if (hasMinSize())
+ value.reserve(static_cast<typename ValueType::size_type>(minSize()));
+
+ // perform read of components
+ reader.readSequenceOfBegin(*this);
+ while (!reader.isSequenceOfEnd(*this))
+ {
+ typename TypeItemType::ValueType item;
+ _innerType->read(reader, item);
+ value.push_back(item);
+ }
+ reader.readSequenceOfEnd(*this);
+
+ // do not restore value if reading completed without exceptions
+ restorer.restoreNotNeeded();
+}
+
+template <typename TypeItemType>
+void SequenceOfType<TypeItemType>::write(ASN1ValueWriter& writer, const ValueType& value) const
+{
+ writer.writeSequenceOfBegin(*this);
+ for (typename ValueType::const_iterator p = value.begin(); p != value.end(); ++p)
+ _innerType->write(writer, *p);
+ writer.writeSequenceOfEnd(*this);
+}
+
+}
+
+#endif // __SEQUENCE_OF_TYPE_HH
View
52 runtime/src/SequenceType.hh
@@ -1,26 +1,26 @@
-#ifndef __SEQUENCE_TYPE_HH
-#define __SEQUENCE_TYPE_HH
-
-#include "Type.hh"
-
-namespace asn1
-{
-
-class SequenceType : public Type
-{
-public:
-
- // Constructor
- explicit SequenceType() {}
-
- // Returns type identifier
- TypeID typeID() const { return SEQUENCE_TYPE; }
-
-private:
-
- DISALLOW_COPY_AND_ASSIGN(SequenceType);
-};
-
-}
-
-#endif // __SEQUENCE_TYPE_HH
+#ifndef __SEQUENCE_TYPE_HH
+#define __SEQUENCE_TYPE_HH
+
+#include "Type.hh"
+
+namespace asn1
+{
+
+class SequenceType : public Type
+{
+public:
+
+ // Constructor
+ explicit SequenceType() {}
+
+ // Returns type identifier
+ TypeID typeID() const { return SEQUENCE_TYPE; }
+
+private:
+
+ DISALLOW_COPY_AND_ASSIGN(SequenceType);
+};
+
+}
+
+#endif // __SEQUENCE_TYPE_HH
View
192 runtime/src/SetOfType.hh
@@ -1,96 +1,96 @@
-#ifndef __SET_OF_TYPE_HH
-#define __SET_OF_TYPE_HH
-
-#include <vector>
-
-#include "ASN1ValueReader.hh"
-#include "ASN1ValueWriter.hh"
-
-#include "BaseSetOfType.hh"
-
-namespace asn1
-{
-
-template <typename TypeItemType>
-class SetOfType : public BaseSetOfType
-{
-public:
-
- typedef std::vector<typename TypeItemType::ValueType> ValueType;
- typedef TypeItemType InnerType;
-
- // Constructor
- explicit SetOfType(TypeItemType* innerType, uint64_t minSize = 0, uint64_t maxSize = 0)
- : BaseSetOfType(minSize, maxSize), _innerType(innerType) {}
-
- // Destructor
- ~SetOfType() { delete _innerType; }
-
- // Returns string representation of type
- std::string toString() const
- {
- return BaseSetOfType::toString() + " { " + _innerType->toString() + " }";
- }
-
- // Returns reference to inner type
- TypeItemType& innerType() { return *_innerType; }
-
- // Checks type parameters for validness
- void checkType(const ValueType& value) const;
-
- void read(ASN1ValueReader& reader, ValueType& value) const;
- void write(ASN1ValueWriter& writer, const ValueType& value) const;
-
-private:
-
- TypeItemType* _innerType;
-
- DISALLOW_COPY_AND_ASSIGN(SetOfType);
-};
-
-template <typename TypeItemType>
-void SetOfType<TypeItemType>::checkType(const ValueType& value) const
-{
- checkSize(value.size());
- for (typename ValueType::const_iterator p = value.begin(); p != value.end(); ++p)
- _innerType->checkType(*p);
-}
-
-template <typename TypeItemType>
-void SetOfType<TypeItemType>::read(ASN1ValueReader& reader, ValueType& value) const
-{
- ValueRestorer<ValueType> restorer(value);
-
- // clear previous values
- value.clear();
-
- // allocate space for value depending on minimal size
- if (hasMinSize())
- value.reserve(static_cast<typename ValueType::size_type>(minSize()));
-
- // perform read of components
- reader.readSetOfBegin(*this);
- while (!reader.isSetOfEnd(*this))
- {
- typename TypeItemType::ValueType item;
- _innerType->read(reader, item);
- value.push_back(item);
- }
- reader.readSetOfEnd(*this);
-
- // do not restore value if reading completed without exceptions
- restorer.restoreNotNeeded();
-}
-
-template <typename TypeItemType>
-void SetOfType<TypeItemType>::write(ASN1ValueWriter& writer, const ValueType& value) const
-{
- writer.writeSetOfBegin(*this);
- for (typename ValueType::const_iterator p = value.begin(); p != value.end(); ++p)
- _innerType->write(writer, *p);
- writer.writeSetOfEnd(*this);
-}
-
-}
-
-#endif // __SET_OF_TYPE_HH
+#ifndef __SET_OF_TYPE_HH
+#define __SET_OF_TYPE_HH
+
+#include <vector>
+
+#include "ASN1ValueReader.hh"
+#include "ASN1ValueWriter.hh"
+
+#include "BaseSetOfType.hh"
+
+namespace asn1
+{
+
+template <typename TypeItemType>
+class SetOfType : public BaseSetOfType
+{
+public:
+
+ typedef std::vector<typename TypeItemType::ValueType> ValueType;
+ typedef TypeItemType InnerType;
+
+ // Constructor
+ explicit SetOfType(TypeItemType* innerType, uint64_t minSize = 0, uint64_t maxSize = 0)
+ : BaseSetOfType(minSize, maxSize), _innerType(innerType) {}
+
+ // Destructor
+ ~SetOfType() { delete _innerType; }
+
+ // Returns string representation of type
+ std::string toString() const
+ {
+ return BaseSetOfType::toString() + " { " + _innerType->toString() + " }";
+ }
+
+ // Returns reference to inner type
+ TypeItemType& innerType() { return *_innerType; }
+
+ // Checks type parameters for validness
+ void checkType(const ValueType& value) const;
+
+ void read(ASN1ValueReader& reader, ValueType& value) const;
+ void write(ASN1ValueWriter& writer, const ValueType& value) const;
+
+private:
+
+ TypeItemType* _innerType;
+
+ DISALLOW_COPY_AND_ASSIGN(SetOfType);
+};
+
+template <typename TypeItemType>
+void SetOfType<TypeItemType>::checkType(const ValueType& value) const
+{
+ checkSize(value.size());
+ for (typename ValueType::const_iterator p = value.begin(); p != value.end(); ++p)
+ _innerType->checkType(*p);
+}
+
+template <typename TypeItemType>
+void SetOfType<TypeItemType>::read(ASN1ValueReader& reader, ValueType& value) const
+{
+ ValueRestorer<ValueType> restorer(value);
+
+ // clear previous values
+ value.clear();
+
+ // allocate space for value depending on minimal size
+ if (hasMinSize())
+ value.reserve(static_cast<typename ValueType::size_type>(minSize()));
+
+ // perform read of components
+ reader.readSetOfBegin(*this);
+ while (!reader.isSetOfEnd(*this))
+ {
+ typename TypeItemType::ValueType item;
+ _innerType->read(reader, item);
+ value.push_back(item);
+ }
+ reader.readSetOfEnd(*this);
+
+ // do not restore value if reading completed without exceptions
+ restorer.restoreNotNeeded();
+}
+
+template <typename TypeItemType>
+void SetOfType<TypeItemType>::write(ASN1ValueWriter& writer, const ValueType& value) const
+{
+ writer.writeSetOfBegin(*this);
+ for (typename ValueType::const_iterator p = value.begin(); p != value.end(); ++p)
+ _innerType->write(writer, *p);
+ writer.writeSetOfEnd(*this);
+}
+
+}
+
+#endif // __SET_OF_TYPE_HH
View
52