> For the complete documentation index, see [llms.txt](https://mwm5.twelite.info/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mwm5.twelite.info/0.8/references/parser/twefmt/twepacket/reftwepacket.md).

# refTwePacket()

本関数は[`spTwePacket`](/0.8/references/parser/twefmt/twepacket.md)オブジェクトを[`TwePacket&`](/0.8/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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/0.8/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.
