Bitstream Interpretation Library (BIL)  0.1
SyncWordRawData.cpp
Go to the documentation of this file.
1 
8 
9 using namespace bil;
10 
11 
12 const size_t SYNCHRO_WORD_SIZE = 1;
13 const boost::uint32_t SYNCHRO_WORD = 0xaa995566;
14 
15 
16 size_t bil::isSyncWord(const boost::uint32_t* words, size_t wordCount)
17 {
18  // test if data is large enough
19  if (SYNCHRO_WORD_SIZE > wordCount) return 0;
20  // test if sync word is correct
21  if (SYNCHRO_WORD != *words) return 0;
22  // sync word raw data found, return its size
23  return SYNCHRO_WORD_SIZE;
24 }
25 
26 
27 size_t bil::writeSyncWord(boost::uint32_t* words, size_t wordCount)
28 {
29  // check if buffer is large enough
30  if (SYNCHRO_WORD_SIZE > wordCount) throw Exception();
31  // write sync word
32  *words = SYNCHRO_WORD;
33  // return written size
34  return SYNCHRO_WORD_SIZE;
35 }