// Looks for the last occurence of 'object' in 'StringView', // returns index or INVALID if there are no occurences. // The behavior is undefined unless 'StringView' was initialized. //C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#: //ORIGINAL LINE: ulong findLast(const char& object) const; //C++ TO C# CONVERTER TODO TASK: The implementation of the following method could not be found: // ulong findLast(char @object); // Looks for the first occurence of 'other' in 'StringView', // returns index or INVALID if there are no occurences. // The behavior is undefined unless both strings were initialized. //C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#: //ORIGINAL LINE: ulong findLast(StringView other) const public ulong findLast(StringView other) { Debug.Assert(data != null || size == 0); Debug.Assert(other.data != null || other.size == 0); if (size >= other.size) { Size i = size - other.size; for (Size j = 0; !(i < j); ++j) { for (Size k = 0; ; ++k) { if (k == other.size) { return(i - j); } if (!(*(data + (i - j + k)) == *(other.data + k))) { break; } } } } return(INVALID); }
// Return false if 'StringView' does not contain 'object'. // The behavior is undefined unless 'StringView' was initialized. //C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#: //ORIGINAL LINE: bool contains(const char& object) const; //C++ TO C# CONVERTER TODO TASK: The implementation of the following method could not be found: // bool contains(char @object); // Return false if 'StringView' does not contain 'other'. // The behavior is undefined unless both strings were initialized. //C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#: //ORIGINAL LINE: bool contains(StringView other) const public bool contains(StringView other) { Debug.Assert(data != null || size == 0); Debug.Assert(other.data != null || other.size == 0); if (size >= other.size) { Size i = size - other.size; for (Size j = 0; !(i < j); ++j) { for (Size k = 0; ; ++k) { if (k == other.size) { return(true); } if (!(*(data + j + k) == *(other.data + k))) { break; } } } } return(false); }
public static override bool functorMethod(ref bool value, Common.StringView name) { char boolVal = value; checkedWrite(boolVal, 1); return(true); }
public Level(Common.StringView nm, ulong arraySize) { this.name = nm; this.state = new CryptoNote.KVBinaryOutputStreamSerializer.State.ArrayPrefix; //C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created: //ORIGINAL LINE: this.count = arraySize; this.count.CopyFrom(arraySize); }
// Copy constructor. // Performs default action - bitwise copying of source object. // The behavior is undefined unless 'other' 'StringView' is in defined state, that is 'data' != 'nullptr' || 'size' == 0 public StringView(StringView other) { this.data = other.data; //C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created: //ORIGINAL LINE: this.size = other.size; this.size.CopyFrom(other.size); Debug.Assert(data != null || size == 0); }
public override bool BeginObject(Common.StringView name) { checkArrayPreamble(new ushort(GlobalMembers.BIN_KV_SERIALIZE_TYPE_OBJECT)); m_stack.Add(new Level(new Common.StringView(name))); m_objectsStack.Add(new MemoryStream()); return(true); }
public static override bool functorMethod(string value, Common.StringView name) { writeElementPrefix(new ushort(GlobalMembers.BIN_KV_SERIALIZE_TYPE_STRING), new Common.StringView(name)); auto @out = stream(); GlobalMembers.writeArraySize(@out, value.Length); write(@out, value.data(), value.Length); return(true); }
public override bool Binary(object value, ulong size, Common.StringView name) { if (size > 0) { writeElementPrefix(new ushort(GlobalMembers.BIN_KV_SERIALIZE_TYPE_STRING), new Common.StringView(name)); auto @out = stream(); GlobalMembers.writeArraySize(@out, new ulong(size)); write(@out, value, size); } return(true); }
private void writeElementPrefix(ushort type, Common.StringView name) { Debug.Assert(m_stack.Count); checkArrayPreamble(new ushort(type)); Level level = m_stack[m_stack.Count - 1]; if (level.state != State.Array) { if (!name.isEmpty()) { auto s = stream(); GlobalMembers.writeElementName(s, new Common.StringView(name)); write(s, type, 1); } ++level.count; } }
// Return false if 'StringView' does not contain 'object' at the beginning. // The behavior is undefined unless 'StringView' was initialized. //C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#: //ORIGINAL LINE: bool beginsWith(const char& object) const; //C++ TO C# CONVERTER TODO TASK: The implementation of the following method could not be found: // bool beginsWith(char @object); // Return false if 'StringView' does not contain 'other' at the beginning. // The behavior is undefined unless both strings were initialized. //C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#: //ORIGINAL LINE: bool beginsWith(StringView other) const public bool beginsWith(StringView other) { Debug.Assert(data != null || size == 0); Debug.Assert(other.data != null || other.size == 0); if (size >= other.size) { for (Size i = 0; ; ++i) { if (i == other.size) { return(true); } if (!(*(data + i) == *(other.data + i))) { break; } } } return(false); }
public static override bool functorMethod(string value, Common.StringView name) { ulong size = new ulong(); readVarint(stream, size); /* Can't take up more than a block size */ if (size > CryptoNote.parameters.MAX_EXTRA_SIZE && (string)name.getData() == "mm_tag") { List <char> temp = new List <char>(); temp.Resize(1); /* Read to the end of the stream, and throw the data away, otherwise * transaction won't validate. There should be a better way to do this? */ while (size > 0) { checkedRead(ref temp[0], 1); size--; } value = ""; return(true); } if (size > 0) { List <char> temp = new List <char>(); temp.Resize(size); checkedRead(ref temp[0], new ulong(size)); value.reserve(size); value.assign(temp[0], size); } else { value = ""; } return(true); }
// Return false if 'StringView' does not contain 'object' at the end. // The behavior is undefined unless 'StringView' was initialized. //C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#: //ORIGINAL LINE: bool endsWith(const char& object) const; //C++ TO C# CONVERTER TODO TASK: The implementation of the following method could not be found: // bool endsWith(char @object); // Return false if 'StringView' does not contain 'other' at the end. // The behavior is undefined unless both strings were initialized. //C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#: //ORIGINAL LINE: bool endsWith(StringView other) const public bool endsWith(StringView other) { Debug.Assert(data != null || size == 0); Debug.Assert(other.data != null || other.size == 0); if (size >= other.size) { Size i = size - other.size; for (Size j = 0; ; ++j) { if (j == other.size) { return(true); } if (!(*(data + i + j) == *(other.data + j))) { break; } } } return(false); }
public override bool BeginObject(Common.StringView name) { return(true); }
//C++ TO C# CONVERTER TODO TASK: The original C++ template specifier was replaced with a C# generic specifier, which may not produce the same behavior: //ORIGINAL LINE: template<typename T> public static new bool functorMethod <T>(T value, Common.StringView name) { return(base.FunctorMethod(value, name)); }
public override bool Binary(string value, Common.StringView name) { return(this.functorMethod(value, name)); }
public override bool Binary(object value, ulong size, Common.StringView name) { checkedRead(ref (char)value, new ulong(size)); return(true); }
public override bool Binary(string value, Common.StringView name) { //C++ TO C# CONVERTER TODO TASK: There is no equivalent to 'const_cast' in C#: return(binary(const_cast <char>(value.data()), value.Length, new Common.StringView(name))); }
public static override bool functorMethod(ulong value, Common.StringView name) { readVarint(stream, value); return(true); }
public override bool beginArray(ulong size, Common.StringView name) { writeVarint(stream, size); return(true); }
public override bool Binary(string value, Common.StringView name) { // write as string (with size prefix) return(this.functorMethod(value, name)); }
public static override bool functorMethod(string value, Common.StringView name) { writeVarint(stream, value.Length); checkedWrite(value.data(), value.Length); return(true); }
public override bool beginArray(ulong size, Common.StringView name) { m_stack.Add(new Level(new Common.StringView(name), new ulong(size))); return(true); }
public static override bool functorMethod(ref bool value, Common.StringView name) { writeElementPrefix(new ushort(GlobalMembers.BIN_KV_SERIALIZE_TYPE_BOOL), new Common.StringView(name)); GlobalMembers.writePod(stream(), value); return(true); }
public override bool beginArray(ulong size, Common.StringView name) { GlobalMembers.readVarintAs <ulong>(stream, ref size); return(true); }
public static override bool functorMethod(int value, Common.StringView name) { writeVarint(stream, (uint)value); return(true); }
public static override bool functorMethod(long value, Common.StringView name) { GlobalMembers.readVarintAs <ulong>(stream, ref value); return(true); }
public static override bool functorMethod(ref bool value, Common.StringView name) { value = read <ushort>(stream) != 0; return(true); }
public static override bool functorMethod(ref double value, Common.StringView name) { Debug.Assert(false); //the method is not supported for this type of serialization throw new System.Exception("double serialization is not supported in BinaryInputStreamSerializer"); return(false); }
public Level(Common.StringView nm) { this.name = nm; this.state = new CryptoNote.KVBinaryOutputStreamSerializer.State.Object; this.count = 0; }