示例#1
0
 struct timeval timeval() const
 {
   struct timeval t;
   t.tv_sec = secs();
   t.tv_usec = us() - (t.tv_sec * MILLISECONDS);
   return t;
 }
示例#2
0
int main(int argc, char** argv){
  UnicodeProperties props;
  UnicodeString us(argv[1]);
  BiDir bidi(&props);
  bidi.determineBidiLevels(us);
  return 0;
}
示例#3
0
QMap<QString, shared_ptr<ChatUser> >
ConnectorOld::parseChatUsers(QStringList recvMessage)
{
  QMap<QString, shared_ptr<ChatUser> > users;
  QString channelId = recvMessage.at(0);
  recvMessage.pop_front(); // Remove channelId
  QStringList usersList = recvMessage.join("\t").split("\r");
  usersList.pop_back();   // Remove empty string

  QStringList::const_iterator it;
  for (it = usersList.constBegin(); it != usersList.constEnd(); ++it)
  {
    QStringList user = (*it).split('\t');
    shared_ptr<ChatUser> us(
          new ChatUser(
            this,
            channelId,
            user.at(0),
            user.at(1),
            user.at(2),
            user.at(3)));
    users.insert(us->id(), us);
  }
  return users;
}
示例#4
0
void testUtf8Bwt(std::string const & fn)
{
	::libmaus::util::Utf8String us(fn);

	typedef ::libmaus::util::Utf8String::saidx_t saidx_t;
	::libmaus::autoarray::AutoArray<saidx_t,::libmaus::autoarray::alloc_type_c> SA = us.computeSuffixArray32();

	// produce bwt
	for ( uint64_t i = 0; i < SA.size(); ++i )
		if ( SA[i] )
			SA[i] = us[SA[i]-1];
		else
			SA[i] = -1;

	// produce huffman shaped wavelet tree of bwt
	::std::map<int64_t,uint64_t> chist = us.getHistogramAsMap();
	chist[-1] = 1;
	::libmaus::huffman::HuffmanTreeNode::shared_ptr_type htree = ::libmaus::huffman::HuffmanBase::createTree(chist);

	::libmaus::util::TempFileNameGenerator tmpgen(fn+"_tmp",3);
	::libmaus::util::FileTempFileContainer tmpcnt(tmpgen);
	::libmaus::wavelet::ImpExternalWaveletGeneratorHuffman IEWGH(htree.get(),tmpcnt);
	
	IEWGH.putSymbol(us[us.size()-1]);
	for ( uint64_t i = 0; i < SA.size(); ++i )
		IEWGH.putSymbol(SA[i]);
	IEWGH.createFinalStream(fn+".hwt");

	// load huffman shaped wavelet tree of bwt
	::libmaus::wavelet::ImpHuffmanWaveletTree::unique_ptr_type IHWT
		(::libmaus::wavelet::ImpHuffmanWaveletTree::load(fn+".hwt"));
		
	// check rank counts
	for ( ::std::map<int64_t,uint64_t>::const_iterator ita = chist.begin(); ita != chist.end(); ++ita )
		assert ( IHWT->rank(ita->first,SA.size()) == ita->second );
		
	/* cumulative symbol freqs, shifted by 1 to accomodate for terminator -1 */
	int64_t const maxsym = chist.rbegin()->first;
	int64_t const shiftedmaxsym = maxsym+1;
	::libmaus::autoarray::AutoArray<uint64_t> D(shiftedmaxsym+1);
	for ( ::std::map<int64_t,uint64_t>::const_iterator ita = chist.begin(); ita != chist.end(); ++ita )
		D [ ita->first + 1 ] = ita->second;
	D.prefixSums();
	
	// terminator has rank 0 and is at position us.size()
	uint64_t rank = 0;
	int64_t pos = us.size();
	
	// decode text backward from bwt
	while ( --pos >= 0 )
	{
		std::pair< int64_t,uint64_t> const is = IHWT->inverseSelect(rank);
		rank = D[is.first+1] + is.second;		
		assert ( is.first == us[pos] );
	}
	
	// remove huffman shaped wavelet tree
	remove ((fn+".hwt").c_str());
}
示例#5
0
void testUtf8Circular(std::string const & fn)
{
	::libmaus::util::Utf8String us(fn);
	::libmaus::aio::Utf8CircularWrapper CW(fn);

	for ( uint64_t i = 0; i < 16*us.size(); ++i )
		assert ( us[i%us.size()] == static_cast<wchar_t>(CW.get()) );
}
示例#6
0
static int FUNC(quantisation_table)(CodedBitstreamContext *ctx, RWContext *rw,
                                     JPEGRawQuantisationTable *current)
{
    int err, i;

    u(4, Pq, 0, 1);
    u(4, Tq, 0, 3);

    if (current->Pq) {
        for (i = 0; i < 64; i++)
            us(16, Q[i], i, 1, 255);
    } else {
        for (i = 0; i < 64; i++)
            us(8,  Q[i], i, 1, 255);
    }

    return 0;
}
示例#7
0
void MainWindow::setFilterAmount()
{
    QString amt;
    QLocale us(QLocale::English,QLocale::UnitedStates);

    amt = "Filter total: ";
    amt.append(us.toCurrencyString(sumColumn(col_amount),us.currencySymbol()));
    ui->lblFilterTotal->setText(amt);
}
示例#8
0
TEST(QiOs, timeValCtor)
{
  qi::os::timeval t0 = qi::os::timeval();
  // t0 members are initialized to 0
  EXPECT_EQ(0, t0.tv_sec);
  EXPECT_EQ(0, t0.tv_usec);
  qi::os::timeval t1;
  // t1 members are initialized to 0
  EXPECT_EQ(0, t1.tv_sec);
  EXPECT_EQ(0, t1.tv_usec);

  // t2 members are not normalized
  qi::os::timeval t2(-1, -2);
  EXPECT_EQ(-1, t2.tv_sec);
  EXPECT_EQ(-2, t2.tv_usec);

  qi::Seconds s(123456789);
  qi::MicroSeconds us(123456);
  qi::NanoSeconds ns(789);
  qi::Duration d_us(s + us);
  qi::Duration d_ns(d_us + ns);
  qi::int64_t normalized_s = s.count();
  qi::int64_t normalized_us = us.count();

  // positive
  {
    qi::os::timeval tv0(d_us);
    EXPECT_EQ(normalized_s, tv0.tv_sec);
    EXPECT_EQ(normalized_us, tv0.tv_usec);

    qi::Duration d_back = qi::Seconds(tv0.tv_sec) +
                          qi::MicroSeconds(tv0.tv_usec);
    EXPECT_TRUE(d_us - d_back < qi::MicroSeconds(1));
    qi::os::timeval tv1(d_us);
    EXPECT_EQ(normalized_s, tv1.tv_sec);
    EXPECT_EQ(normalized_us, tv1.tv_usec);
  }
  // negative
  d_us = -d_us;
  d_ns = -d_ns;
  normalized_s = -s.count() - 1;
  normalized_us = -us.count() + 1000000;
  {
    qi::os::timeval tv0(d_us);
    EXPECT_EQ(normalized_s, tv0.tv_sec);
    EXPECT_EQ(normalized_us, tv0.tv_usec);

    qi::Duration d_back = qi::Seconds(tv0.tv_sec) +
                          qi::MicroSeconds(tv0.tv_usec);
    EXPECT_TRUE(d_us - d_back < qi::MicroSeconds(1));
    qi::os::timeval tv1(d_us);
    EXPECT_EQ(normalized_s, tv1.tv_sec);
    EXPECT_EQ(normalized_us, tv1.tv_usec);
  }
}
    inline std::string upcase(const std::string& s)
    {
	std::string us(s);
	// Getting the character type facet for toupper().
	// We use the classic (i.e. C) locale.
	const std::ctype<char>& ct = std::use_facet< std::ctype<char> >(std::locale::classic());
	for (int i = 0; i < int(s.size()); ++i) {
	    us[i] = ct.toupper(s[i]);
	}
	return us;
    }
示例#10
0
static int FUNC(huffman_table)(CodedBitstreamContext *ctx, RWContext *rw,
                               JPEGRawHuffmanTable *current)
{
    int err, i, j, ij;

    u(4, Tc, 0, 1);
    u(4, Th, 0, 3);

    for (i = 0; i < 16; i++)
        us(8, L[i], i, 0, 224);

    ij = 0;
    for (i = 0; i < 16; i++) {
        for (j = 0; j < current->L[i]; j++) {
            us(8, V[ij], ij, 0, 255);
            ++ij;
        }
    }

    return 0;
}
示例#11
0
int main(int argc, const char *argv[]) {
  puts("verify");
  UErrorCode errorCode = U_ZERO_ERROR;
#if defined (COLLUNSAFE_PATTERN)
  puts("verify pattern");
  const UnicodeString unsafeBackwardPattern(FALSE, collunsafe_pattern, collunsafe_len);
  fprintf(stderr, "\n -- pat '%c%c%c%c%c'\n",
          collunsafe_pattern[0],
          collunsafe_pattern[1],
          collunsafe_pattern[2],
          collunsafe_pattern[3],
          collunsafe_pattern[4]);
  if(U_SUCCESS(errorCode)) {
    UnicodeSet us(unsafeBackwardPattern, errorCode);
    fprintf(stderr, "\n%s:%d: err creating set %s\n", __FILE__, __LINE__, u_errorName(errorCode));
  }
#endif

#if defined (COLLUNSAFE_RANGE)
  {
    puts("verify range");
    UnicodeSet u;
    for(int32_t i=0;i<unsafe_rangeCount*2;i+=2) {
      u.add(unsafe_ranges[i+0],unsafe_ranges[i+1]);
    }
    printf("Finished with %d ranges\n", u.getRangeCount());
  }
#endif

#if defined (COLLUNSAFE_SERIALIZE)
  {
    puts("verify serialize");
    UnicodeSet u(unsafe_serializedData, unsafe_serializedCount, UnicodeSet::kSerialized, errorCode);
    fprintf(stderr, "\n%s:%d: err creating set %s\n", __FILE__, __LINE__, u_errorName(errorCode));
    printf("Finished deserialize with %d ranges\n", u.getRangeCount());
  }
#endif
// if(tailoring.unsafeBackwardSet == NULL) {
  //   errorCode = U_MEMORY_ALLOCATION_ERROR;
  //   fprintf(stderr, "\n%s:%d: err %s\n", __FILE__, __LINE__, u_errorName(errorCode));
  // }
  puts("verify col UCA");
  if(U_SUCCESS(errorCode)) {
    Collator *col = Collator::createInstance(Locale::getEnglish(), errorCode);
    fprintf(stderr, "\n%s:%d: err %s creating collator\n", __FILE__, __LINE__, u_errorName(errorCode));
  }
  
  if(U_FAILURE(errorCode)) {
    return 1;
  } else {
    return 0;
  }
}
示例#12
0
size_t StdStringToASUnicode(const std::string text, ASUnicode* buffer, size_t bufferMax)
{
    char* cstr = new char [text.length()+1];
    std::strcpy (cstr, text.c_str());
    
    ai::UnicodeString us(cstr);
    us.as_ASUnicode(buffer, bufferMax);
    
    delete[] cstr;
    
    return ai::UnicodeString(buffer).length();
}
示例#13
0
int main() {
    Undergrad us("Frodo Baggins", 5562, "Ring Theory", 4, 1220);
    GradStudent gs("Bilbo Baggins", 3029, "History", 6,
                    GradStudent::fellowship);
    cout << "Here is the data for the two students:\n";
    cout << gs.toString() << endl;
    cout << us.toString() << endl;
    cout << "\nHere is what happens when they finish their studies:\n";
    finish(&us);
    finish(&gs);
    return 0;
}
示例#14
0
    ~Performance(void)
    {
        if (is_measured)
        {
            int counter = counters[tag_];

            ms_results[tag_][counter] = ms();
            us_results[tag_][counter] = us();

            counters[tag_] = (counter+1) % RANGE;
        }
    }
示例#15
0
shared_ptr<ChatUser>
ConnectorOld::parseEnteredUser(QStringList recvMessage)
{
  shared_ptr<ChatUser> us(
        new ChatUser(
          this,
          recvMessage.at(0),
          recvMessage.at(2),
          recvMessage.at(3),
          recvMessage.at(4),
          recvMessage.at(5)));
  return us;
}
示例#16
0
_Accum mulkD(_Accum x, _Accum y)
{
#if BYTE_ORDER == BIG_ENDIAN
#  define LO 0
#  define HI 1
#else
#  define LO 1
#  define HI 0
#endif
  uint16_t xs[2];
  uint16_t ys[2];
  int8_t positive = ((x < 0 && y < 0) || (y > 0 && x > 0)) ? 1 : 0;
  y = absk(y);

#ifndef TEST_ON_PC
//clang doesn't allow pragma's within function def's
//Ignore gcc warnings on the following
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif

  *((_Accum*)xs) = absk(x);
  *((_Accum*)ys) = y;
  x = sl(xs[HI])*y + sl(xs[LO])*sl(ys[HI]);
  *((_Accum*)xs) = ul(xs[LO])*ul(ys[LO]);

#ifndef TEST_ON_PC
#pragma GCC diagnostic pop
#endif


  if(positive)
     return x + us(xs[HI]);
  else
     return -(x + us(xs[HI]));
#undef HI
#undef LO
}
示例#17
0
         void logTextview::writeLog(std::string const& _s)
         {
            // Add a timestamp.
            boost::posix_time::ptime t(boost::posix_time::second_clock::local_time());
            std::string timestamp = to_simple_string(t);

            // Add the string.
            Glib::ustring us("[" + timestamp + "] " + _s + "\n");
            Gtk::TextIter iter = get_buffer()->end();
            get_buffer()->insert(iter, us);

            // Scroll to the end of the buffer.
            scroll_to_mark(get_buffer()->create_mark("end", get_buffer()->end()), 0.0);
         }
示例#18
0
static int FUNC(scan_header)(CodedBitstreamContext *ctx, RWContext *rw,
                             JPEGRawScanHeader *current)
{
    int err, j;

    HEADER("Scan");

    u(16, Ls, 6, 6 + 2 * JPEG_MAX_COMPONENTS);

    u(8, Ns, 1, 4);
    for (j = 0; j < current->Ns; j++) {
        us(8, Cs[j], j, 0, JPEG_MAX_COMPONENTS);
        us(4, Td[j], j, 0, 3);
        us(4, Ta[j], j, 0, 3);
    }

    u(8, Ss, 0, 63);
    u(8, Se, 0, 63);
    u(4, Ah, 0, 13);
    u(4, Al, 0, 15);

    return 0;
}
示例#19
0
static int FUNC(frame_header)(CodedBitstreamContext *ctx, RWContext *rw,
                              JPEGRawFrameHeader *current)
{
    int err, i;

    HEADER("Frame Header");

    u(16, Lf, 8, 8 + 3 * JPEG_MAX_COMPONENTS);

    u(8,  P,  2, 16);
    u(16, Y,  0, JPEG_MAX_HEIGHT);
    u(16, X,  1, JPEG_MAX_WIDTH);
    u(8,  Nf, 1, JPEG_MAX_COMPONENTS);

    for (i = 0; i < current->Nf; i++) {
        us(8, C[i],  i, 0, JPEG_MAX_COMPONENTS);
        us(4, H[i],  i, 1, 4);
        us(4, V[i],  i, 1, 4);
        us(8, Tq[i], i, 0, 3);
    }

    return 0;
}
示例#20
0
Time Time::operator+=(int usecs) {
    int newUsecs = us() + usecs;
    int dSec = 0;
    while (newUsecs < 0) {
        dSec--;
        newUsecs += 1000000;
    }
    while (newUsecs > 1000000) {
        dSec++;
        newUsecs -= 1000000;            
    }
    t.tv_usec = newUsecs;
    t.tv_sec += dSec;    
    return *this;
}
示例#21
0
void Logger::Impl::FormatTime() {
	int64_t microSecondsSinceEpoch = timeStamp.GetMicroSecondsSinceEpoch();
	time_t seconds = static_cast<time_t>(microSecondsSinceEpoch / TimeStamp::MICRO_SECOND_PER_SECOND);
	int microSeconds = static_cast<int>(microSecondsSinceEpoch % TimeStamp::MICRO_SECOND_PER_SECOND);
	if (seconds != t_lastSecond) {
		t_lastSecond = seconds;
		struct tm tm_time;
		::gmtime_r(&seconds, &tm_time);

		int len = snprintf(t_time, sizeof(t_time), "%4d%02d%02d %02d:%02d:%02d"
			, tm_time.tm_year + 1900, tm_time.tm_mon + 1, tm_time.tm_mday
			, tm_time.tm_hour, tm_time.tm_min, tm_time.tm_sec);
		assert(len == 17);
	}

	Fmt us(".%06dZ ", microSeconds);
	assert(us.GetLength() == 9);
	stream << T(t_time, 17) << T(us.GetData(), 9);
}
示例#22
0
	char *get(char *buf, int maxbuf) {
		CBuf mybuf(maxbuf);
		char *pbuf = buf;

		do {
			int rc = readline(us(), pbuf, maxbuf);
			if (rc < 0){
				err("readLine err %d", rc);
				exit(-errno);
			}
/** BUG what if field is called ERROR ? should be on EOF line ? */
			if (strstr(pbuf, "ERROR") || strstr(pbuf, "FAIL")){
				++errors;
				err("MDS ERROR: %s", pbuf);
			}
			pbuf = mybuf.buf;
		} while (!strstr(pbuf, "EOF"));

		return buf;
	}
int main()
{
    // exact conversions allowed for integral reps
    {
        boost::chrono::milliseconds ms(1);
        boost::chrono::microseconds us = ms;
        BOOST_TEST(us.count() == 1000);
    }
    // inexact conversions allowed for floating point reps
    {
        boost::chrono::duration<double, boost::micro> us(1);
        boost::chrono::duration<double, boost::milli> ms = us;
        BOOST_TEST(ms.count() == 1./1000);
    }
    // Convert int to float
    {
        boost::chrono::duration<int> i(3);
        boost::chrono::duration<int> d = i;
        BOOST_TEST(d.count() == 3);
    }
    // default constructor
    {
        check_default<boost::chrono::duration<Rep> >();
    }
    // constructor from rep
    {
        check_from_rep<boost::chrono::duration<int> >(5);
        check_from_rep<boost::chrono::duration<int, boost::ratio<3, 2> > >(5);
        check_from_rep<boost::chrono::duration<Rep, boost::ratio<3, 2> > >(Rep(3));
        check_from_rep<boost::chrono::duration<double, boost::ratio<2, 3> > >(5.5);
    }
    // constructor from other rep
    {
        boost::chrono::duration<double> d(5);
        BOOST_TEST(d.count() == 5);
        return boost::report_errors();
    }
    
    return boost::report_errors();
}
示例#24
0
QMap<QString, QString>
Session::lastSessionData()
{
    Settings s;
    QMap<QString, QString> sessionData;

    //use the Username setting or the first username if there have been any logged in previously
    QString username = s.value( "Username", QString() ).toString();

    if( !username.isEmpty() )
    {
        UserSettings us( username );

        sessionData[ "username" ] = username;
        const QString sk = us.value( "SessionKey", "" ).toString();

        if( !sk.isEmpty() )
            sessionData[ "sessionKey" ] = sk;
    }

    return sessionData;
}
示例#25
0
int wy(int m, int JL, int K7zL, int nQ4v, int UFv, int OTU1, int FZu0) {
int KH;
int w;
int G;
int C8x;
int W;
;
while (us(703691925, - VyCm < 1738169888 > 113986089 < LRrJ - g3Ra, s9K)) while (X(N <= osq, nA)) while (YoG) My1g;
break;
{
int sX;
int g_t;
int TOh;
int y;
int wDNG;
int uhu;
int i;
int Zev;
int r;
Wt;
}
}
示例#26
0
static int FUNC(application_data)(CodedBitstreamContext *ctx, RWContext *rw,
                                  JPEGRawApplicationData *current)
{
    int err, i;

    HEADER("Application Data");

    u(16, Lp, 2, 65535);

    if (current->Lp > 2) {
#ifdef READ
        current->Ap_ref = av_buffer_alloc(current->Lp - 2);
        if (!current->Ap_ref)
            return AVERROR(ENOMEM);
        current->Ap = current->Ap_ref->data;
#endif

        for (i = 0; i < current->Lp - 2; i++)
            us(8, Ap[i], i, 0, 255);
    }

    return 0;
}
示例#27
0
static int FUNC(comment)(CodedBitstreamContext *ctx, RWContext *rw,
                         JPEGRawComment *current)
{
    int err, i;

    HEADER("Comment");

    u(16, Lc, 2, 65535);

    if (current->Lc > 2) {
#ifdef READ
        current->Cm_ref = av_buffer_alloc(current->Lc - 2);
        if (!current->Cm_ref)
            return AVERROR(ENOMEM);
        current->Cm = current->Cm_ref->data;
#endif

        for (i = 0; i < current->Lc - 2; i++)
            us(8, Cm[i], i, 0, 255);
    }

    return 0;
}
示例#28
0
status_t
ShowImageWindow::_LoadImage(bool forward)
{
	BMessenger us(this);
	status_t status = my_app->DefaultCache().RetrieveImage(
		fNavigator.CurrentRef(), fNavigator.CurrentPage(), &us);
	if (status != B_OK)
		return status;

	fProgressWindow->Start(this);

	// Preload previous/next images - two in the navigation direction, one
	// in the opposite direction.

	entry_ref nextRef = fNavigator.CurrentRef();
	if (_PreloadImage(forward, nextRef))
		_PreloadImage(forward, nextRef);

	entry_ref previousRef = fNavigator.CurrentRef();
	_PreloadImage(!forward, previousRef);

	return B_OK;
}
示例#29
0
void Logger::formatTime()
{
	int64_t microSecondsSinceEpoch = time_.microSecondsSinceEpoch();
	time_t seconds = static_cast<time_t>(microSecondsSinceEpoch / Timestamp::kMicroSecondsPerSecond);
	int microseconds = static_cast<int>(microSecondsSinceEpoch % Timestamp::kMicroSecondsPerSecond);

	if (seconds != t_lastSecond) //如果seconds一样不用重新获取t_time,加快速度
	{
		t_lastSecond = seconds;
		struct tm tm_time;
		
		//::gmtime_r(&seconds, &tm_time); // FIXME TimeZone::fromUtcTime
		

		#ifdef WIN
					//gmtime_s(&tm_time, &seconds);//thread-safe gmtime
					localtime_s(&tm_time, &seconds); //localtime_r得到小时数会多8,因为china是+8区。同样建议使用localtime_r版本。
		#else
			//gmtime_r(&seconds, &tm_time); //linux下gmtime_r为可重入版本
			localtime_s(&tm_time, &seconds); //localtime_r得到小时数会多8,因为china是+8区。同样建议使用localtime_r版本。
		#endif


		int len = snprintf(t_time, sizeof(t_time), "%4d%02d%02d %02d:%02d:%02d",
			tm_time.tm_year + 1900, tm_time.tm_mon + 1, tm_time.tm_mday,
			tm_time.tm_hour, tm_time.tm_min, tm_time.tm_sec);
		assert(len == 17); (void)len;

	}

	Fmt us(".%06dZ ", microseconds);
	assert(us.length() == 9);
	stream_ << T(t_time, 17) << T(us.data(), 9); //T类定义看本文件



}
示例#30
0
void DdmSSAPIDriver::cbQueryAlarms(
 		U16 numberOfAlarms,
		AlarmRecord* pAlarmRecords,
		U16 numberOfAlarmLogEntries,
		AlarmLogRecord* pAlarmLogEntries,
		STATUS status_)
{
	U32 i;
	static U16 j = 0;
	UnicodeString us(StringClass("Jaymie"));
	TRACE_ENTRY(DdmSSAPIDriver::cbQueryAlarms(STATUS, void*));
	
	if (j==1)
	{
		for (i = 0; i < numberOfAlarms; i++)
		{
			if ((pAlarmRecords[i].did != this->GetDid()) &&
				(pAlarmRecords[i].clearable==TRUE))
			{
				RemitAlarmFromUser(pAlarmRecords[i].rid, us);
				break;
			}
		}
		for (i = 0; i < numberOfAlarms; i++)
		{
			if ((pAlarmRecords[i].did != this->GetDid()) &&
				(pAlarmRecords[i].clearable==FALSE))
			{
				RemitAlarmFromUser(pAlarmRecords[i].rid, us);
				break;
			}
		}
	}

	MessageControl();
	j++;
}