Beispiel #1
0
	UnicodeChar ref(size_t i) const {
		if(i < l1) {
			return one->ref(i);
		} else {
			return two->ref(i - l1);
		}
	}
Beispiel #2
0
	void cut(string_ptr& into, size_t i, size_t l) const {
		/*get the start*/
		BYTE const* nstart = start;
		repeat(i) utf8_adv(nstart);
		/*for the trivial case where we would reach
		the end of this string, don't bother
		iterating over the rest of the string
		*/
		if(i + l == len) {
			into.reset(
				new Utf8Impl(buffer, nstart, end, l)
			);
			return;
		}
		/*iterate over the substring.  since we are
		iterating over the substring anyway, we might
		as well check if the substring is pure ascii.
		*/
		bool nonascii = false;
		BYTE const* nend = nstart;
		repeat(l) utf8_adv_check(nend, nonascii);
		if(nonascii) {
			into.reset(
				new Utf8Impl(buffer, nstart, nend, l)
			);
			return;
		} else {
			into.reset(
				new AsciiImpl(buffer, nstart, l)
			);
			return;
		}
	}
Beispiel #3
0
void RopeImpl::base_append_string_impl(
		string_ptr& dest,
		string_ptr const& one,
		string_ptr const& two,
		size_t d1,
		size_t d2) {
	size_t nd =
		d1 > d2 ?		d1 + 1 :
		/*otherwise*/		d2 + 1 ;
	dest.reset(
		new RopeImpl(one, two, nd, one->length())
	);
}
Beispiel #4
0
bool isOwnMessage(string_ptr message)
{
    if(message->find(*promptCpy) != string::npos)
        return true;
    else
        return false;
}
Beispiel #5
0
bool Client::isOwnMessage(string_ptr message)
{
    if(message->find(*strPrompt) != string::npos)
        return true;
    else
        return false;
}
Beispiel #6
0
bool clientSentExit(string_ptr message)
{
	if(message->find("exit") != string::npos)
		return true;
	else
		return false;
}
Beispiel #7
0
	/*direct construction, only allowed for friends*/
	RopeImpl(
			string_ptr const& n1,
			string_ptr const& n2,
			size_t nd,
			size_t nl1)
		: one(n1), two(n2), depth(nd), l1(nl1),
		  HlStringImpl(nl1 + n2->length()) { }
Beispiel #8
0
	void CA210IntensityAnalyzer::setChannel(int no, string_ptr id) {
	    if (false == dummyMode) {
		//設定no
		ca210api->setChannelNO(no);
		//設定id
		ca210api->setChannelID(WideString(id->c_str()));
	    }
	};
Beispiel #9
0
	void point_at(
			HlStringBufferPointer& b,
			boost::shared_ptr<HlStringPath>& p,
			size_t i) const {
		if(likely(i < l1)) {
			/*push the second string onto the string path, to
			be traversed after the first one.
			*/
			HlStringPath::push(two, p);
			one->point_at(b, p, i);
		} else {
			/*the pointed value is after the first string,
			so point only within the second string,
			ignoring the first.
			*/
			two->point_at(b, p, i - l1);
		}
	}
Beispiel #10
0
void RopeImpl::append_string_impl(
		string_ptr& dest,
		string_ptr const& one,
		string_ptr const& two) {
	/*trivial cases where one string is empty*/
	if(one->length() == 0) {
		dest = two;
		return;
	} else if(two->length() == 0){
		dest = one;
		return;
	}
	/*check for catting two short Ascii strings.*/
	AsciiImpl* as1 = dynamic_cast<AsciiImpl*>(one.get());
	if(as1 && as1->length() < (ASCII_BUFFER_LEVEL / 2)) {
		AsciiImpl* as2 = dynamic_cast<AsciiImpl*>(two.get());
		if(as2 && as2->length() < (ASCII_BUFFER_LEVEL / 2)) {
			size_t l1 = as1->length();
			size_t l2 = as2->length();
			/*create a single buffer and concat them*/
			boost::shared_array<BYTE> nbp(new BYTE(l1 + l2));
			std::copy(as2->start, &as2->start[l2],
				std::copy(as1->start, &as1->start[l1],
					&nbp[0]
				)
			);
			dest.reset(new AsciiImpl(nbp, &nbp[0], l1 + l2));
			return;
		}
	}
	size_t d1 = one->rope_depth();
	size_t d2 = two->rope_depth();
	if(d1 > d2 + 1) {
		/*first subtree is pretty heavy, check if:
		  one    two
		   /\     |
		  /\ c    d
		 a  b
		If so, do this:
		    /\
		   /  \
		  /\  /\
		 a b  c d
		*/
		RopeImpl& r1 = static_cast<RopeImpl&>(*one);
		size_t d1_2 = r1.two->rope_depth();
		if(d1_2 <= d2 + 1) {
			string_ptr tmp;
			base_append_string_impl(tmp, r1.two, two, d1_2, d2);
			append_string_impl(dest, r1.one, tmp);
			return;
		}
	}
	base_append_string_impl(dest, one, two, d1, d2);
}
Beispiel #11
0
	void cut(string_ptr& into, size_t i, size_t l) const {
		size_t il_extent = i + l;
		/*check for trivial cases*/
		if(il_extent <= l1) {
			/*completely within one*/
			one->cut(into, i, l);
			return;
		} else if(i >= l1) {
			/*completely within two*/
			two->cut(into, i - l1, l);
			return;
		} else if(i == 0) {
			/*contains one uncut, but with two possibly cut*/
			string_ptr cut_two;
			two->cut(cut_two, 0, il_extent - l1);
			append_string_impl(into, one, cut_two);
			return;
		} else if(il_extent == len) {
			/*one is cut, but followed by the entire two*/
			string_ptr cut_one;
			one->cut(cut_one, i, l1 - i);
			append_string_impl(into, cut_one, two);
			return;
		} else {
			/*both are cut*/
			string_ptr cut_one;
			one->cut(cut_one, i, l1 - i);
			string_ptr cut_two;
			two->cut(cut_two, 0, il_extent - l1);
			append_string_impl(into, cut_one, cut_two);
			return;
		}
	}
Beispiel #12
0
	void to_cpp_string(std::string& into) const {
		one->to_cpp_string(into);
		two->to_cpp_string(into);
	}
Beispiel #13
0
	void cut(string_ptr& into, size_t i, size_t l) const {
		into.reset(
			new AsciiImpl(buffer, start + i, l)
		);
	}