# refTwePacket()

本関数は[`spTwePacket`](/master-2/references/parser/twefmt/twepacket.md)オブジェクトを[`TwePacket&`](/master-2/references/parser/twefmt/twepacket.md)として参照します。

```cpp
TwePacket& refTwePacket(spTwePacket& p)

//例
  auto&& pkt = newTwePacket(p, len); // パケットの生成
  
  if (refTwePacket(pkt).get_type() == E_PKT::PKT_TWELITE) {
    // App_Twelite の処理
  }
```

{% hint style="info" %}
この関数は、`->`演算子や`*`演算子を極力使用しない方針でライブラリを設定しているため、スマートポインタの参照を行うために用意しています。

上記の判定式を`(pkt && pkt->get_type() == E_PKT::PKT_TWELITE)`と記述しても同じ判定が得られます。
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mwm5.twelite.info/master-2/references/parser/twefmt/twepacket/reftwepacket.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
