Another set of refactoring
diff --git a/helper/ccnb-parser/syntax-tree/block.cc b/helper/ccnb-parser/syntax-tree/block.cc
new file mode 100644
index 0000000..0d425dd
--- /dev/null
+++ b/helper/ccnb-parser/syntax-tree/block.cc
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "block.h"
+
+#include "blob.h"
+#include "udata.h"
+#include "tag.h"
+#include "dtag.h"
+#include "attr.h"
+#include "dattr.h"
+#include "ext.h"
+
+#include "ns3/log.h"
+
+NS_LOG_COMPONENT_DEFINE ("ndn.CcnbParser.Block");
+
+namespace ns3 {
+namespace ndn {
+namespace CcnbParser {
+
+/// @cond include_hidden
+const uint8_t CCN_TT_BITS = 3;
+const uint8_t CCN_TT_MASK = ((1 << CCN_TT_BITS) - 1);
+const uint8_t CCN_MAX_TINY= ((1 << (7-CCN_TT_BITS)) - 1);
+const uint8_t CCN_TT_HBIT = ((uint8_t)(1 << 7));
+/// @endcond
+
+// int Block::counter = 0;
+
+Ptr<Block> Block::ParseBlock (Buffer::Iterator &start)
+{
+  // std::cout << "<< pos: " << counter << "\n";
+  uint32_t value = 0;
+
+  // We will have problems if length field is more than 32 bits. Though it's really impossible
+  uint8_t byte = 0;
+  while (!start.IsEnd() && !(byte & CCN_TT_HBIT))
+    {
+      value <<= 8;
+      value += byte;
+      byte = start.ReadU8 ();
+      // Block::counter ++;
+    }
+  if (start.IsEnd())
+    CcnbDecodingException ();
+  
+  value <<= 4;
+  value += ( (byte&(~CCN_TT_HBIT)) >> 3);
+  
+  /**
+   * Huh. After fighting with NS-3, it became apparent that Create<T>(...) construct
+   * doesn't work with references.  Just simply doesn't work.  wtf?
+   */
+  switch (byte & CCN_TT_MASK)
+    {
+    case CCN_BLOB:
+      return Ptr<Blob> (new Blob(start, value), false);
+    case CCN_UDATA:
+      return Ptr<Udata> (new Udata(start, value), false);
+    case CCN_TAG:
+      return Ptr<Tag> (new Tag(start, value), false);
+    case CCN_ATTR:
+      return Ptr<Attr> (new Attr(start, value), false);
+    case CCN_DTAG:
+      return Ptr<Dtag> (new Dtag(start, value), false);
+    case CCN_DATTR:
+      return Ptr<Dattr> (new Dattr(start, value), false);
+    case CCN_EXT:
+      return Ptr<Ext> (new Ext(start, value), false);
+    default:
+      throw CcnbDecodingException ();
+    }
+}
+
+Block::~Block ()
+{
+}
+
+}
+}
+}