forked from connamara/quickfixn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/oclancy/quickfixn
- Loading branch information
Showing
41 changed files
with
502 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,3 +164,8 @@ FakesAssemblies/ | |
|
||
# JetBrains Rider | ||
.idea | ||
|
||
# stuff from the gh-pages branch I guess | ||
.sass-cache/ | ||
_site/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
| ||
namespace QuickFix.Fields.Converters | ||
{ | ||
/// <summary> | ||
/// convert Int64 to/from string | ||
/// </summary> | ||
public static class AsciiValidator | ||
{ | ||
public const int ASCII_ZERO = 48; | ||
public const int ASCII_NINE = 57; | ||
public const int ASCII_MINUS = 45; | ||
|
||
/// <summary> | ||
/// TODO can we use NumberFormatInfo or NumberStyles to avoid this bit of ASCII hackery? | ||
/// Validates that a string looks like number (for use before conversion to an int, ulong, etc.). | ||
/// </summary> | ||
/// <param name="i"></param> | ||
/// <returns></returns> | ||
public static void Validate(string i) | ||
{ | ||
if ((null == i) || (i.Length < 1)) | ||
throw new FieldConvertError("The argument string cannot be null or empty"); | ||
int asciiValOfFirstChar = System.Convert.ToInt32(i[0]); | ||
if ((asciiValOfFirstChar < ASCII_ZERO) || (asciiValOfFirstChar > ASCII_NINE)) | ||
if (asciiValOfFirstChar != ASCII_MINUS) | ||
throw new FieldConvertError("Could not convert string to int (" + i + "): The first character must be a digit or a minus sign"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
| ||
namespace QuickFix.Fields.Converters | ||
{ | ||
/// <summary> | ||
/// convert UInt64 to/from string | ||
/// </summary> | ||
public static class ULongConverter | ||
{ | ||
/// <summary> | ||
/// Converts string to ulong. | ||
/// </summary> | ||
/// <param name="i"></param> | ||
/// <returns></returns> | ||
public static ulong Convert(string i) | ||
{ | ||
try | ||
{ | ||
AsciiValidator.Validate(i); | ||
return System.Convert.ToUInt64(i); | ||
} | ||
catch (System.FormatException e) | ||
{ | ||
throw new FieldConvertError("Could not convert string to ulong (" + i + ")", e); | ||
} | ||
catch (System.OverflowException e) | ||
{ | ||
throw new FieldConvertError("Could not convert string to ulong (" + i + ")", e); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// convert ulong to string | ||
/// </summary> | ||
public static string Convert(System.UInt64 i) | ||
{ | ||
return i.ToString(); | ||
} | ||
} | ||
} |
Oops, something went wrong.