Commit fc1e4db7 authored by baire's avatar baire
Browse files

added MoveAt & MovePast

parent 85ae46ce
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -15,8 +15,8 @@ public:
	}

	bool Match (Buffer& buffer) {
		mStart = iterator (buffer.GetValue().c_str() + (buffer.GetPosition() / 8));
		mStop = iterator (buffer.GetValue().c_str() + (buffer.GetEndMarker() / 8));
		mStart = iterator (reinterpret_cast<const char*> (buffer.GetValueBin()) + (buffer.GetPosition() / 8));
		mStop = iterator (reinterpret_cast<const char*> (buffer.GetValueBin()) + (buffer.GetEndMarker() / 8));

		int result = boost::regex_search (mStart, mStop, mResults, mRegex);

@@ -56,6 +56,16 @@ public:
		return *(&*mResults[id].second - 1); // FIXME: how about null match ?
	}

	void MovePast (Buffer& buffer, int id = 0)
	{
		buffer.SetPosition ((&*mResults[id].second - reinterpret_cast<const char*> (buffer.GetValueBin())) * 8);
	}
	
	void MoveAt (Buffer& buffer, int id = 0)
	{
		buffer.SetPosition ((&*mResults[id].first - reinterpret_cast<const char*> (buffer.GetValueBin())) * 8);
	}

	void Error (Variable* v, Buffer& buffer) throw (DecodeError) {

		std::string message ("cannot match regex /");
@@ -767,7 +777,7 @@ void SentProtocol::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
	if (id) {
		static Regex reg_slash ("^/");
		reg_slash.AssertMatch (buffer, this);
		buffer.SetPosition(buffer.GetPosition() + reg_slash.GetMatchedLength());
		reg_slash.MovePast (buffer);
	}

	static Regex reg_sp ("^" SIPREG_TOKEN);
@@ -785,7 +795,7 @@ void ViaBody::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
	switch (id) {
	case id_sentBy:
		reg_lws.AssertMatch (buffer, this);
		buffer.SetPosition(buffer.GetPosition() + reg_lws.GetMatchedLength());
		reg_lws.MovePast (buffer);
		break;
	case id_viaParams:
		SetHypFieldIsPresent (id, reg_semi.Match (buffer) ? 1 : 0);